summaryrefslogtreecommitdiff
path: root/src/components/application_manager/test/commands/mobile
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/application_manager/test/commands/mobile')
-rw-r--r--src/components/application_manager/test/commands/mobile/add_command_request_test.cc1084
-rw-r--r--src/components/application_manager/test/commands/mobile/add_sub_menu_request_test.cc121
-rw-r--r--src/components/application_manager/test/commands/mobile/alert_maneuver_request_test.cc265
-rw-r--r--src/components/application_manager/test/commands/mobile/alert_request_test.cc771
-rw-r--r--src/components/application_manager/test/commands/mobile/change_registration_test.cc565
-rw-r--r--src/components/application_manager/test/commands/mobile/create_interaction_choice_set_test.cc814
-rw-r--r--src/components/application_manager/test/commands/mobile/delete_command_request_test.cc258
-rw-r--r--src/components/application_manager/test/commands/mobile/delete_file_test.cc246
-rw-r--r--src/components/application_manager/test/commands/mobile/delete_interaction_choice_set_test.cc284
-rw-r--r--src/components/application_manager/test/commands/mobile/delete_sub_menu_test.cc338
-rw-r--r--src/components/application_manager/test/commands/mobile/diagnostic_message_request_test.cc185
-rw-r--r--src/components/application_manager/test/commands/mobile/dial_number_request_test.cc187
-rw-r--r--src/components/application_manager/test/commands/mobile/dummy_mobile_commands_test.cc342
-rw-r--r--src/components/application_manager/test/commands/mobile/end_audio_pass_thru_request_test.cc120
-rw-r--r--src/components/application_manager/test/commands/mobile/get_dtcs_request_test.cc142
-rw-r--r--src/components/application_manager/test/commands/mobile/get_vehicle_data_request_test.cc254
-rw-r--r--src/components/application_manager/test/commands/mobile/get_way_points_request_test.cc284
-rw-r--r--src/components/application_manager/test/commands/mobile/list_files_request_test.cc145
-rw-r--r--src/components/application_manager/test/commands/mobile/on_button_notification_commands_test.cc355
-rw-r--r--src/components/application_manager/test/commands/mobile/on_command_notification_test.cc137
-rw-r--r--src/components/application_manager/test/commands/mobile/on_hash_change_notification_test.cc117
-rw-r--r--src/components/application_manager/test/commands/mobile/on_hmi_status_notification_from_mobile_test.cc282
-rw-r--r--src/components/application_manager/test/commands/mobile/on_hmi_status_notification_test.cc206
-rw-r--r--src/components/application_manager/test/commands/mobile/on_keyboard_input_notification_test.cc164
-rw-r--r--src/components/application_manager/test/commands/mobile/on_system_request_notification_test.cc206
-rw-r--r--src/components/application_manager/test/commands/mobile/on_tbt_client_state_notification_test.cc140
-rw-r--r--src/components/application_manager/test/commands/mobile/on_touch_event_notification_test.cc149
-rw-r--r--src/components/application_manager/test/commands/mobile/on_vehicle_data_notification_test.cc148
-rw-r--r--src/components/application_manager/test/commands/mobile/on_way_point_change_notification_test.cc116
-rw-r--r--src/components/application_manager/test/commands/mobile/perform_audio_pass_thru_test.cc801
-rw-r--r--src/components/application_manager/test/commands/mobile/perform_interaction_test.cc262
-rw-r--r--src/components/application_manager/test/commands/mobile/put_file_test.cc351
-rw-r--r--src/components/application_manager/test/commands/mobile/read_did_request_test.cc166
-rw-r--r--src/components/application_manager/test/commands/mobile/register_app_interface_request_test.cc522
-rw-r--r--src/components/application_manager/test/commands/mobile/reset_global_properties_test.cc565
-rw-r--r--src/components/application_manager/test/commands/mobile/scrollable_message_test.cc289
-rw-r--r--src/components/application_manager/test/commands/mobile/send_haptic_data_test.cc163
-rw-r--r--src/components/application_manager/test/commands/mobile/send_location_request_test.cc396
-rw-r--r--src/components/application_manager/test/commands/mobile/set_app_icon_test.cc151
-rw-r--r--src/components/application_manager/test/commands/mobile/set_display_layout_test.cc254
-rw-r--r--src/components/application_manager/test/commands/mobile/set_global_properties_test.cc1229
-rw-r--r--src/components/application_manager/test/commands/mobile/set_media_clock_timer_test.cc352
-rw-r--r--src/components/application_manager/test/commands/mobile/show_test.cc937
-rw-r--r--src/components/application_manager/test/commands/mobile/simple_notification_commands_test.cc99
-rw-r--r--src/components/application_manager/test/commands/mobile/simple_response_commands_test.cc199
-rw-r--r--src/components/application_manager/test/commands/mobile/slider_test.cc341
-rw-r--r--src/components/application_manager/test/commands/mobile/speak_request_test.cc398
-rw-r--r--src/components/application_manager/test/commands/mobile/subscribe_button_request_test.cc204
-rw-r--r--src/components/application_manager/test/commands/mobile/subscribe_way_points_request_test.cc129
-rw-r--r--src/components/application_manager/test/commands/mobile/system_request_test.cc135
-rw-r--r--src/components/application_manager/test/commands/mobile/unregister_app_interface_request_test.cc118
-rw-r--r--src/components/application_manager/test/commands/mobile/unsubscribe_button_request_test.cc156
-rw-r--r--src/components/application_manager/test/commands/mobile/unsubscribe_vehicle_request_test.cc287
-rw-r--r--src/components/application_manager/test/commands/mobile/unsubscribe_vehicle_response_test.cc111
-rw-r--r--src/components/application_manager/test/commands/mobile/unsubscribe_way_points_request_test.cc172
-rw-r--r--src/components/application_manager/test/commands/mobile/update_turn_list_request_test.cc305
56 files changed, 0 insertions, 17517 deletions
diff --git a/src/components/application_manager/test/commands/mobile/add_command_request_test.cc b/src/components/application_manager/test/commands/mobile/add_command_request_test.cc
deleted file mode 100644
index 471f0763de..0000000000
--- a/src/components/application_manager/test/commands/mobile/add_command_request_test.cc
+++ /dev/null
@@ -1,1084 +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 <set>
-
-#include "application_manager/commands/mobile/add_command_request.h"
-
-#include "gtest/gtest.h"
-#include "utils/shared_ptr.h"
-#include "utils/helpers.h"
-#include "utils/make_shared.h"
-#include "smart_objects/smart_object.h"
-#include "utils/custom_string.h"
-#include "application_manager/commands/command_request_test.h"
-#include "application_manager/smart_object_keys.h"
-#include "application_manager/mock_application.h"
-#include "application_manager/mock_application_manager.h"
-#include "application_manager/mock_message_helper.h"
-#include "application_manager/event_engine/event.h"
-#include "application_manager/mock_hmi_interface.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace add_command_request {
-
-namespace am = application_manager;
-using am::commands::CommandImpl;
-using am::ApplicationManager;
-using am::commands::MessageSharedPtr;
-using am::ApplicationSharedPtr;
-using ::testing::_;
-using ::utils::SharedPtr;
-using ::testing::Return;
-using ::testing::InSequence;
-using am::commands::AddCommandRequest;
-using NsSmartDeviceLink::NsSmartObjects::SmartObjectSPtr;
-using ::test::components::application_manager_test::MockApplication;
-using am::event_engine::EventObserver;
-using namespace smart_objects;
-
-namespace custom_str = utils::custom_string;
-namespace strings = ::application_manager::strings;
-namespace mobile_result = mobile_apis::Result;
-namespace hmi_response = ::application_manager::hmi_response;
-namespace hmi_request = ::application_manager::hmi_request;
-using namespace strings;
-
-namespace {
-const hmi_apis::FunctionID::eType kInvalidFunctionId =
- hmi_apis::FunctionID::INVALID_ENUM;
-const uint32_t kAppId = 1u;
-const uint32_t kCmdId = 1u;
-const uint32_t kConnectionKey = 2u;
-const std::string kMenuName = "LG";
-const uint32_t kFirstParentId = 10u;
-const uint32_t kSecondParentId = 1u;
-const std::string kErroredVRCommand = "l\namer";
-const std::string kFirstVrCommand = "lamer";
-const std::string kSecondVrCommand = "hacker";
-const uint32_t kFirstCommandId = 10u;
-const uint32_t kSecondCommandId = 11u;
-const int32_t kType = 34;
-const int32_t kGrammarId = 12;
-const int32_t kPosition = 10;
-} // namespace
-
-class AddCommandRequestTest
- : public CommandRequestTest<CommandsTestMocks::kIsNice> {
- public:
- AddCommandRequestTest()
- : msg_(CreateMessage())
- , default_app_name_("test_default_app_name_")
- , mock_app_(CreateMockApp()) {
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillRepeatedly(Return(mock_app_));
- InitGetters();
- InitBasicMessage();
- }
-
- protected:
- void InitBasicMessage() {
- (*msg_)[params][connection_key] = kConnectionKey;
- (*msg_)[msg_params][app_id] = kAppId;
- (*msg_)[msg_params][app_name] = default_app_name_;
- }
-
- void InitGetters() {
- ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kAppId));
- ON_CALL(*mock_app_, FindCommand(kCmdId))
- .WillByDefault(Return(so_ptr_.get()));
- }
-
- void CreateBasicParamsUIRequest() {
- SmartObject menu_params = SmartObject(SmartType_Map);
- menu_params[position] = kPosition;
- menu_params[menu_name] = kMenuName;
- SmartObject& msg_params = (*msg_)[strings::msg_params];
- msg_params[cmd_id] = kCmdId;
- msg_params[strings::menu_params] = menu_params;
- msg_params[cmd_icon] = 1;
- msg_params[cmd_icon][value] = "10";
- msg_params[info] = "UI info";
- }
-
- void CreateBasicParamsVRRequest() {
- SmartObject& msg_params = (*msg_)[strings::msg_params];
- msg_params[cmd_id] = kCmdId;
- msg_params[vr_commands] = SmartObject(SmartType_Array);
- msg_params[vr_commands][0] = kFirstVrCommand;
- msg_params[type] = kPosition;
- msg_params[grammar_id] = kGrammarId;
- msg_params[info] = "VR info";
- }
-
- const am::CommandsMap CreateCommandsMap(SmartObject& first_command,
- SmartObject& second_command) {
- second_command[menu_params] = SmartObject(SmartType_Map);
- second_command[menu_params][hmi_request::parent_id] = kFirstParentId;
- second_command[menu_params][menu_name] = kMenuName;
- second_command[vr_commands] = SmartObject(SmartType_Array);
- second_command[vr_commands][0] = kSecondVrCommand;
- am::CommandsMap commands_map;
- commands_map.insert(std::make_pair(kFirstCommandId, &first_command));
- commands_map.insert(std::make_pair(kSecondCommandId, &second_command));
- return commands_map;
- }
-
- void CheckOnTimeOutCommandDeletion(
- const hmi_apis::FunctionID::eType incoming_cmd,
- const hmi_apis::FunctionID::eType cmd_to_delete) {
- CreateBasicParamsVRRequest();
- CreateBasicParamsUIRequest();
- SmartObject& msg_params = (*msg_)[strings::msg_params];
- msg_params[menu_params][hmi_request::parent_id] = kSecondParentId;
- SmartObject& image = msg_params[cmd_icon];
- EXPECT_CALL(mock_message_helper_, VerifyImage(image, _, _))
- .WillOnce(Return(mobile_apis::Result::SUCCESS));
- EXPECT_CALL(*mock_app_, FindCommand(kCmdId))
- .WillOnce(Return(so_ptr_.get()));
- SmartObject first_command = SmartObject(SmartType_Map);
- SmartObject second_command = SmartObject(SmartType_Map);
- const am::CommandsMap commands_map =
- CreateCommandsMap(first_command, second_command);
- EXPECT_CALL(*mock_app_, commands_map())
- .WillRepeatedly(Return(DataAccessor<application_manager::CommandsMap>(
- commands_map, lock_)));
- so_ptr_ = utils::MakeShared<SmartObject>(SmartType_Map);
- EXPECT_CALL(*mock_app_, FindSubMenu(kSecondParentId))
- .WillOnce(Return(so_ptr_.get()));
- {
- InSequence dummy;
- EXPECT_CALL(app_mngr_,
- ManageHMICommand(
- HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand)))
- .WillOnce(Return(true));
- EXPECT_CALL(app_mngr_,
- ManageHMICommand(
- HMIResultCodeIs(hmi_apis::FunctionID::VR_AddCommand)))
- .WillOnce(Return(true));
- }
- EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0);
- utils::SharedPtr<AddCommandRequest> request_ptr =
- CreateCommand<AddCommandRequest>(msg_);
- request_ptr->Run();
- Event event(incoming_cmd);
- event.set_smart_object(*msg_);
- request_ptr->on_event(event);
- EXPECT_CALL(*mock_app_, RemoveCommand(kCmdId));
- EXPECT_CALL(app_mngr_, ManageHMICommand(HMIResultCodeIs(cmd_to_delete)))
- .WillOnce(Return(true));
- SmartObjectSPtr response = utils::MakeShared<SmartObject>(SmartType_Map);
- (*response)[strings::msg_params][strings::info] = "info";
- EXPECT_CALL(
- mock_message_helper_,
- CreateNegativeResponse(_, _, _, mobile_apis::Result::GENERIC_ERROR))
- .WillOnce(Return(response));
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(response,
- am::commands::Command::CommandOrigin::ORIGIN_SDL));
- utils::SharedPtr<CommandRequestImpl> base_class_request =
- static_cast<utils::SharedPtr<CommandRequestImpl> >(request_ptr);
- base_class_request->onTimeOut();
- }
-
- MessageSharedPtr msg_;
- SmartObjectSPtr so_ptr_;
- const utils::custom_string::CustomString default_app_name_;
- sync_primitives::Lock lock_;
- MockAppPtr mock_app_;
-};
-
-TEST_F(AddCommandRequestTest, Run_AppNotExisted_EXPECT_AppNotRegistered) {
- CreateBasicParamsUIRequest();
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(ApplicationSharedPtr()));
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(
- MobileResultCodeIs(mobile_result::APPLICATION_NOT_REGISTERED), _));
- utils::SharedPtr<AddCommandRequest> request_ptr =
- CreateCommand<AddCommandRequest>(msg_);
- request_ptr->Run();
-}
-
-TEST_F(AddCommandRequestTest, Run_ImageVerificationFailed_EXPECT_INVALID_DATA) {
- CreateBasicParamsUIRequest();
- SmartObject& msg_params = (*msg_)[strings::msg_params];
- SmartObject& image = msg_params[cmd_icon];
- EXPECT_CALL(mock_message_helper_, VerifyImage(image, _, _))
- .WillOnce(Return(mobile_apis::Result::INVALID_DATA));
- EXPECT_CALL(app_mngr_,
- ManageMobileCommand(
- MobileResultCodeIs(mobile_apis::Result::INVALID_DATA), _));
- utils::SharedPtr<AddCommandRequest> request_ptr =
- CreateCommand<AddCommandRequest>(msg_);
- request_ptr->Run();
-}
-
-TEST_F(AddCommandRequestTest, Run_MenuNameHasSyntaxError_EXPECT_INVALID_DATA) {
- CreateBasicParamsUIRequest();
- SmartObject& msg_params = (*msg_)[strings::msg_params];
- msg_params[menu_params][hmi_request::parent_id] = kFirstParentId;
- const std::string errored_menu_name = "L\nG";
- msg_params[menu_params][menu_name] = errored_menu_name;
- SmartObject& image = msg_params[cmd_icon];
- EXPECT_CALL(mock_message_helper_, VerifyImage(image, _, _))
- .WillOnce(Return(mobile_apis::Result::SUCCESS));
- EXPECT_CALL(*mock_app_, FindCommand(kCmdId)).WillOnce(Return(so_ptr_.get()));
- am::CommandsMap commands_map;
- EXPECT_CALL(*mock_app_, commands_map())
- .WillRepeatedly(Return(
- DataAccessor<application_manager::CommandsMap>(commands_map, lock_)));
- SmartObject parent = SmartObject(SmartType_Map);
- EXPECT_CALL(*mock_app_, FindSubMenu(kFirstParentId))
- .WillOnce(Return(&parent));
- EXPECT_CALL(app_mngr_,
- ManageMobileCommand(
- MobileResultCodeIs(mobile_apis::Result::INVALID_DATA), _));
- utils::SharedPtr<AddCommandRequest> request_ptr =
- CreateCommand<AddCommandRequest>(msg_);
- request_ptr->Run();
-}
-
-TEST_F(AddCommandRequestTest,
- Run_VRCommandsHaveSyntaxError_EXPECT_INVALID_DATA) {
- CreateBasicParamsVRRequest();
- SmartObject& msg_params = (*msg_)[strings::msg_params];
- msg_params[vr_commands][0] = kErroredVRCommand;
- EXPECT_CALL(*mock_app_, FindCommand(kCmdId)).WillOnce(Return(so_ptr_.get()));
- am::CommandsMap commands_map;
- EXPECT_CALL(*mock_app_, commands_map())
- .WillRepeatedly(Return(
- DataAccessor<application_manager::CommandsMap>(commands_map, lock_)));
- EXPECT_CALL(app_mngr_,
- ManageMobileCommand(
- MobileResultCodeIs(mobile_apis::Result::INVALID_DATA), _));
- utils::SharedPtr<AddCommandRequest> request_ptr =
- CreateCommand<AddCommandRequest>(msg_);
- request_ptr->Run();
-}
-
-TEST_F(AddCommandRequestTest, Run_CMDIconHasError_EXPECT_INVALID_DATA) {
- MessageSharedPtr msg = CreateMessage();
- SmartObject& msg_params = (*msg)[strings::msg_params];
- (*msg)[params][connection_key] = kConnectionKey;
- msg_params[cmd_id] = kCmdId;
- msg_params[cmd_icon] = 1;
- const std::string errored_cmd_icon_value = "1\n0";
- msg_params[cmd_icon][value] = errored_cmd_icon_value;
- msg_params[vr_commands][0] = kFirstVrCommand;
- SmartObject& image = msg_params[cmd_icon];
- EXPECT_CALL(mock_message_helper_, VerifyImage(image, _, _))
- .WillOnce(Return(mobile_apis::Result::SUCCESS));
- EXPECT_CALL(*mock_app_, FindCommand(kCmdId)).WillOnce(Return(so_ptr_.get()));
- am::CommandsMap commands_map;
- EXPECT_CALL(*mock_app_, commands_map())
- .WillRepeatedly(Return(
- DataAccessor<application_manager::CommandsMap>(commands_map, lock_)));
- EXPECT_CALL(app_mngr_,
- ManageMobileCommand(
- MobileResultCodeIs(mobile_apis::Result::INVALID_DATA), _));
- utils::SharedPtr<AddCommandRequest> request_ptr =
- CreateCommand<AddCommandRequest>(msg);
- request_ptr->Run();
-}
-
-TEST_F(AddCommandRequestTest, Run_CommandIDAlreadyExists_EXPECT_INVALID_ID) {
- CreateBasicParamsUIRequest();
- SmartObject& msg_params = (*msg_)[strings::msg_params];
- SmartObject& image = msg_params[cmd_icon];
- EXPECT_CALL(mock_message_helper_, VerifyImage(image, _, _))
- .WillOnce(Return(mobile_apis::Result::SUCCESS));
- so_ptr_ = utils::MakeShared<SmartObject>(SmartType_Map);
- EXPECT_CALL(*mock_app_, FindCommand(kCmdId)).WillOnce(Return(so_ptr_.get()));
- EXPECT_CALL(app_mngr_,
- ManageMobileCommand(
- MobileResultCodeIs(mobile_apis::Result::INVALID_ID), _));
- utils::SharedPtr<AddCommandRequest> request_ptr =
- CreateCommand<AddCommandRequest>(msg_);
- request_ptr->Run();
-}
-
-TEST_F(AddCommandRequestTest,
- Run_CommandNameAlreadyExists_EXPECT_DUPLICATE_NAME) {
- CreateBasicParamsUIRequest();
- SmartObject& msg_params = (*msg_)[strings::msg_params];
- msg_params[menu_params][hmi_request::parent_id] = kFirstParentId;
- SmartObject& image = msg_params[cmd_icon];
- EXPECT_CALL(mock_message_helper_, VerifyImage(image, _, _))
- .WillOnce(Return(mobile_apis::Result::SUCCESS));
- EXPECT_CALL(*mock_app_, FindCommand(kCmdId)).WillOnce(Return(so_ptr_.get()));
- SmartObject first_command = SmartObject(SmartType_Map);
- SmartObject second_command = SmartObject(SmartType_Map);
- const am::CommandsMap commands_map =
- CreateCommandsMap(first_command, second_command);
- EXPECT_CALL(*mock_app_, commands_map())
- .WillRepeatedly(Return(
- DataAccessor<application_manager::CommandsMap>(commands_map, lock_)));
- EXPECT_CALL(app_mngr_,
- ManageMobileCommand(
- MobileResultCodeIs(mobile_apis::Result::DUPLICATE_NAME), _));
- utils::SharedPtr<AddCommandRequest> request_ptr =
- CreateCommand<AddCommandRequest>(msg_);
- request_ptr->Run();
-}
-
-TEST_F(AddCommandRequestTest,
- Run_CmdAndMsgParentIDsAreDifferentSubmenuNotExisted_EXPECT_INVALID_ID) {
- CreateBasicParamsUIRequest();
- SmartObject& msg_params = (*msg_)[strings::msg_params];
- msg_params[menu_params][hmi_request::parent_id] = kSecondParentId;
- SmartObject& image = msg_params[cmd_icon];
- EXPECT_CALL(mock_message_helper_, VerifyImage(image, _, _))
- .WillOnce(Return(mobile_apis::Result::SUCCESS));
- EXPECT_CALL(*mock_app_, FindCommand(kCmdId)).WillOnce(Return(so_ptr_.get()));
- SmartObject first_command = SmartObject(SmartType_Map);
- SmartObject second_command = SmartObject(SmartType_Map);
- const am::CommandsMap commands_map =
- CreateCommandsMap(first_command, second_command);
- EXPECT_CALL(*mock_app_, commands_map())
- .WillRepeatedly(Return(
- DataAccessor<application_manager::CommandsMap>(commands_map, lock_)));
- EXPECT_CALL(*mock_app_, FindSubMenu(kSecondParentId))
- .WillOnce(Return(so_ptr_.get()));
- EXPECT_CALL(app_mngr_,
- ManageMobileCommand(
- MobileResultCodeIs(mobile_apis::Result::INVALID_ID), _));
- utils::SharedPtr<AddCommandRequest> request_ptr =
- CreateCommand<AddCommandRequest>(msg_);
- request_ptr->Run();
-}
-
-TEST_F(AddCommandRequestTest,
- Run_CmdAndMsgVrSynonymsAreTheSame_EXPECT_DUPLICATE_NAME) {
- CreateBasicParamsVRRequest();
- SmartObject& msg_params = (*msg_)[strings::msg_params];
- msg_params[menu_params][hmi_request::parent_id] = kSecondParentId;
- msg_params[vr_commands][0] = kSecondVrCommand;
- SmartObject& image = msg_params[cmd_icon];
- EXPECT_CALL(mock_message_helper_, VerifyImage(image, _, _))
- .WillOnce(Return(mobile_apis::Result::SUCCESS));
- EXPECT_CALL(*mock_app_, FindCommand(kCmdId)).WillOnce(Return(so_ptr_.get()));
-
- SmartObject first_command = SmartObject(SmartType_Map);
- SmartObject second_command = SmartObject(SmartType_Map);
- const am::CommandsMap commands_map =
- CreateCommandsMap(first_command, second_command);
- EXPECT_CALL(*mock_app_, commands_map())
- .WillRepeatedly(Return(
- DataAccessor<application_manager::CommandsMap>(commands_map, lock_)));
- so_ptr_ = utils::MakeShared<SmartObject>(SmartType_Map);
- EXPECT_CALL(*mock_app_, FindSubMenu(kSecondParentId))
- .WillOnce(Return(so_ptr_.get()));
- EXPECT_CALL(app_mngr_,
- ManageMobileCommand(
- MobileResultCodeIs(mobile_apis::Result::DUPLICATE_NAME), _));
- utils::SharedPtr<AddCommandRequest> request_ptr =
- CreateCommand<AddCommandRequest>(msg_);
- request_ptr->Run();
-}
-
-TEST_F(AddCommandRequestTest, Run_MsgDataEmpty_EXPECT_INVALID_DATA) {
- MessageSharedPtr msg = CreateMessage();
- (*msg)[params][connection_key] = kConnectionKey;
- SmartObject& msg_params = (*msg)[strings::msg_params];
- msg_params[app_id] = kAppId;
- msg_params[cmd_id] = kCmdId;
- EXPECT_CALL(*mock_app_, FindCommand(kCmdId)).WillOnce(Return(so_ptr_.get()));
- EXPECT_CALL(app_mngr_,
- ManageMobileCommand(
- MobileResultCodeIs(mobile_apis::Result::INVALID_DATA), _));
- utils::SharedPtr<AddCommandRequest> request_ptr =
- CreateCommand<AddCommandRequest>(msg);
- request_ptr->Run();
-}
-
-TEST_F(AddCommandRequestTest,
- Run_CmdAndMsg_UI_and_Vr_AreCorrect_EXPECT_VR_AND_UI_SENT) {
- CreateBasicParamsVRRequest();
- CreateBasicParamsUIRequest();
- SmartObject& msg_params = (*msg_)[strings::msg_params];
- msg_params[menu_params][hmi_request::parent_id] = kSecondParentId;
- SmartObject& image = msg_params[cmd_icon];
- EXPECT_CALL(mock_message_helper_, VerifyImage(image, _, _))
- .WillOnce(Return(mobile_apis::Result::SUCCESS));
- EXPECT_CALL(*mock_app_, FindCommand(kCmdId)).WillOnce(Return(so_ptr_.get()));
- SmartObject first_command = SmartObject(SmartType_Map);
- SmartObject second_command = SmartObject(SmartType_Map);
- const am::CommandsMap commands_map =
- CreateCommandsMap(first_command, second_command);
- EXPECT_CALL(*mock_app_, commands_map())
- .WillRepeatedly(Return(
- DataAccessor<application_manager::CommandsMap>(commands_map, lock_)));
- so_ptr_ = utils::MakeShared<SmartObject>(SmartType_Map);
- EXPECT_CALL(*mock_app_, FindSubMenu(kSecondParentId))
- .WillOnce(Return(so_ptr_.get()));
- {
- InSequence dummy;
- EXPECT_CALL(
- app_mngr_,
- ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand)))
- .WillOnce(Return(true));
- EXPECT_CALL(
- app_mngr_,
- ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::VR_AddCommand)))
- .WillOnce(Return(true));
- }
- EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0);
- utils::SharedPtr<AddCommandRequest> request_ptr =
- CreateCommand<AddCommandRequest>(msg_);
- request_ptr->Run();
-}
-
-TEST_F(AddCommandRequestTest, GetRunMethods_SUCCESS) {
- CreateBasicParamsUIRequest();
- SmartObject& image = (*msg_)[msg_params][cmd_icon];
- EXPECT_CALL(mock_message_helper_, VerifyImage(image, _, _))
- .WillOnce(Return(mobile_apis::Result::SUCCESS));
- EXPECT_CALL(*mock_app_, FindCommand(kCmdId)).WillOnce(Return(so_ptr_.get()));
- EXPECT_CALL(*mock_app_, AddCommand(kCmdId, (*msg_)[msg_params]));
-
- am::CommandsMap commands_map;
- EXPECT_CALL(*mock_app_, commands_map())
- .WillRepeatedly(Return(
- DataAccessor<application_manager::CommandsMap>(commands_map, lock_)));
- EXPECT_CALL(
- app_mngr_,
- ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand)))
- .WillOnce(Return(true));
- utils::SharedPtr<AddCommandRequest> request_ptr =
- CreateCommand<AddCommandRequest>(msg_);
- request_ptr->Run();
-}
-
-TEST_F(AddCommandRequestTest, OnEvent_UI_SUCCESS) {
- CreateBasicParamsUIRequest();
- (*msg_)[params][hmi_response::code] = hmi_apis::Common_Result::SUCCESS;
- SmartObject& image = (*msg_)[msg_params][cmd_icon];
- EXPECT_CALL(mock_message_helper_, VerifyImage(image, _, _))
- .WillOnce(Return(mobile_apis::Result::SUCCESS));
- EXPECT_CALL(*mock_app_, AddCommand(kCmdId, (*msg_)[msg_params]));
-
- am::CommandsMap commands_map;
- EXPECT_CALL(*mock_app_, commands_map())
- .WillRepeatedly(
- Return(DataAccessor<am::CommandsMap>(commands_map, lock_)));
-
- Event event(hmi_apis::FunctionID::UI_AddCommand);
- event.set_smart_object(*msg_);
- EXPECT_CALL(
- app_mngr_,
- ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand)))
- .WillOnce(Return(true));
- utils::SharedPtr<AddCommandRequest> request_ptr =
- CreateCommand<AddCommandRequest>(msg_);
- request_ptr->Run();
- request_ptr->on_event(event);
-}
-
-TEST_F(AddCommandRequestTest, OnEvent_VR_SUCCESS) {
- CreateBasicParamsVRRequest();
- MessageSharedPtr msg = CreateMessage(SmartType_Map);
- (*msg)[params][hmi_response::code] = hmi_apis::Common_Result::SUCCESS;
- (*msg)[msg_params][cmd_id] = kCmdId;
-
- Event event(hmi_apis::FunctionID::VR_AddCommand);
- event.set_smart_object(*msg);
- EXPECT_CALL(*mock_app_, AddCommand(kCmdId, (*msg_)[msg_params]));
-
- am::CommandsMap commands_map;
- EXPECT_CALL(*mock_app_, commands_map())
- .WillRepeatedly(
- Return(DataAccessor<am::CommandsMap>(commands_map, lock_)));
- EXPECT_CALL(
- app_mngr_,
- ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::VR_AddCommand)))
- .WillOnce(Return(true));
- utils::SharedPtr<AddCommandRequest> request_ptr =
- CreateCommand<AddCommandRequest>(msg_);
- request_ptr->Run();
- request_ptr->on_event(event);
-}
-
-TEST_F(AddCommandRequestTest, OnTimeOut_EXPECT_VR_DeleteCommand) {
- CheckOnTimeOutCommandDeletion(hmi_apis::FunctionID::VR_AddCommand,
- hmi_apis::FunctionID::VR_DeleteCommand);
-}
-
-TEST_F(AddCommandRequestTest, OnTimeOut_EXPECT_UI_DeleteCommand) {
- CheckOnTimeOutCommandDeletion(hmi_apis::FunctionID::UI_AddCommand,
- hmi_apis::FunctionID::UI_DeleteCommand);
-}
-
-TEST_F(AddCommandRequestTest, OnEvent_BothSend_SUCCESS) {
- MessageSharedPtr command_msg = CreateMessage(SmartType_Map);
- (*command_msg)[params][connection_key] = kConnectionKey;
- MessageSharedPtr event_msg = CreateMessage(SmartType_Map);
- (*event_msg)[params][hmi_response::code] = hmi_apis::Common_Result::SUCCESS;
- (*event_msg)[msg_params][cmd_id] = kCmdId;
-
- Event event_ui(hmi_apis::FunctionID::UI_AddCommand);
- event_ui.set_smart_object(*event_msg);
-
- Event event_vr(hmi_apis::FunctionID::VR_AddCommand);
- event_vr.set_smart_object(*event_msg);
-
- EXPECT_CALL(*mock_app_, RemoveCommand(kCmdId)).Times(0);
-
- utils::SharedPtr<AddCommandRequest> request_ptr =
- CreateCommand<AddCommandRequest>(command_msg);
- request_ptr->Run();
- request_ptr->on_event(event_ui);
- request_ptr->on_event(event_vr);
-}
-
-TEST_F(AddCommandRequestTest, OnEvent_UnknownEvent_UNSUCCESS) {
- EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0);
- utils::SharedPtr<AddCommandRequest> request_ptr =
- CreateCommand<AddCommandRequest>(msg_);
- Event event(hmi_apis::FunctionID::INVALID_ENUM);
- request_ptr->on_event(event);
-}
-
-TEST_F(AddCommandRequestTest, OnEvent_AppNotExisted_UNSUCCESS) {
- CreateBasicParamsUIRequest();
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(ApplicationSharedPtr()));
- Event event(hmi_apis::FunctionID::UI_AddCommand);
- EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0);
- utils::SharedPtr<AddCommandRequest> request_ptr =
- CreateCommand<AddCommandRequest>(msg_);
- request_ptr->on_event(event);
-}
-
-TEST_F(AddCommandRequestTest,
- OnEvent_HmiResponseCodeIsRejected_ExpectUICommandRemoved) {
- CreateBasicParamsUIRequest();
- SmartObject& params = (*msg_)[strings::params];
- params[hmi_response::code] = hmi_apis::Common_Result::REJECTED;
- SmartObject& image = (*msg_)[msg_params][cmd_icon];
- EXPECT_CALL(mock_message_helper_, VerifyImage(image, _, _))
- .WillOnce(Return(mobile_apis::Result::SUCCESS));
- am::CommandsMap commands_map;
- EXPECT_CALL(*mock_app_, commands_map())
- .WillRepeatedly(Return(
- DataAccessor<application_manager::CommandsMap>(commands_map, lock_)));
- EXPECT_CALL(
- app_mngr_,
- ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand)))
- .WillOnce(Return(true));
- utils::SharedPtr<AddCommandRequest> request_ptr =
- CreateCommand<AddCommandRequest>(msg_);
- request_ptr->Run();
- EXPECT_CALL(*mock_app_, RemoveCommand(kCmdId));
- EXPECT_CALL(app_mngr_,
- ManageMobileCommand(
- MobileResultCodeIs(mobile_apis::Result::REJECTED), _));
- Event event(hmi_apis::FunctionID::UI_AddCommand);
- event.set_smart_object(*msg_);
- request_ptr->on_event(event);
-}
-
-TEST_F(AddCommandRequestTest,
- OnEvent_HmiResponseCodeIsWarnings_ExpectCommandUpdated) {
- CreateBasicParamsVRRequest();
- CreateBasicParamsUIRequest();
- SmartObject& params = (*msg_)[strings::params];
- params[hmi_response::code] = hmi_apis::Common_Result::WARNINGS;
- SmartObject& image = (*msg_)[msg_params][cmd_icon];
- EXPECT_CALL(mock_message_helper_, VerifyImage(image, _, _))
- .WillOnce(Return(mobile_apis::Result::SUCCESS));
- am::CommandsMap commands_map;
- EXPECT_CALL(*mock_app_, commands_map())
- .WillRepeatedly(Return(
- DataAccessor<application_manager::CommandsMap>(commands_map, lock_)));
- {
- InSequence dummy;
- EXPECT_CALL(
- app_mngr_,
- ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand)))
- .WillOnce(Return(true));
- EXPECT_CALL(
- app_mngr_,
- ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::VR_AddCommand)))
- .WillOnce(Return(true));
- }
- EXPECT_CALL(app_mngr_,
- ManageMobileCommand(
- MobileResultCodeIs(mobile_apis::Result::WARNINGS), _));
- utils::SharedPtr<AddCommandRequest> request_ptr =
- CreateCommand<AddCommandRequest>(msg_);
- request_ptr->Run();
- Event event_ui(hmi_apis::FunctionID::UI_AddCommand);
- event_ui.set_smart_object(*msg_);
- Event event_vr(hmi_apis::FunctionID::VR_AddCommand);
- event_vr.set_smart_object(*msg_);
- request_ptr->on_event(event_ui);
- request_ptr->on_event(event_vr);
-}
-
-TEST_F(
- AddCommandRequestTest,
- OnEvent_UI_HmiResponseCodeIsGenericError_VR_HmiResponseCodeIsUnsupportedResourse_ExpectCommandRemoved) {
- CreateBasicParamsVRRequest();
- CreateBasicParamsUIRequest();
- SmartObject& params = (*msg_)[strings::params];
- params[hmi_response::code] = hmi_apis::Common_Result::GENERIC_ERROR;
- SmartObject& image = (*msg_)[msg_params][cmd_icon];
- EXPECT_CALL(mock_message_helper_, VerifyImage(image, _, _))
- .WillOnce(Return(mobile_apis::Result::SUCCESS));
- am::CommandsMap commands_map;
- EXPECT_CALL(*mock_app_, commands_map())
- .WillRepeatedly(Return(
- DataAccessor<application_manager::CommandsMap>(commands_map, lock_)));
- {
- InSequence dummy;
- EXPECT_CALL(
- app_mngr_,
- ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand)))
- .WillOnce(Return(true));
- EXPECT_CALL(
- app_mngr_,
- ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::VR_AddCommand)))
- .WillOnce(Return(true));
- }
-
- EXPECT_CALL(*mock_app_, RemoveCommand(kCmdId));
- utils::SharedPtr<AddCommandRequest> request_ptr =
- CreateCommand<AddCommandRequest>(msg_);
- request_ptr->Run();
-
- Event event_ui(hmi_apis::FunctionID::UI_AddCommand);
- event_ui.set_smart_object(*msg_);
- request_ptr->on_event(event_ui);
-
- Event event_vr(hmi_apis::FunctionID::VR_AddCommand);
- MessageSharedPtr msg_vr = CreateMessage(SmartType_Map);
- (*msg_vr)[strings::params][hmi_response::code] =
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
- (*msg_vr)[msg_params][cmd_id] = kCmdId;
- event_vr.set_smart_object(*msg_vr);
- request_ptr->on_event(event_vr);
-}
-
-TEST_F(
- AddCommandRequestTest,
- OnEvent_VR_HmiResponseCodeIsGenericError_UI_HmiResponseCodeIsUnsupportedResourse_ExpectCommandRemoved) {
- CreateBasicParamsVRRequest();
- CreateBasicParamsUIRequest();
- SmartObject& params = (*msg_)[strings::params];
- params[hmi_response::code] = hmi_apis::Common_Result::GENERIC_ERROR;
- SmartObject& image = (*msg_)[msg_params][cmd_icon];
- EXPECT_CALL(mock_message_helper_, VerifyImage(image, _, _))
- .WillOnce(Return(mobile_apis::Result::SUCCESS));
- am::CommandsMap commands_map;
- EXPECT_CALL(*mock_app_, commands_map())
- .WillRepeatedly(Return(
- DataAccessor<application_manager::CommandsMap>(commands_map, lock_)));
- {
- InSequence dummy;
- EXPECT_CALL(
- app_mngr_,
- ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand)))
- .WillOnce(Return(true));
- EXPECT_CALL(
- app_mngr_,
- ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::VR_AddCommand)))
- .WillOnce(Return(true));
- }
-
- EXPECT_CALL(*mock_app_, RemoveCommand(kCmdId));
- utils::SharedPtr<AddCommandRequest> request_ptr =
- CreateCommand<AddCommandRequest>(msg_);
- request_ptr->Run();
-
- Event event_vr(hmi_apis::FunctionID::VR_AddCommand);
- event_vr.set_smart_object(*msg_);
- request_ptr->on_event(event_vr);
-
- Event event_ui(hmi_apis::FunctionID::UI_AddCommand);
- MessageSharedPtr msg_ui = CreateMessage(SmartType_Map);
- (*msg_ui)[strings::params][hmi_response::code] =
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
- (*msg_ui)[msg_params][cmd_id] = kCmdId;
- event_ui.set_smart_object(*msg_ui);
- request_ptr->on_event(event_ui);
-}
-
-TEST_F(
- AddCommandRequestTest,
- OnEvent_UI_VR_HmiResponseCodeIsUnsupportedResourse_UI_NotAvailableInterfaceState_ExpectCommandRemoved) {
- CreateBasicParamsVRRequest();
- CreateBasicParamsUIRequest();
- SmartObject& params = (*msg_)[strings::params];
- params[hmi_response::code] = hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
- SmartObject& image = (*msg_)[msg_params][cmd_icon];
- EXPECT_CALL(mock_message_helper_, VerifyImage(image, _, _))
- .WillOnce(Return(mobile_apis::Result::SUCCESS));
- am::CommandsMap commands_map;
- EXPECT_CALL(*mock_app_, commands_map())
- .WillRepeatedly(Return(
- DataAccessor<application_manager::CommandsMap>(commands_map, lock_)));
- {
- InSequence dummy;
- EXPECT_CALL(
- app_mngr_,
- ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand)))
- .WillOnce(Return(true));
- EXPECT_CALL(
- app_mngr_,
- ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::VR_AddCommand)))
- .WillOnce(Return(true));
- }
- utils::SharedPtr<AddCommandRequest> request_ptr =
- CreateCommand<AddCommandRequest>(msg_);
- request_ptr->Run();
-
- EXPECT_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
- .WillRepeatedly(
- Return(am::HmiInterfaces::InterfaceState::STATE_NOT_AVAILABLE));
- EXPECT_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR))
- .WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE));
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(
- MobileResultCodeIs(mobile_apis::Result::UNSUPPORTED_RESOURCE), _));
- EXPECT_CALL(*mock_app_, RemoveCommand(kCmdId));
- Event event_ui(hmi_apis::FunctionID::UI_AddCommand);
- event_ui.set_smart_object(*msg_);
- Event event_vr(hmi_apis::FunctionID::VR_AddCommand);
- event_vr.set_smart_object(*msg_);
- request_ptr->on_event(event_ui);
- request_ptr->on_event(event_vr);
-}
-
-TEST_F(
- AddCommandRequestTest,
- OnEvent_UI_VR_HmiResponseCodeIsUnsupportedResourse_VR_NotAvailableInterfaceState_ExpectCommandRemoved) {
- CreateBasicParamsVRRequest();
- CreateBasicParamsUIRequest();
- SmartObject& params = (*msg_)[strings::params];
- params[hmi_response::code] = hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
- SmartObject& image = (*msg_)[msg_params][cmd_icon];
- EXPECT_CALL(mock_message_helper_, VerifyImage(image, _, _))
- .WillOnce(Return(mobile_apis::Result::SUCCESS));
- am::CommandsMap commands_map;
- EXPECT_CALL(*mock_app_, commands_map())
- .WillRepeatedly(Return(
- DataAccessor<application_manager::CommandsMap>(commands_map, lock_)));
- {
- InSequence dummy;
- EXPECT_CALL(
- app_mngr_,
- ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand)))
- .WillOnce(Return(true));
- EXPECT_CALL(
- app_mngr_,
- ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::VR_AddCommand)))
- .WillOnce(Return(true));
- }
- utils::SharedPtr<AddCommandRequest> request_ptr =
- CreateCommand<AddCommandRequest>(msg_);
- request_ptr->Run();
-
- EXPECT_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
- .WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE));
- EXPECT_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR))
- .WillRepeatedly(
- Return(am::HmiInterfaces::InterfaceState::STATE_NOT_AVAILABLE));
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(
- MobileResultCodeIs(mobile_apis::Result::UNSUPPORTED_RESOURCE), _));
- EXPECT_CALL(*mock_app_, RemoveCommand(kCmdId));
- Event event_ui(hmi_apis::FunctionID::UI_AddCommand);
- event_ui.set_smart_object(*msg_);
- Event event_vr(hmi_apis::FunctionID::VR_AddCommand);
- event_vr.set_smart_object(*msg_);
- request_ptr->on_event(event_ui);
- request_ptr->on_event(event_vr);
-}
-
-TEST_F(
- AddCommandRequestTest,
- OnEvent_UI_HmiResponseCodeIsUnsupportedResource_NotAvailableInterfaceState_ExpectCommandRemoved) {
- CreateBasicParamsUIRequest();
- SmartObject& params = (*msg_)[strings::params];
- params[hmi_response::code] = hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
- SmartObject& image = (*msg_)[msg_params][cmd_icon];
- EXPECT_CALL(mock_message_helper_, VerifyImage(image, _, _))
- .WillOnce(Return(mobile_apis::Result::SUCCESS));
- am::CommandsMap commands_map;
- EXPECT_CALL(*mock_app_, commands_map())
- .WillRepeatedly(Return(
- DataAccessor<application_manager::CommandsMap>(commands_map, lock_)));
- EXPECT_CALL(
- app_mngr_,
- ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand)))
- .WillOnce(Return(true));
- utils::SharedPtr<AddCommandRequest> request_ptr =
- CreateCommand<AddCommandRequest>(msg_);
- request_ptr->Run();
- EXPECT_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
- .WillRepeatedly(
- Return(am::HmiInterfaces::InterfaceState::STATE_NOT_AVAILABLE));
- EXPECT_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR))
- .WillRepeatedly(
- Return(am::HmiInterfaces::InterfaceState::STATE_NOT_AVAILABLE));
- EXPECT_CALL(*mock_app_, RemoveCommand(kCmdId));
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(
- MobileResultCodeIs(mobile_apis::Result::UNSUPPORTED_RESOURCE), _));
- Event event(hmi_apis::FunctionID::UI_AddCommand);
- event.set_smart_object(*msg_);
- request_ptr->on_event(event);
-}
-
-TEST_F(
- AddCommandRequestTest,
- OnEvent_VR_HmiResponseCodeIsUnsupportedResource_NotAvailableInterfaceState_ExpectCommandRemoved) {
- CreateBasicParamsVRRequest();
- SmartObject& params = (*msg_)[strings::params];
- params[hmi_response::code] = hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
- am::CommandsMap commands_map;
- EXPECT_CALL(*mock_app_, commands_map())
- .WillRepeatedly(Return(
- DataAccessor<application_manager::CommandsMap>(commands_map, lock_)));
- EXPECT_CALL(
- app_mngr_,
- ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::VR_AddCommand)))
- .WillOnce(Return(true));
- utils::SharedPtr<AddCommandRequest> request_ptr =
- CreateCommand<AddCommandRequest>(msg_);
- request_ptr->Run();
- EXPECT_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
- .WillRepeatedly(
- Return(am::HmiInterfaces::InterfaceState::STATE_NOT_AVAILABLE));
- EXPECT_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR))
- .WillRepeatedly(
- Return(am::HmiInterfaces::InterfaceState::STATE_NOT_AVAILABLE));
- EXPECT_CALL(*mock_app_, RemoveCommand(kCmdId));
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(
- MobileResultCodeIs(mobile_apis::Result::UNSUPPORTED_RESOURCE), _));
- Event event(hmi_apis::FunctionID::VR_AddCommand);
- event.set_smart_object(*msg_);
- request_ptr->on_event(event);
-}
-
-TEST_F(AddCommandRequestTest,
- OnEvent_UI_EventWithNotSuccesResponseCode_ExpectVRCommandDelete) {
- CreateBasicParamsVRRequest();
- CreateBasicParamsUIRequest();
- SmartObject& params = (*msg_)[strings::params];
- params[hmi_response::code] = hmi_apis::Common_Result::SUCCESS;
- SmartObject& image = (*msg_)[msg_params][cmd_icon];
- EXPECT_CALL(mock_message_helper_, VerifyImage(image, _, _))
- .WillOnce(Return(mobile_apis::Result::SUCCESS));
- am::CommandsMap commands_map;
- EXPECT_CALL(*mock_app_, commands_map())
- .WillRepeatedly(Return(
- DataAccessor<application_manager::CommandsMap>(commands_map, lock_)));
- {
- InSequence dummy;
- EXPECT_CALL(
- app_mngr_,
- ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand)))
- .WillOnce(Return(true));
- EXPECT_CALL(
- app_mngr_,
- ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::VR_AddCommand)))
- .WillOnce(Return(true));
- }
- EXPECT_CALL(app_mngr_,
- ManageMobileCommand(
- MobileResultCodeIs(mobile_apis::Result::GENERIC_ERROR), _));
- utils::SharedPtr<AddCommandRequest> request_ptr =
- CreateCommand<AddCommandRequest>(msg_);
- request_ptr->Run();
-
- MessageSharedPtr msg_ui = CreateMessage(SmartType_Map);
- (*msg_ui)[strings::params][hmi_response::code] =
- hmi_apis::Common_Result::ABORTED;
- (*msg_ui)[msg_params][cmd_id] = kCmdId;
- Event event_ui(hmi_apis::FunctionID::UI_AddCommand);
- event_ui.set_smart_object(*msg_ui);
- Event event_vr(hmi_apis::FunctionID::VR_AddCommand);
- event_vr.set_smart_object(*msg_);
- EXPECT_CALL(
- app_mngr_,
- ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::VR_DeleteCommand)))
- .WillOnce(Return(true));
- EXPECT_CALL(*mock_app_, RemoveCommand(kCmdId)).Times(2);
- request_ptr->on_event(event_ui);
- request_ptr->on_event(event_vr);
-}
-
-TEST_F(AddCommandRequestTest,
- OnEvent_UI_VR_Events_VRErrorPresent_ExpectRemoveCommand) {
- CreateBasicParamsVRRequest();
- CreateBasicParamsUIRequest();
- SmartObject& params = (*msg_)[strings::params];
- params[hmi_response::code] = hmi_apis::Common_Result::SUCCESS;
- SmartObject& image = (*msg_)[msg_params][cmd_icon];
- EXPECT_CALL(mock_message_helper_, VerifyImage(image, _, _))
- .WillOnce(Return(mobile_apis::Result::SUCCESS));
- am::CommandsMap commands_map;
- EXPECT_CALL(*mock_app_, commands_map())
- .WillRepeatedly(Return(
- DataAccessor<application_manager::CommandsMap>(commands_map, lock_)));
- {
- InSequence dummy;
- EXPECT_CALL(
- app_mngr_,
- ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand)))
- .WillOnce(Return(true));
- EXPECT_CALL(
- app_mngr_,
- ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::VR_AddCommand)))
- .WillOnce(Return(true));
- }
- EXPECT_CALL(app_mngr_,
- ManageMobileCommand(
- MobileResultCodeIs(mobile_apis::Result::GENERIC_ERROR), _));
- utils::SharedPtr<AddCommandRequest> request_ptr =
- CreateCommand<AddCommandRequest>(msg_);
- request_ptr->Run();
-
- Event event_ui(hmi_apis::FunctionID::UI_AddCommand);
- event_ui.set_smart_object(*msg_);
- request_ptr->on_event(event_ui);
- EXPECT_CALL(
- app_mngr_,
- ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_DeleteCommand)))
- .WillOnce(Return(true));
- EXPECT_CALL(*mock_app_, RemoveCommand(kCmdId)).Times(2);
- Event event_vr(hmi_apis::FunctionID::VR_AddCommand);
- MessageSharedPtr msg_vr = CreateMessage(SmartType_Map);
- (*msg_vr)[strings::params][hmi_response::code] =
- hmi_apis::Common_Result::ABORTED;
- (*msg_vr)[msg_params][cmd_id] = kCmdId;
- event_vr.set_smart_object(*msg_vr);
- request_ptr->on_event(event_vr);
-}
-
-TEST_F(AddCommandRequestTest,
- OnTimeOut_AppNotExisted_NoAppRemoveCommandCalled) {
- CreateBasicParamsUIRequest();
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(ApplicationSharedPtr()));
- EXPECT_CALL(*mock_app_, RemoveCommand(kCmdId)).Times(0);
- SmartObjectSPtr response = utils::MakeShared<SmartObject>(SmartType_Map);
- (*response)[strings::msg_params][strings::info] = "info";
- EXPECT_CALL(
- mock_message_helper_,
- CreateNegativeResponse(_, _, _, mobile_apis::Result::GENERIC_ERROR))
- .WillOnce(Return(response));
- EXPECT_CALL(app_mngr_,
- ManageMobileCommand(
- response, am::commands::Command::CommandOrigin::ORIGIN_SDL));
- utils::SharedPtr<CommandRequestImpl> base_class_request =
- static_cast<utils::SharedPtr<CommandRequestImpl> >(
- CreateCommand<AddCommandRequest>(msg_));
- base_class_request->onTimeOut();
-}
-
-TEST_F(AddCommandRequestTest, OnTimeOut_AppRemoveCommandCalled) {
- CreateBasicParamsVRRequest();
- CreateBasicParamsUIRequest();
- SmartObject& msg_params = (*msg_)[strings::msg_params];
- SmartObject& image = msg_params[cmd_icon];
- msg_params[menu_params][hmi_request::parent_id] = kSecondParentId;
- EXPECT_CALL(mock_message_helper_, VerifyImage(image, _, _))
- .WillOnce(Return(mobile_apis::Result::SUCCESS));
- EXPECT_CALL(*mock_app_, FindCommand(kCmdId)).WillOnce(Return(so_ptr_.get()));
- SmartObject first_command = SmartObject(SmartType_Map);
- SmartObject second_command = SmartObject(SmartType_Map);
- const am::CommandsMap commands_map =
- CreateCommandsMap(first_command, second_command);
- EXPECT_CALL(*mock_app_, commands_map())
- .WillRepeatedly(Return(
- DataAccessor<application_manager::CommandsMap>(commands_map, lock_)));
- so_ptr_ = utils::MakeShared<SmartObject>(SmartType_Map);
- EXPECT_CALL(*mock_app_, FindSubMenu(kSecondParentId))
- .WillOnce(Return(so_ptr_.get()));
- {
- InSequence dummy;
- EXPECT_CALL(
- app_mngr_,
- ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand)))
- .WillOnce(Return(true));
- EXPECT_CALL(
- app_mngr_,
- ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::VR_AddCommand)))
- .WillOnce(Return(true));
- }
- EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0);
- utils::SharedPtr<AddCommandRequest> request_ptr =
- CreateCommand<AddCommandRequest>(msg_);
- request_ptr->Run();
- EXPECT_CALL(*mock_app_, RemoveCommand(kCmdId));
- SmartObjectSPtr response = utils::MakeShared<SmartObject>(SmartType_Map);
- (*response)[strings::msg_params][strings::info] = "info";
- EXPECT_CALL(
- mock_message_helper_,
- CreateNegativeResponse(_, _, _, mobile_apis::Result::GENERIC_ERROR))
- .WillOnce(Return(response));
- EXPECT_CALL(app_mngr_,
- ManageMobileCommand(
- response, am::commands::Command::CommandOrigin::ORIGIN_SDL));
- utils::SharedPtr<CommandRequestImpl> base_class_request =
- static_cast<utils::SharedPtr<CommandRequestImpl> >(request_ptr);
- base_class_request->onTimeOut();
-}
-
-} // namespace add_command_test
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace tests
diff --git a/src/components/application_manager/test/commands/mobile/add_sub_menu_request_test.cc b/src/components/application_manager/test/commands/mobile/add_sub_menu_request_test.cc
deleted file mode 100644
index f5bb7888d8..0000000000
--- a/src/components/application_manager/test/commands/mobile/add_sub_menu_request_test.cc
+++ /dev/null
@@ -1,121 +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 "application_manager/commands/mobile/add_sub_menu_request.h"
-
-#include "gtest/gtest.h"
-#include "application_manager/commands/commands_test.h"
-#include "application_manager/commands/command_request_test.h"
-#include "application_manager/mock_application_manager.h"
-#include "application_manager/mock_application.h"
-#include "application_manager/mock_message_helper.h"
-#include "application_manager/event_engine/event.h"
-#include "application_manager/mock_hmi_interface.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace add_sub_menu_request {
-
-namespace am = ::application_manager;
-using am::commands::AddSubMenuRequest;
-using am::commands::MessageSharedPtr;
-using am::event_engine::Event;
-using ::testing::_;
-using ::testing::Return;
-
-typedef SharedPtr<AddSubMenuRequest> AddSubMenuPtr;
-
-namespace {
-const uint32_t kConnectionKey = 2u;
-} // namespace
-
-class AddSubMenuRequestTest
- : public CommandRequestTest<CommandsTestMocks::kIsNice> {};
-
-TEST_F(AddSubMenuRequestTest, OnEvent_UI_UNSUPPORTED_RESOURCE) {
- const uint32_t menu_id = 10u;
- MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
- (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey;
- (*msg)[am::strings::msg_params][am::strings::menu_id] = menu_id;
-
- utils::SharedPtr<AddSubMenuRequest> command =
- CreateCommand<AddSubMenuRequest>(msg);
-
- MockAppPtr mock_app = CreateMockApp();
- ON_CALL(app_mngr_, application(kConnectionKey))
- .WillByDefault(Return(mock_app));
- ON_CALL(*mock_app, app_id()).WillByDefault(Return(kConnectionKey));
- EXPECT_CALL(*mock_app, AddSubMenu(menu_id, _));
- EXPECT_CALL(*mock_app, UpdateHash());
-
- MessageSharedPtr ev_msg = CreateMessage(smart_objects::SmartType_Map);
- (*ev_msg)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
- (*ev_msg)[am::strings::msg_params][am::strings::info] = "info";
-
- Event event(hmi_apis::FunctionID::UI_AddSubMenu);
- event.set_smart_object(*ev_msg);
-
- MessageSharedPtr ui_command_result;
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
- .WillOnce(DoAll(SaveArg<0>(&ui_command_result), Return(true)));
- command->Init();
- command->on_event(event);
-
- EXPECT_EQ((*ui_command_result)[am::strings::msg_params][am::strings::success]
- .asBool(),
- true);
- EXPECT_EQ(
- (*ui_command_result)[am::strings::msg_params][am::strings::result_code]
- .asInt(),
- static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE));
- if ((*ui_command_result)[am::strings::msg_params].keyExists(
- am::strings::info)) {
- EXPECT_FALSE(
- (*ui_command_result)[am::strings::msg_params][am::strings::info]
- .asString()
- .empty());
- }
-}
-
-} // namespace add_sub_menu_request
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/alert_maneuver_request_test.cc b/src/components/application_manager/test/commands/mobile/alert_maneuver_request_test.cc
deleted file mode 100644
index 90c6409fa8..0000000000
--- a/src/components/application_manager/test/commands/mobile/alert_maneuver_request_test.cc
+++ /dev/null
@@ -1,265 +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/commands_test.h"
-#include "application_manager/commands/command_request_test.h"
-#include "application_manager/application.h"
-#include "application_manager/mock_application_manager.h"
-#include "application_manager/mock_application.h"
-#include "application_manager/mock_message_helper.h"
-#include "event_engine/event.h"
-#include "application_manager/commands/mobile/alert_maneuver_request.h"
-#include "interfaces/MOBILE_API.h"
-#include "application_manager/policies/policy_handler_interface.h"
-#include "application_manager/policies/mock_policy_handler_interface.h"
-#include "application_manager/mock_hmi_interface.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace alert_maneuver_request {
-
-using ::testing::_;
-using ::testing::Return;
-using ::testing::ReturnRef;
-namespace am = ::application_manager;
-using am::commands::AlertManeuverRequest;
-using am::commands::MessageSharedPtr;
-using am::event_engine::Event;
-
-typedef SharedPtr<AlertManeuverRequest> CommandPtr;
-
-class AlertManeuverRequestTest
- : public CommandRequestTest<CommandsTestMocks::kIsNice> {
- public:
- void CheckExpectations(const hmi_apis::Common_Result::eType hmi_response,
- const mobile_apis::Result::eType mobile_response,
- const am::HmiInterfaces::InterfaceState state,
- const bool success) {
- MessageSharedPtr response = CreateMessage(smart_objects::SmartType_Map);
- (*response)[am::strings::params][am::hmi_response::code] = hmi_response;
- (*response)[am::strings::msg_params][am::strings::info] = "test";
-
- am::event_engine::Event event(hmi_apis::FunctionID::TTS_Speak);
- event.set_smart_object(*response);
-
- utils::SharedPtr<AlertManeuverRequest> command =
- CreateCommand<AlertManeuverRequest>(response);
-
- MockAppPtr mock_app(CreateMockApp());
- ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app));
-
- EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
- .WillRepeatedly(Return(state));
-
- MessageSharedPtr response_to_mobile;
- EXPECT_CALL(app_mngr_,
- ManageMobileCommand(
- _, am::commands::Command::CommandOrigin::ORIGIN_SDL))
- .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true)));
- command->on_event(event);
-
- EXPECT_EQ(
- (*response_to_mobile)[am::strings::msg_params][am::strings::success]
- .asBool(),
- success);
- EXPECT_EQ(
- (*response_to_mobile)[am::strings::msg_params][am::strings::result_code]
- .asInt(),
- static_cast<int32_t>(mobile_response));
- }
-
- protected:
- NiceMock<policy_test::MockPolicyHandlerInterface> policy_interface_;
-};
-
-TEST_F(AlertManeuverRequestTest, Run_RequiredFieldsDoesNotExist_UNSUCCESS) {
- CommandPtr command(CreateCommand<AlertManeuverRequest>());
- EXPECT_CALL(app_mngr_, application(_)).Times(0);
- MessageSharedPtr result_msg(CatchMobileCommandResult(CallRun(*command)));
- EXPECT_EQ(mobile_apis::Result::INVALID_DATA,
- static_cast<mobile_apis::Result::eType>(
- (*result_msg)[am::strings::msg_params][am::strings::result_code]
- .asInt()));
-}
-
-TEST_F(AlertManeuverRequestTest, Run_ApplicationIsNotRegistered_UNSUCCESS) {
- MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
- (*msg)[am::strings::msg_params][am::strings::soft_buttons] = 0;
- (*msg)[am::strings::msg_params][am::strings::tts_chunks] = 0;
-
- CommandPtr command(CreateCommand<AlertManeuverRequest>(msg));
-
- ON_CALL(app_mngr_, application(_))
- .WillByDefault(Return(ApplicationSharedPtr()));
-
- MessageSharedPtr result_msg(CatchMobileCommandResult(CallRun(*command)));
- EXPECT_EQ(mobile_apis::Result::APPLICATION_NOT_REGISTERED,
- static_cast<mobile_apis::Result::eType>(
- (*result_msg)[am::strings::msg_params][am::strings::result_code]
- .asInt()));
-}
-
-TEST_F(AlertManeuverRequestTest, Run_ProcessingResult_UNSUCCESS) {
- MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
- (*msg)[am::strings::msg_params][am::strings::soft_buttons][0]
- [am::strings::text] = "text";
-
- CommandPtr command(CreateCommand<AlertManeuverRequest>(msg));
-
- MockAppPtr app(CreateMockApp());
- ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app));
-
- ON_CALL(app_mngr_, GetPolicyHandler())
- .WillByDefault(ReturnRef(policy_interface_));
-
- const mobile_apis::Result::eType kProcessingResult =
- mobile_apis::Result::ABORTED;
-
- EXPECT_CALL(mock_message_helper_, ProcessSoftButtons(_, _, _, _))
- .WillOnce(Return(kProcessingResult));
-
- MessageSharedPtr result_msg(CatchMobileCommandResult(CallRun(*command)));
- EXPECT_EQ(kProcessingResult,
- static_cast<mobile_apis::Result::eType>(
- (*result_msg)[am::strings::msg_params][am::strings::result_code]
- .asInt()));
-}
-
-TEST_F(AlertManeuverRequestTest, Run_IsWhiteSpaceExist_UNSUCCESS) {
- MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
- (*msg)[am::strings::msg_params][am::strings::soft_buttons] = 0;
- (*msg)[am::strings::msg_params][am::strings::tts_chunks] =
- SmartObject(smart_objects::SmartType_Array);
-
- SmartObject tts_chunk(smart_objects::SmartType_Map);
- tts_chunk[am::strings::text] = "wrong chunk syntax\t\n";
-
- (*msg)[am::strings::msg_params][am::strings::tts_chunks].asArray()->push_back(
- tts_chunk);
-
- CommandPtr command(CreateCommand<AlertManeuverRequest>(msg));
-
- MockAppPtr app(CreateMockApp());
- ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app));
-
- MessageSharedPtr result_msg(CatchMobileCommandResult(CallRun(*command)));
- EXPECT_EQ(mobile_apis::Result::INVALID_DATA,
- static_cast<mobile_apis::Result::eType>(
- (*result_msg)[am::strings::msg_params][am::strings::result_code]
- .asInt()));
-}
-
-TEST_F(AlertManeuverRequestTest, Run_ProcessingResult_SUCCESS) {
- MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
- (*msg)[am::strings::msg_params][am::strings::soft_buttons][0]
- [am::strings::text] = "text";
-
- CommandPtr command(CreateCommand<AlertManeuverRequest>(msg));
-
- MockAppPtr app(CreateMockApp());
- ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app));
-
- ON_CALL(app_mngr_, GetPolicyHandler())
- .WillByDefault(ReturnRef(policy_interface_));
-
- EXPECT_CALL(mock_message_helper_, ProcessSoftButtons(_, _, _, _))
- .WillOnce(Return(mobile_apis::Result::SUCCESS));
-
- EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceFromFunction(_))
- .WillRepeatedly(
- Return(am::HmiInterfaces::InterfaceID::HMI_INTERFACE_TTS));
- EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
- .WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE));
-
- EXPECT_CALL(mock_message_helper_, SubscribeApplicationToSoftButton(_, _, _));
-
- MessageSharedPtr result_msg(CatchHMICommandResult(CallRun(*command)));
- EXPECT_EQ(hmi_apis::FunctionID::Navigation_AlertManeuver,
- static_cast<hmi_apis::FunctionID::eType>(
- (*result_msg)[am::strings::params][am::strings::function_id]
- .asInt()));
-}
-
-TEST_F(AlertManeuverRequestTest, OnEvent_ReceivedUnknownEvent_UNSUCCESS) {
- CommandPtr command(CreateCommand<AlertManeuverRequest>());
- Event event(hmi_apis::FunctionID::INVALID_ENUM);
-
- MessageSharedPtr result_msg(
- CatchMobileCommandResult(CallOnEvent(*command, event)));
- EXPECT_EQ(mobile_apis::Result::INVALID_ENUM,
- static_cast<mobile_apis::Result::eType>(
- (*result_msg)[am::strings::msg_params][am::strings::result_code]
- .asInt()));
-}
-
-TEST_F(AlertManeuverRequestTest, OnEvent_SUCCESS) {
- CheckExpectations(hmi_apis::Common_Result::SUCCESS,
- mobile_apis::Result::SUCCESS,
- am::HmiInterfaces::STATE_AVAILABLE,
- true);
-}
-
-TEST_F(AlertManeuverRequestTest, OnEvent_UNSUPPORTED_RESOURCE) {
- CheckExpectations(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE,
- mobile_apis::Result::UNSUPPORTED_RESOURCE,
- am::HmiInterfaces::STATE_AVAILABLE,
- false);
-}
-
-TEST_F(AlertManeuverRequestTest, OnEvent_WARNINGS) {
- CheckExpectations(hmi_apis::Common_Result::WARNINGS,
- mobile_apis::Result::WARNINGS,
- am::HmiInterfaces::STATE_NOT_RESPONSE,
- true);
-}
-
-TEST_F(AlertManeuverRequestTest, OnEvent_GENERIC_ERROR) {
- CheckExpectations(hmi_apis::Common_Result::GENERIC_ERROR,
- mobile_apis::Result::GENERIC_ERROR,
- am::HmiInterfaces::STATE_NOT_RESPONSE,
- false);
-}
-
-} // namespace alert_maneuver_request
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/alert_request_test.cc b/src/components/application_manager/test/commands/mobile/alert_request_test.cc
deleted file mode 100644
index 5d9e507511..0000000000
--- a/src/components/application_manager/test/commands/mobile/alert_request_test.cc
+++ /dev/null
@@ -1,771 +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 <set>
-
-#include "application_manager/commands/mobile/alert_request.h"
-
-#include "gtest/gtest.h"
-#include "application_manager/commands/command_request_test.h"
-#include "application_manager/mock_application.h"
-#include "application_manager/mock_application_manager.h"
-#include "application_manager/mock_message_helper.h"
-#include "application_manager/event_engine/event.h"
-#include "application_manager/mock_hmi_interface.h"
-#include "application_manager/policies/mock_policy_handler_interface.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace alert_request {
-
-namespace am = application_manager;
-using am::commands::AlertRequest;
-using am::commands::CommandImpl;
-using am::commands::MessageSharedPtr;
-using am::MockMessageHelper;
-using ::utils::SharedPtr;
-using am::event_engine::Event;
-using policy_test::MockPolicyHandlerInterface;
-using ::testing::_;
-using ::testing::Return;
-using ::testing::ReturnRef;
-
-typedef SharedPtr<AlertRequest> CommandPtr;
-
-namespace {
-const int32_t kCommandId = 1;
-const uint32_t kAppId = 1u;
-const uint32_t kCmdId = 1u;
-const uint32_t kConnectionKey = 2u;
-const uint32_t kDefaultTimeout = 1000u;
-const uint32_t kCorrelationId = 2u;
-const mobile_apis::FunctionID::eType kFunctionId =
- mobile_apis::FunctionID::AlertID;
-} // namespace
-
-class AlertRequestTest : public CommandRequestTest<CommandsTestMocks::kIsNice> {
- public:
- AlertRequestTest() : mock_app_(CreateMockApp()), msg_(CreateMessage()) {}
-
- protected:
- MessageSharedPtr CreateFullParamsUISO() {
- MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
- (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey;
- smart_objects::SmartObject menu_params =
- smart_objects::SmartObject(smart_objects::SmartType_Map);
- menu_params[am::strings::position] = 10;
- menu_params[am::strings::menu_name] = "LG";
-
- smart_objects::SmartObject msg_params =
- smart_objects::SmartObject(smart_objects::SmartType_Map);
- msg_params[am::strings::cmd_id] = kCmdId;
- msg_params[am::strings::menu_params] = menu_params;
- msg_params[am::strings::app_id] = kAppId;
- msg_params[am::strings::cmd_icon] = 1;
- msg_params[am::strings::cmd_icon][am::strings::value] = "10";
- (*msg)[am::strings::msg_params] = msg_params;
-
- return msg;
- }
-
- void ResultCommandExpectations(MessageSharedPtr msg,
- const std::string& info) {
- EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::success].asBool(),
- true);
- EXPECT_EQ(
- (*msg)[am::strings::msg_params][am::strings::result_code].asInt(),
- static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE));
- EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::info].asString(),
- info);
- }
-
- void PreConditions() {
- ON_CALL(app_mngr_, application(kConnectionKey))
- .WillByDefault(Return(mock_app_));
- ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey));
-
- ON_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
- .WillByDefault(
- Return(am::HmiInterfaces::InterfaceState::STATE_AVAILABLE));
-
- ON_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS))
- .WillByDefault(
- Return(am::HmiInterfaces::InterfaceState::STATE_AVAILABLE));
- }
-
- void Expectations() {
- (*msg_)[am::strings::params][am::strings::function_id] = kFunctionId;
- (*msg_)[am::strings::params][am::strings::connection_key] = kConnectionKey;
- (*msg_)[am::strings::params][am::strings::correlation_id] = kCorrelationId;
-
- ON_CALL(app_mngr_, application(kConnectionKey))
- .WillByDefault(Return(mock_app_));
- ON_CALL(
- *mock_app_,
- AreCommandLimitsExceeded(kFunctionId, am::TLimitSource::POLICY_TABLE))
- .WillByDefault(Return(false));
- ON_CALL(app_mngr_, GetPolicyHandler())
- .WillByDefault(ReturnRef(mock_policy_handler_));
- ON_CALL(*mock_app_, hmi_level())
- .WillByDefault(Return(mobile_apis::HMILevel::HMI_FULL));
- ON_CALL(*mock_app_, hmi_level())
- .WillByDefault(Return(mobile_apis::HMILevel::HMI_BACKGROUND));
- }
-
- void AddAlertTextsToMsg() {
- (*msg_)[am::strings::msg_params][am::strings::alert_text1] = "alert_text1";
- (*msg_)[am::strings::msg_params][am::strings::alert_text2] = "alert_text2";
- (*msg_)[am::strings::msg_params][am::strings::alert_text3] = "alert_text3";
- }
- void AddTTSChunkToMsg() {
- (*msg_)[am::strings::msg_params][am::strings::tts_chunks][0]
- [am::strings::text] = "tts_chunk_text";
- }
-
- void ExpectCallHmiLevel(const mobile_apis::HMILevel::eType level) {
- EXPECT_CALL(*mock_app_, hmi_level()).WillRepeatedly(Return(level));
- }
-
- void ExpectManageMobileCommandWithResultCode(
- const mobile_apis::Result::eType code) {
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(MobileResultCodeIs(code),
- am::commands::Command::CommandOrigin::ORIGIN_SDL));
- }
-
- void ExpectManageHmiCommandTTSAndUI() {
- EXPECT_CALL(
- app_mngr_,
- ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_Alert)))
- .WillOnce(Return(true));
- EXPECT_CALL(
- app_mngr_,
- ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak)))
- .WillOnce(Return(true));
- }
- sync_primitives::Lock lock_;
-
- MockAppPtr mock_app_;
- MessageSharedPtr msg_;
- MockPolicyHandlerInterface mock_policy_handler_;
-};
-
-TEST_F(AlertRequestTest, OnTimeout_GENERIC_ERROR) {
- PreConditions();
- MessageSharedPtr command_msg = CreateMessage(smart_objects::SmartType_Map);
- (*command_msg)[am::strings::msg_params][am::strings::result_code] =
- am::mobile_api::Result::GENERIC_ERROR;
- (*command_msg)[am::strings::msg_params][am::strings::success] = false;
- (*command_msg)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
-
- utils::SharedPtr<AlertRequest> command = CreateCommand<AlertRequest>();
-
- EXPECT_CALL(
- mock_message_helper_,
- CreateNegativeResponse(_, _, _, am::mobile_api::Result::GENERIC_ERROR))
- .WillOnce(Return(command_msg));
-
- MessageSharedPtr ui_command_result;
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
- .WillOnce(DoAll(SaveArg<0>(&ui_command_result), Return(true)));
-
- command->onTimeOut();
- EXPECT_EQ((*ui_command_result)[am::strings::msg_params][am::strings::success]
- .asBool(),
- false);
- EXPECT_EQ(
- (*ui_command_result)[am::strings::msg_params][am::strings::result_code]
- .asInt(),
- static_cast<int32_t>(am::mobile_api::Result::GENERIC_ERROR));
-}
-
-TEST_F(AlertRequestTest, OnEvent_UI_HmiSendSuccess_UNSUPPORTED_RESOURCE) {
- PreConditions();
- MessageSharedPtr command_msg = CreateFullParamsUISO();
- (*command_msg)[am::strings::msg_params][am::strings::menu_params]
- [am::hmi_request::parent_id] = 10u;
- (*command_msg)[am::strings::msg_params][am::strings::menu_params]
- [am::strings::menu_name] = "menu_name";
-
- utils::SharedPtr<AlertRequest> command =
- CreateCommand<AlertRequest>(command_msg);
-
- MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
- (*msg)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
- (*msg)[am::strings::msg_params][am::strings::cmd_id] = kCommandId;
- (*msg)[am::strings::msg_params][am::strings::info] =
- "UI is not supported by system";
-
- MessageSharedPtr msg_tts = CreateMessage();
- (*msg_tts)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::SUCCESS;
- Event event_vr(hmi_apis::FunctionID::TTS_Speak);
- event_vr.set_smart_object(*msg_tts);
-
- command->on_event(event_vr);
-
- Event event(hmi_apis::FunctionID::UI_Alert);
- event.set_smart_object(*msg);
-
- MessageSharedPtr ui_command_result;
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
- .WillOnce(DoAll(SaveArg<0>(&ui_command_result), Return(true)));
-
- command->on_event(event);
-
- ResultCommandExpectations(ui_command_result, "UI is not supported by system");
-}
-
-class CallOnTimeOut {
- public:
- CallOnTimeOut(CommandRequestImpl& command) : command_(command) {}
-
- void operator()() {
- command_.onTimeOut();
- }
-
- CommandRequestImpl& command_;
-};
-
-TEST_F(AlertRequestTest, Init_DurationExists_SUCCESS) {
- Expectations();
- (*msg_)[am::strings::msg_params][am::strings::duration] = kDefaultTimeout;
- (*msg_)[am::strings::msg_params][am::strings::soft_buttons] = "soft_buttons";
-
- CommandPtr command(CreateCommand<AlertRequest>(msg_));
- EXPECT_TRUE(command->Init());
-}
-
-TEST_F(AlertRequestTest, Init_DurationNotExists_SUCCESS) {
- Expectations();
- CommandPtr command(CreateCommand<AlertRequest>(msg_));
- EXPECT_TRUE(command->Init());
-}
-
-TEST_F(AlertRequestTest, OnTimeOut_SUCCESS) {
- Expectations();
- MessageSharedPtr result_msg(CreateMessage(smart_objects::SmartType_Null));
- EXPECT_CALL(
- mock_message_helper_,
- CreateNegativeResponse(_, _, _, mobile_apis::Result::GENERIC_ERROR))
- .WillOnce(Return(result_msg));
-
- CommandPtr command(CreateCommand<AlertRequest>());
- MessageSharedPtr received_result_msg(
- CatchMobileCommandResult(CallOnTimeOut(*command)));
- EXPECT_EQ(result_msg, received_result_msg);
-}
-
-TEST_F(AlertRequestTest, Run_ApplicationIsNotRegistered_UNSUCCESS) {
- Expectations();
- MockAppPtr invalid_app;
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(invalid_app));
-
- CommandPtr command(CreateCommand<AlertRequest>(msg_));
- ExpectManageMobileCommandWithResultCode(
- mobile_apis::Result::APPLICATION_NOT_REGISTERED);
- command->Run();
-}
-
-TEST_F(AlertRequestTest, Run_AlertFrequencyIsTooHigh_UNSUCCESS) {
- Expectations();
- EXPECT_CALL(
- *mock_app_,
- AreCommandLimitsExceeded(kFunctionId, am::TLimitSource::POLICY_TABLE))
- .WillOnce(Return(true));
-
- CommandPtr command(CreateCommand<AlertRequest>(msg_));
- MessageSharedPtr result_msg(CatchMobileCommandResult(CallRun(*command)));
- EXPECT_EQ(mobile_apis::Result::REJECTED,
- static_cast<mobile_apis::Result::eType>(
- (*result_msg)[am::strings::msg_params][am::strings::result_code]
- .asInt()));
-}
-
-TEST_F(AlertRequestTest, Run_FailToProcessSoftButtons_UNSUCCESS) {
- Expectations();
- const mobile_apis::Result::eType result_code =
- mobile_apis::Result::INVALID_ENUM;
-
- EXPECT_CALL(mock_message_helper_,
- ProcessSoftButtons((*msg_)[am::strings::msg_params], _, _, _))
- .WillOnce(Return(result_code));
-
- CommandPtr command(CreateCommand<AlertRequest>(msg_));
- MessageSharedPtr result_msg(CatchMobileCommandResult(CallRun(*command)));
- EXPECT_EQ(result_code,
- static_cast<mobile_apis::Result::eType>(
- (*result_msg)[am::strings::msg_params][am::strings::result_code]
- .asInt()));
-}
-
-TEST_F(AlertRequestTest, Run_MandatoryParametersAreMissed_UNSUCCESS) {
- Expectations();
- EXPECT_CALL(mock_message_helper_,
- ProcessSoftButtons((*msg_)[am::strings::msg_params], _, _, _))
- .WillOnce(Return(mobile_apis::Result::SUCCESS));
-
- ExpectManageMobileCommandWithResultCode(mobile_apis::Result::INVALID_DATA);
- CommandPtr command(CreateCommand<AlertRequest>(msg_));
- command->Run();
-}
-
-TEST_F(AlertRequestTest, Run_MandatoryParametersAreInvalid_UNSUCCESS) {
- Expectations();
- AddAlertTextsToMsg();
- (*msg_)[am::strings::msg_params][am::strings::alert_text2] =
- "invalid\t\nParam";
-
- ExpectManageMobileCommandWithResultCode(mobile_apis::Result::INVALID_DATA);
- CommandPtr command(CreateCommand<AlertRequest>(msg_));
- command->Run();
-}
-
-TEST_F(AlertRequestTest, Run_SUCCESS) {
- Expectations();
- AddAlertTextsToMsg();
- AddTTSChunkToMsg();
-
- (*msg_)[am::strings::msg_params][am::strings::soft_buttons] = "soft_buttons";
- (*msg_)[am::strings::msg_params][am::strings::progress_indicator] =
- "progress_indicator";
- (*msg_)[am::strings::msg_params][am::strings::play_tone] = true;
-
- EXPECT_CALL(mock_message_helper_,
- ProcessSoftButtons((*msg_)[am::strings::msg_params], _, _, _))
- .WillOnce(Return(mobile_apis::Result::SUCCESS));
-
- EXPECT_CALL(mock_message_helper_,
- SubscribeApplicationToSoftButton(
- (*msg_)[am::strings::msg_params], _, kFunctionId));
-
- ExpectManageHmiCommandTTSAndUI();
- CommandPtr command(CreateCommand<AlertRequest>(msg_));
- command->Run();
-}
-
-TEST_F(AlertRequestTest, OnEvent_InvalidEventId_UNSUCCESS) {
- Expectations();
- EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0);
-
- Event event(hmi_apis::FunctionID::INVALID_ENUM);
- event.set_smart_object(*msg_);
-
- CommandPtr command(CreateCommand<AlertRequest>(msg_));
- command->on_event(event);
-}
-
-TEST_F(AlertRequestTest, DISABLED_OnEvent_UI_OnResetTimeout_SUCCESS) {
- PreConditions();
- Expectations();
- AddAlertTextsToMsg();
-
- (*msg_)[am::strings::msg_params][am::strings::duration] = kDefaultTimeout;
-
- CommandPtr command(CreateCommand<AlertRequest>(msg_));
- EXPECT_TRUE(command->Init());
-
- EXPECT_CALL(
- app_mngr_,
- updateRequestTimeout(kConnectionKey, kCorrelationId, kDefaultTimeout));
-
- ExpectManageMobileCommandWithResultCode(mobile_apis::Result::INVALID_ENUM);
-
- Event event(hmi_apis::FunctionID::UI_OnResetTimeout);
- event.set_smart_object(*msg_);
- command->on_event(event);
-}
-
-TEST_F(AlertRequestTest, OnEvent_UIAlertHasHmiResponsesToWait_UNSUCCESS) {
- Expectations();
- AddAlertTextsToMsg();
- AddTTSChunkToMsg();
-
- (*msg_)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::WARNINGS;
- (*msg_)[am::strings::msg_params][am::strings::play_tone] = true;
-
- CommandPtr command(CreateCommand<AlertRequest>(msg_));
-
- ExpectCallHmiLevel(mobile_apis::HMILevel::HMI_FULL);
-
- EXPECT_CALL(mock_message_helper_,
- ProcessSoftButtons((*msg_)[am::strings::msg_params], _, _, _))
- .WillOnce(Return(mobile_apis::Result::SUCCESS));
-
- ExpectManageHmiCommandTTSAndUI();
-
- command->Run();
-
- Event event(hmi_apis::FunctionID::UI_Alert);
- event.set_smart_object(*msg_);
-
- EXPECT_CALL(app_mngr_,
- ManageHMICommand(
- HMIResultCodeIs(hmi_apis::FunctionID::TTS_StopSpeaking)));
-
- command->on_event(event);
-}
-
-TEST_F(AlertRequestTest, DISABLED_OnEvent_TTSWarnings_SUCCESS) {
- PreConditions();
- Expectations();
- AddTTSChunkToMsg();
- (*msg_)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::WARNINGS;
- (*msg_)[am::strings::msg_params][am::strings::play_tone] = true;
-
- ExpectCallHmiLevel(mobile_apis::HMILevel::HMI_FULL);
-
- EXPECT_CALL(mock_message_helper_,
- ProcessSoftButtons((*msg_)[am::strings::msg_params], _, _, _))
- .WillOnce(Return(mobile_apis::Result::SUCCESS));
-
- EXPECT_CALL(
- app_mngr_,
- ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak)))
- .WillOnce(Return(true));
-
- CommandPtr command(CreateCommand<AlertRequest>(msg_));
- command->Run();
-
- ExpectManageMobileCommandWithResultCode(mobile_apis::Result::WARNINGS);
-
- Event event(hmi_apis::FunctionID::TTS_Speak);
- event.set_smart_object(*msg_);
- command->on_event(event);
-}
-
-TEST_F(AlertRequestTest, DISABLED_OnEvent_TTSUnsupportedResource_SUCCESS) {
- Expectations();
- AddTTSChunkToMsg();
- (*msg_)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
- (*msg_)[am::strings::msg_params][am::strings::play_tone] = true;
-
- ExpectCallHmiLevel(mobile_apis::HMILevel::HMI_FULL);
-
- EXPECT_CALL(mock_message_helper_,
- ProcessSoftButtons((*msg_)[am::strings::msg_params], _, _, _))
- .WillOnce(Return(mobile_apis::Result::SUCCESS));
- EXPECT_CALL(
- app_mngr_,
- ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak)))
- .WillOnce(Return(true));
-
- CommandPtr command(CreateCommand<AlertRequest>(msg_));
- command->Run();
-
- ExpectManageMobileCommandWithResultCode(mobile_apis::Result::WARNINGS);
-
- Event event(hmi_apis::FunctionID::TTS_Speak);
- event.set_smart_object(*msg_);
- PreConditions();
-
- command->on_event(event);
-}
-
-TEST_F(AlertRequestTest,
- DISABLED_OnEvent_TTSUnsupportedResourceUiAlertSent_SUCCESS) {
- PreConditions();
-
- Expectations();
- AddAlertTextsToMsg();
- AddTTSChunkToMsg();
- (*msg_)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
- (*msg_)[am::strings::msg_params][am::strings::play_tone] = true;
- (*msg_)[am::strings::msg_params][am::strings::soft_buttons] = "soft_buttons";
-
- ExpectCallHmiLevel(mobile_apis::HMILevel::HMI_FULL);
- EXPECT_CALL(mock_message_helper_,
- ProcessSoftButtons((*msg_)[am::strings::msg_params], _, _, _))
- .WillOnce(Return(mobile_apis::Result::SUCCESS));
- EXPECT_CALL(mock_message_helper_,
- SubscribeApplicationToSoftButton(
- (*msg_)[am::strings::msg_params], _, kFunctionId));
-
- ExpectManageHmiCommandTTSAndUI();
-
- CommandPtr command(CreateCommand<AlertRequest>(msg_));
- command->Run();
-
- EXPECT_CALL(
- app_mngr_,
- ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_StopSpeaking)))
- .WillOnce(Return(true));
-
- Event ui_event(hmi_apis::FunctionID::UI_Alert);
- ui_event.set_smart_object(*msg_);
- command->on_event(ui_event);
-
- Event tts_stop_event(hmi_apis::FunctionID::TTS_StopSpeaking);
- tts_stop_event.set_smart_object(*msg_);
- command->on_event(tts_stop_event);
-
- ExpectManageMobileCommandWithResultCode(mobile_apis::Result::WARNINGS);
-
- Event event(hmi_apis::FunctionID::TTS_Speak);
- event.set_smart_object(*msg_);
- command->on_event(event);
-}
-
-TEST_F(AlertRequestTest, OnEvent_TTSUnsupportedResourceUiAlertSuccess_SUCCESS) {
- Expectations();
- AddAlertTextsToMsg();
- AddTTSChunkToMsg();
- (*msg_)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
- (*msg_)[am::strings::msg_params][am::strings::play_tone] = true;
- (*msg_)[am::strings::msg_params][am::strings::soft_buttons] = "soft_buttons";
-
- ExpectCallHmiLevel(mobile_apis::HMILevel::HMI_FULL);
- EXPECT_CALL(mock_message_helper_,
- ProcessSoftButtons((*msg_)[am::strings::msg_params], _, _, _))
- .WillOnce(Return(mobile_apis::Result::SUCCESS));
- EXPECT_CALL(mock_message_helper_,
- SubscribeApplicationToSoftButton(
- (*msg_)[am::strings::msg_params], _, kFunctionId));
- ExpectManageHmiCommandTTSAndUI();
-
- CommandPtr command(CreateCommand<AlertRequest>(msg_));
- command->Run();
-
- (*msg_)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::SUCCESS;
-
- EXPECT_CALL(
- app_mngr_,
- ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_StopSpeaking)))
- .WillOnce(Return(true));
-
- Event ui_event(hmi_apis::FunctionID::UI_Alert);
- ui_event.set_smart_object(*msg_);
- command->on_event(ui_event);
-
- Event tts_stop_event(hmi_apis::FunctionID::TTS_StopSpeaking);
- tts_stop_event.set_smart_object(*msg_);
- command->on_event(tts_stop_event);
-
- (*msg_)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
- ExpectManageMobileCommandWithResultCode(mobile_apis::Result::WARNINGS);
-
- Event event(hmi_apis::FunctionID::TTS_Speak);
- event.set_smart_object(*msg_);
- command->on_event(event);
-}
-
-TEST_F(AlertRequestTest, OnEvent_TTSSuccesUiAlertInvalidEnum_SUCCESS) {
- Expectations();
- AddTTSChunkToMsg();
- (*msg_)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
- (*msg_)[am::strings::msg_params][am::strings::play_tone] = true;
-
- ExpectCallHmiLevel(mobile_apis::HMILevel::HMI_FULL);
- EXPECT_CALL(mock_message_helper_,
- ProcessSoftButtons((*msg_)[am::strings::msg_params], _, _, _))
- .WillOnce(Return(mobile_apis::Result::SUCCESS));
- EXPECT_CALL(
- app_mngr_,
- ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak)))
- .WillOnce(Return(true));
-
- CommandPtr command(CreateCommand<AlertRequest>(msg_));
- command->Run();
-
- (*msg_)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::INVALID_ENUM;
-
- EXPECT_CALL(
- app_mngr_,
- ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_StopSpeaking)))
- .WillOnce(Return(true));
-
- Event ui_event(hmi_apis::FunctionID::UI_Alert);
- ui_event.set_smart_object(*msg_);
- command->on_event(ui_event);
-
- Event tts_stop_event(hmi_apis::FunctionID::TTS_StopSpeaking);
- tts_stop_event.set_smart_object(*msg_);
- command->on_event(tts_stop_event);
-
- (*msg_)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::SUCCESS;
-
- ExpectManageMobileCommandWithResultCode(mobile_apis::Result::SUCCESS);
-
- Event event(hmi_apis::FunctionID::TTS_Speak);
- event.set_smart_object(*msg_);
- command->on_event(event);
-}
-
-TEST_F(AlertRequestTest, DISABLED_OnEvent_TTSAbortedUiAlertNotSent_SUCCESS) {
- Expectations();
- AddTTSChunkToMsg();
- (*msg_)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
- (*msg_)[am::strings::msg_params][am::strings::play_tone] = true;
-
- ExpectCallHmiLevel(mobile_apis::HMILevel::HMI_FULL);
- EXPECT_CALL(mock_message_helper_,
- ProcessSoftButtons((*msg_)[am::strings::msg_params], _, _, _))
- .WillOnce(Return(mobile_apis::Result::SUCCESS));
- EXPECT_CALL(
- app_mngr_,
- ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak)))
- .WillOnce(Return(true));
-
- CommandPtr command(CreateCommand<AlertRequest>(msg_));
- command->Run();
-
- (*msg_)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::INVALID_ENUM;
-
- EXPECT_CALL(
- app_mngr_,
- ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_StopSpeaking)))
- .WillOnce(Return(true));
-
- Event ui_event(hmi_apis::FunctionID::UI_Alert);
- ui_event.set_smart_object(*msg_);
- command->on_event(ui_event);
-
- Event tts_stop_event(hmi_apis::FunctionID::TTS_StopSpeaking);
- tts_stop_event.set_smart_object(*msg_);
- command->on_event(tts_stop_event);
-
- (*msg_)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::ABORTED;
-
- ExpectManageMobileCommandWithResultCode(mobile_apis::Result::ABORTED);
-
- Event event(hmi_apis::FunctionID::TTS_Speak);
- event.set_smart_object(*msg_);
- command->on_event(event);
-}
-
-TEST_F(AlertRequestTest, DISABLED_OnEvent_TTSWarningUiAlertWarning_SUCCESS) {
- Expectations();
- AddAlertTextsToMsg();
- (*msg_)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::WARNINGS;
- (*msg_)[am::strings::msg_params][am::strings::play_tone] = true;
-
- ExpectCallHmiLevel(mobile_apis::HMILevel::HMI_FULL);
- EXPECT_CALL(mock_message_helper_,
- ProcessSoftButtons((*msg_)[am::strings::msg_params], _, _, _))
- .WillOnce(Return(mobile_apis::Result::SUCCESS));
- ExpectManageHmiCommandTTSAndUI();
-
- CommandPtr command(CreateCommand<AlertRequest>(msg_));
- command->Run();
-
- EXPECT_CALL(
- app_mngr_,
- ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_StopSpeaking)))
- .WillOnce(Return(true));
-
- Event ui_event(hmi_apis::FunctionID::UI_Alert);
- ui_event.set_smart_object(*msg_);
- command->on_event(ui_event);
-
- Event tts_stop_event(hmi_apis::FunctionID::TTS_StopSpeaking);
- tts_stop_event.set_smart_object(*msg_);
- command->on_event(tts_stop_event);
-
- ExpectManageMobileCommandWithResultCode(mobile_apis::Result::WARNINGS);
-
- Event event(hmi_apis::FunctionID::TTS_Speak);
- event.set_smart_object(*msg_);
- command->on_event(event);
-}
-
-TEST_F(AlertRequestTest, Run_InvalidAlert2_UNSUCCESS) {
- Expectations();
- AddAlertTextsToMsg();
- (*msg_)[am::strings::msg_params][am::strings::alert_text2] =
- "invalid_text_with_empty_str\\n";
-
- EXPECT_CALL(mock_message_helper_, ProcessSoftButtons(_, _, _, _)).Times(0);
- ExpectManageMobileCommandWithResultCode(mobile_apis::Result::INVALID_DATA);
-
- CommandPtr command(CreateCommand<AlertRequest>(msg_));
- command->Run();
-}
-
-TEST_F(AlertRequestTest, Run_InvalidAlert3_UNSUCCESS) {
- Expectations();
- AddAlertTextsToMsg();
- (*msg_)[am::strings::msg_params][am::strings::alert_text3] =
- "invalid_text_with_empty_str\\n";
-
- EXPECT_CALL(mock_message_helper_, ProcessSoftButtons(_, _, _, _)).Times(0);
- ExpectManageMobileCommandWithResultCode(mobile_apis::Result::INVALID_DATA);
-
- CommandPtr command(CreateCommand<AlertRequest>(msg_));
- command->Run();
-}
-
-TEST_F(AlertRequestTest, Run_InvalidTTSChunk_UNSUCCESS) {
- Expectations();
- AddAlertTextsToMsg();
- (*msg_)[am::strings::msg_params][am::strings::tts_chunks][0]
- [am::strings::text] = "invalid_text_with_empty_str\\n";
-
- EXPECT_CALL(mock_message_helper_, ProcessSoftButtons(_, _, _, _)).Times(0);
- ExpectManageMobileCommandWithResultCode(mobile_apis::Result::INVALID_DATA);
-
- CommandPtr command(CreateCommand<AlertRequest>(msg_));
- command->Run();
-}
-
-} // namespace alert_request
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/change_registration_test.cc b/src/components/application_manager/test/commands/mobile/change_registration_test.cc
deleted file mode 100644
index 3d7671015c..0000000000
--- a/src/components/application_manager/test/commands/mobile/change_registration_test.cc
+++ /dev/null
@@ -1,565 +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 <set>
-
-#include "application_manager/commands/mobile/change_registration_request.h"
-
-#include "gtest/gtest.h"
-#include "utils/shared_ptr.h"
-#include "utils/helpers.h"
-#include "utils/make_shared.h"
-#include "utils/custom_string.h"
-#include "smart_objects/smart_object.h"
-#include "application_manager/commands/command_request_test.h"
-#include "application_manager/smart_object_keys.h"
-#include "policy/usage_statistics/mock_statistics_manager.h"
-#include "application_manager/mock_application.h"
-#include "application_manager/mock_application_manager.h"
-#include "application_manager/mock_message_helper.h"
-#include "application_manager/mock_hmi_capabilities.h"
-#include "application_manager/event_engine/event.h"
-#include "application_manager/mock_hmi_interface.h"
-#include "application_manager/policies/mock_policy_handler_interface.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace change_registration_request {
-
-namespace am = application_manager;
-using am::commands::CommandImpl;
-using am::ApplicationManager;
-using am::commands::MessageSharedPtr;
-using am::ApplicationSharedPtr;
-using am::MockMessageHelper;
-using ::testing::_;
-using ::utils::SharedPtr;
-using ::testing::Return;
-using ::testing::ReturnRef;
-using ::testing::SetArgPointee;
-using am::commands::ChangeRegistrationRequest;
-using policy_test::MockPolicyHandlerInterface;
-using ::test::components::application_manager_test::MockApplication;
-
-namespace custom_str = utils::custom_string;
-namespace strings = ::application_manager::strings;
-namespace hmi_response = ::application_manager::hmi_response;
-
-namespace {
-const uint32_t kAppId = 1u;
-const uint32_t kCmdId = 1u;
-const uint32_t kConnectionKey = 2u;
-} // namespace
-
-class ChangeRegistrationRequestTest
- : public CommandRequestTest<CommandsTestMocks::kIsNice> {
- public:
- ChangeRegistrationRequestTest()
- : mock_app_(CreateMockApp())
- , supported_languages_(CreateMessage(smart_objects::SmartType_Array)) {}
-
- MessageSharedPtr CreateMsgFromMobile() {
- MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
- (*msg)[strings::params][strings::connection_key] = kConnectionKey;
- smart_objects::SmartObject msg_params =
- smart_objects::SmartObject(smart_objects::SmartType_Map);
- msg_params[strings::hmi_display_language] = mobile_apis::Language::EN_US;
- msg_params[strings::language] = mobile_apis::Language::EN_US;
- (*msg)[strings::msg_params] = msg_params;
- return msg;
- }
- void PrepareExpectationBeforeRun() {
- ON_CALL(app_mngr_, hmi_capabilities())
- .WillByDefault(ReturnRef(hmi_capabilities_));
- (*supported_languages_)[0] =
- static_cast<int32_t>(mobile_apis::Language::EN_US);
- EXPECT_CALL(hmi_capabilities_, ui_supported_languages())
- .WillOnce(Return(supported_languages_.get()));
- EXPECT_CALL(hmi_capabilities_, vr_supported_languages())
- .WillOnce(Return(supported_languages_.get()));
- EXPECT_CALL(hmi_capabilities_, tts_supported_languages())
- .WillOnce(Return(supported_languages_.get()));
-
- EXPECT_CALL(app_mngr_, hmi_interfaces())
- .WillRepeatedly(ReturnRef(mock_hmi_interfaces_));
- EXPECT_CALL(
- mock_hmi_interfaces_,
- GetInterfaceFromFunction(hmi_apis::FunctionID::UI_ChangeRegistration))
- .WillRepeatedly(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
- EXPECT_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
- .WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE));
-
- EXPECT_CALL(
- mock_hmi_interfaces_,
- GetInterfaceFromFunction(hmi_apis::FunctionID::VR_ChangeRegistration))
- .WillRepeatedly(Return(am::HmiInterfaces::HMI_INTERFACE_VR));
- EXPECT_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR))
- .WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE));
-
- EXPECT_CALL(
- mock_hmi_interfaces_,
- GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_ChangeRegistration))
- .WillRepeatedly(Return(am::HmiInterfaces::HMI_INTERFACE_TTS));
- EXPECT_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS))
- .WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE));
- }
-
- void CheckExpectations(const hmi_apis::Common_Result::eType hmi_response,
- const mobile_apis::Result::eType mobile_response,
- const am::HmiInterfaces::InterfaceState state,
- const bool success,
- const hmi_apis::Common_Result::eType ui_hmi_response =
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE,
- const hmi_apis::Common_Result::eType vr_hmi_response =
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE) {
- MessageSharedPtr msg_from_mobile = CreateMsgFromMobile();
-
- utils::SharedPtr<ChangeRegistrationRequest> command =
- CreateCommand<ChangeRegistrationRequest>(msg_from_mobile);
- MockAppPtr mock_app = CreateMockApp();
- ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app));
- ON_CALL(*mock_app, app_id()).WillByDefault(Return(1));
- am::ApplicationSet application_set;
- const utils::custom_string::CustomString name("name");
- MockAppPtr app = CreateMockApp();
- app->set_name(name);
-
- DataAccessor<am::ApplicationSet> accessor(application_set, app_set_lock_);
-
- application_set.insert(app);
-
- EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(accessor));
- EXPECT_CALL(*app, name()).WillOnce(ReturnRef(name));
- PrepareExpectationBeforeRun();
- EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
- .WillRepeatedly(Return(state));
- command->Run();
-
- MessageSharedPtr ui_response = CreateMessage(smart_objects::SmartType_Map);
- MessageSharedPtr vr_response = CreateMessage(smart_objects::SmartType_Map);
- MessageSharedPtr tts_response = CreateMessage(smart_objects::SmartType_Map);
- CreateResponseFromHMI(ui_response, ui_hmi_response, "ui_info");
- CreateResponseFromHMI(vr_response, vr_hmi_response, "unsupported_resource");
-
- (*tts_response)[strings::params][hmi_response::code] = hmi_response;
- (*tts_response)[strings::msg_params] = 0;
-
- am::event_engine::Event event_ui(
- hmi_apis::FunctionID::UI_ChangeRegistration);
- event_ui.set_smart_object(*ui_response);
- am::event_engine::Event event_vr(
- hmi_apis::FunctionID::VR_ChangeRegistration);
- event_vr.set_smart_object(*vr_response);
- am::event_engine::Event event_tts(
- hmi_apis::FunctionID::TTS_ChangeRegistration);
- event_tts.set_smart_object(*tts_response);
-
- MessageSharedPtr response_to_mobile;
-
- EXPECT_CALL(app_mngr_,
- ManageMobileCommand(
- _, am::commands::Command::CommandOrigin::ORIGIN_SDL))
- .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true)));
-
- command->on_event(event_ui);
- command->on_event(event_vr);
- command->on_event(event_tts);
-
- EXPECT_EQ(
- (*response_to_mobile)[strings::msg_params][strings::success].asBool(),
- success);
- EXPECT_EQ((*response_to_mobile)[strings::msg_params][strings::result_code]
- .asInt(),
- static_cast<int32_t>(mobile_response));
- }
-
- void CreateResponseFromHMI(MessageSharedPtr msg,
- hmi_apis::Common_Result::eType result,
- const std::string& info) {
- (*msg)[strings::params][hmi_response::code] = static_cast<int32_t>(result);
- (*msg)[strings::msg_params][strings::info] = info;
- }
-
- MessageSharedPtr CreateFullParamsUISO() {
- MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
- (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey;
- smart_objects::SmartObject menu_params =
- smart_objects::SmartObject(smart_objects::SmartType_Map);
- menu_params[am::strings::position] = 10;
- menu_params[am::strings::menu_name] = "LG";
-
- smart_objects::SmartObject msg_params =
- smart_objects::SmartObject(smart_objects::SmartType_Map);
- msg_params[am::strings::cmd_id] = kCmdId;
- msg_params[am::strings::menu_params] = menu_params;
- msg_params[am::strings::app_id] = kAppId;
- msg_params[am::strings::cmd_icon] = 1;
- msg_params[am::strings::cmd_icon][am::strings::value] = "10";
- (*msg)[am::strings::msg_params] = msg_params;
-
- return msg;
- }
-
- void SetUp() OVERRIDE {
- ON_CALL(app_mngr_, application(kConnectionKey))
- .WillByDefault(Return(mock_app_));
- ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey));
- ON_CALL(app_mngr_, hmi_capabilities())
- .WillByDefault(ReturnRef(hmi_capabilities_));
- }
-
- void ExpectationsHmiCapabilities(
- smart_objects::SmartObjectSPtr supported_languages) {
- EXPECT_CALL(hmi_capabilities_, ui_supported_languages())
- .WillOnce(Return(supported_languages.get()));
- EXPECT_CALL(hmi_capabilities_, vr_supported_languages())
- .WillOnce(Return(supported_languages.get()));
- EXPECT_CALL(hmi_capabilities_, tts_supported_languages())
- .WillOnce(Return(supported_languages.get()));
- }
-
- void ResultCommandExpectations(MessageSharedPtr msg,
- const std::string& info) {
- EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::success].asBool(),
- true);
- EXPECT_EQ(
- (*msg)[am::strings::msg_params][am::strings::result_code].asInt(),
- static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE));
- EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::info].asString(),
- info);
- }
-
- typedef TypeIf<kMocksAreNice,
- NiceMock<application_manager_test::MockHMICapabilities>,
- application_manager_test::MockHMICapabilities>::Result
- MockHMICapabilities;
- sync_primitives::Lock app_set_lock_;
- MockHMICapabilities hmi_capabilities_;
- MockAppPtr mock_app_;
- MessageSharedPtr supported_languages_;
- MockPolicyHandlerInterface mock_policy_handler_;
-};
-
-typedef ChangeRegistrationRequestTest::MockHMICapabilities MockHMICapabilities;
-
-TEST_F(ChangeRegistrationRequestTest,
- OnEvent_VRHmiSendSuccess_UNSUPPORTED_RESOURCE) {
- MessageSharedPtr msg_from_mobile = CreateMsgFromMobile();
- utils::SharedPtr<ChangeRegistrationRequest> command =
- CreateCommand<ChangeRegistrationRequest>(msg_from_mobile);
-
- am::ApplicationSet application_set;
- const utils::custom_string::CustomString name("name");
- MockAppPtr app = CreateMockApp();
- app->set_name(name);
-
- DataAccessor<am::ApplicationSet> accessor(application_set, app_set_lock_);
-
- application_set.insert(app);
-
- EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(accessor));
- EXPECT_CALL(*app, name()).WillOnce(ReturnRef(name));
-
- smart_objects::SmartObjectSPtr supported_languages(
- CreateMessage(smart_objects::SmartType_Array));
- (*supported_languages)[0] =
- static_cast<int32_t>(mobile_apis::Language::EN_US);
-
- ExpectationsHmiCapabilities(supported_languages);
-
- ON_CALL(mock_hmi_interfaces_,
- GetInterfaceFromFunction(hmi_apis::FunctionID::UI_ChangeRegistration))
- .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
- ON_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
- .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
-
- ON_CALL(mock_hmi_interfaces_,
- GetInterfaceFromFunction(hmi_apis::FunctionID::VR_ChangeRegistration))
- .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_VR));
- ON_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR))
- .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_RESPONSE));
-
- ON_CALL(
- mock_hmi_interfaces_,
- GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_ChangeRegistration))
- .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_TTS));
- ON_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS))
- .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
- command->Run();
-
- MessageSharedPtr ui_response = CreateMessage(smart_objects::SmartType_Map);
- MessageSharedPtr vr_response = CreateMessage(smart_objects::SmartType_Map);
- MessageSharedPtr tts_response = CreateMessage(smart_objects::SmartType_Map);
- CreateResponseFromHMI(
- ui_response, hmi_apis::Common_Result::WARNINGS, "ui_info");
- CreateResponseFromHMI(vr_response,
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE,
- "VR is not supported by system");
- CreateResponseFromHMI(
- tts_response, hmi_apis::Common_Result::SUCCESS, "tts_info");
- (*ui_response)[am::strings::msg_params][am::strings::app_id] = kConnectionKey;
- (*vr_response)[am::strings::msg_params][am::strings::app_id] = kConnectionKey;
- (*tts_response)[am::strings::msg_params][am::strings::app_id] =
- kConnectionKey;
- am::event_engine::Event event_ui(hmi_apis::FunctionID::UI_ChangeRegistration);
- event_ui.set_smart_object(*ui_response);
- am::event_engine::Event event_vr(hmi_apis::FunctionID::VR_ChangeRegistration);
- event_vr.set_smart_object(*vr_response);
- am::event_engine::Event event_tts(
- hmi_apis::FunctionID::TTS_ChangeRegistration);
- event_tts.set_smart_object(*tts_response);
-
- EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
- .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
-
- MessageSharedPtr response_to_mobile;
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
- .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true)));
-
- command->on_event(event_ui);
- command->on_event(event_tts);
- command->on_event(event_vr);
-
- ResultCommandExpectations(response_to_mobile,
- "ui_info, VR is not supported by system, tts_info");
-}
-
-TEST_F(ChangeRegistrationRequestTest,
- OnEvent_TTS_UNSUPPORTED_RESOURCE_STATE_NOT_AVAILABLE_Expect_false) {
- MessageSharedPtr msg_from_mobile = CreateMsgFromMobile();
- utils::SharedPtr<ChangeRegistrationRequest> command =
- CreateCommand<ChangeRegistrationRequest>(msg_from_mobile);
- MockAppPtr mock_app = CreateMockApp();
- ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app));
- ON_CALL(*mock_app, app_id()).WillByDefault(Return(1));
- am::ApplicationSet application_set;
- const utils::custom_string::CustomString name("name");
- MockAppPtr app = CreateMockApp();
- app->set_name(name);
- DataAccessor<am::ApplicationSet> accessor(application_set, app_set_lock_);
- application_set.insert(app);
- EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(accessor));
- EXPECT_CALL(*app, name()).WillOnce(ReturnRef(name));
-
- ON_CALL(app_mngr_, hmi_capabilities())
- .WillByDefault(ReturnRef(hmi_capabilities_));
- (*supported_languages_)[0] =
- static_cast<int32_t>(mobile_apis::Language::EN_US);
- EXPECT_CALL(hmi_capabilities_, ui_supported_languages())
- .WillOnce(Return(supported_languages_.get()));
- EXPECT_CALL(hmi_capabilities_, vr_supported_languages())
- .WillOnce(Return(supported_languages_.get()));
- EXPECT_CALL(hmi_capabilities_, tts_supported_languages())
- .WillOnce(Return(supported_languages_.get()));
-
- EXPECT_CALL(app_mngr_, hmi_interfaces())
- .WillRepeatedly(ReturnRef(mock_hmi_interfaces_));
-
- EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
- .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
-
- MessageSharedPtr response_to_mobile;
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
- .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true)));
- command->Run();
-
- EXPECT_EQ(
- (*response_to_mobile)[strings::msg_params][strings::success].asBool(),
- false);
- EXPECT_EQ(
- (*response_to_mobile)[strings::msg_params][strings::result_code].asInt(),
- static_cast<int32_t>(mobile_apis::Result::UNSUPPORTED_RESOURCE));
-}
-
-TEST_F(ChangeRegistrationRequestTest,
- OnEvent_TTS_UNSUPPORTED_RESOURCE_STATE_NOT_RESPONSE_Expect_false) {
- CheckExpectations(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE,
- mobile_apis::Result::UNSUPPORTED_RESOURCE,
- am::HmiInterfaces::STATE_NOT_RESPONSE,
- false);
-}
-
-TEST_F(ChangeRegistrationRequestTest,
- OnEvent_TTS_UNSUPPORTED_RESOURCE_STATE_AVAILABLE_Expect_false) {
- CheckExpectations(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE,
- mobile_apis::Result::UNSUPPORTED_RESOURCE,
- am::HmiInterfaces::STATE_AVAILABLE,
- false);
-}
-
-TEST_F(ChangeRegistrationRequestTest,
- OnEvent_TTS_UNSUPPORTED_RESOURCE_SUCCESS_STATE_AVAILABLE_Expect_true) {
- CheckExpectations(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE,
- mobile_apis::Result::UNSUPPORTED_RESOURCE,
- am::HmiInterfaces::STATE_AVAILABLE,
- true,
- hmi_apis::Common_Result::SUCCESS,
- hmi_apis::Common_Result::SUCCESS);
-}
-
-TEST_F(ChangeRegistrationRequestTest,
- OnEvent_TTS_SUCCESS_STATE_AVAILABLE_Expect_true) {
- CheckExpectations(hmi_apis::Common_Result::SUCCESS,
- mobile_apis::Result::SUCCESS,
- am::HmiInterfaces::STATE_AVAILABLE,
- true,
- hmi_apis::Common_Result::SUCCESS,
- hmi_apis::Common_Result::SUCCESS);
-}
-
-TEST_F(ChangeRegistrationRequestTest,
- OnEvent_TTS_WRONG_LANGUAGE_STATE_AVAILABLE_Expect_true) {
- CheckExpectations(hmi_apis::Common_Result::WRONG_LANGUAGE,
- mobile_apis::Result::WRONG_LANGUAGE,
- am::HmiInterfaces::STATE_AVAILABLE,
- true,
- hmi_apis::Common_Result::SUCCESS,
- hmi_apis::Common_Result::SUCCESS);
-}
-
-TEST_F(ChangeRegistrationRequestTest,
- OnEvent_TTS_INVALID_DATA_STATE_AVAILABLE_Expect_false) {
- CheckExpectations(hmi_apis::Common_Result::INVALID_DATA,
- mobile_apis::Result::INVALID_DATA,
- am::HmiInterfaces::STATE_AVAILABLE,
- false,
- hmi_apis::Common_Result::SUCCESS,
- hmi_apis::Common_Result::SUCCESS);
-}
-
-TEST_F(ChangeRegistrationRequestTest,
- OnEvent_UIHmiSendSuccess_UNSUPPORTED_RESOURCE) {
- MessageSharedPtr msg_from_mobile = CreateMsgFromMobile();
-
- utils::SharedPtr<ChangeRegistrationRequest> command =
- CreateCommand<ChangeRegistrationRequest>(msg_from_mobile);
-
- am::ApplicationSet application_set;
- const utils::custom_string::CustomString name("name");
- MockAppPtr app = CreateMockApp();
- app->set_name(name);
-
- DataAccessor<am::ApplicationSet> accessor(application_set, app_set_lock_);
-
- application_set.insert(app);
-
- EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(accessor));
- EXPECT_CALL(*app, name()).WillOnce(ReturnRef(name));
-
- smart_objects::SmartObjectSPtr supported_languages(
- CreateMessage(smart_objects::SmartType_Array));
- (*supported_languages)[0] =
- static_cast<int32_t>(mobile_apis::Language::EN_US);
-
- ExpectationsHmiCapabilities(supported_languages);
-
- ON_CALL(mock_hmi_interfaces_,
- GetInterfaceFromFunction(hmi_apis::FunctionID::UI_ChangeRegistration))
- .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
- ON_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
- .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
-
- ON_CALL(mock_hmi_interfaces_,
- GetInterfaceFromFunction(hmi_apis::FunctionID::VR_ChangeRegistration))
- .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_VR));
- ON_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR))
- .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
-
- ON_CALL(
- mock_hmi_interfaces_,
- GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_ChangeRegistration))
- .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_TTS));
- ON_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS))
- .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
-
- command->Run();
-
- MessageSharedPtr ui_response = CreateMessage(smart_objects::SmartType_Map);
- MessageSharedPtr vr_response = CreateMessage(smart_objects::SmartType_Map);
- MessageSharedPtr tts_response = CreateMessage(smart_objects::SmartType_Map);
- CreateResponseFromHMI(ui_response,
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE,
- "unsupported_resource");
- CreateResponseFromHMI(
- vr_response, hmi_apis::Common_Result::WARNINGS, "vr_info");
- CreateResponseFromHMI(
- tts_response, hmi_apis::Common_Result::SUCCESS, "tts_info");
- (*ui_response)[am::strings::msg_params][am::strings::app_id] = kConnectionKey;
- (*vr_response)[am::strings::msg_params][am::strings::app_id] = kConnectionKey;
- (*tts_response)[am::strings::msg_params][am::strings::app_id] =
- kConnectionKey;
- am::event_engine::Event event_ui(hmi_apis::FunctionID::UI_ChangeRegistration);
- event_ui.set_smart_object(*ui_response);
- am::event_engine::Event event_vr(hmi_apis::FunctionID::VR_ChangeRegistration);
- event_vr.set_smart_object(*vr_response);
- am::event_engine::Event event_tts(
- hmi_apis::FunctionID::TTS_ChangeRegistration);
- event_tts.set_smart_object(*tts_response);
-
- MessageSharedPtr response_to_mobile;
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
- .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true)));
-
- command->on_event(event_vr);
- command->on_event(event_tts);
- command->on_event(event_ui);
-
- ResultCommandExpectations(response_to_mobile,
- "unsupported_resource, vr_info, tts_info");
-}
-
-} // namespace change_registration_request
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace tests
diff --git a/src/components/application_manager/test/commands/mobile/create_interaction_choice_set_test.cc b/src/components/application_manager/test/commands/mobile/create_interaction_choice_set_test.cc
deleted file mode 100644
index c3513d2acb..0000000000
--- a/src/components/application_manager/test/commands/mobile/create_interaction_choice_set_test.cc
+++ /dev/null
@@ -1,814 +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 <set>
-
-#include "application_manager/commands/mobile/create_interaction_choice_set_request.h"
-#include "application_manager/commands/mobile/create_interaction_choice_set_response.h"
-
-#include "gtest/gtest.h"
-#include "utils/shared_ptr.h"
-#include "utils/helpers.h"
-#include "utils/make_shared.h"
-#include "smart_objects/smart_object.h"
-#include "utils/custom_string.h"
-#include "application_manager/commands/command_request_test.h"
-#include "application_manager/smart_object_keys.h"
-#include "application_manager/mock_application.h"
-#include "application_manager/mock_application_manager.h"
-#include "application_manager/mock_message_helper.h"
-#include "application_manager/event_engine/event.h"
-#include "application_manager/mock_hmi_interface.h"
-#include "application_manager/mock_hmi_capabilities.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace create_interaction_choice_set_request {
-
-namespace am = application_manager;
-using am::commands::CommandImpl;
-using am::ApplicationManager;
-using am::commands::MessageSharedPtr;
-using am::ApplicationSharedPtr;
-using am::MockMessageHelper;
-using ::testing::_;
-using ::utils::SharedPtr;
-using ::testing::Return;
-using ::testing::ReturnRef;
-using ::testing::AtLeast;
-using am::commands::CreateInteractionChoiceSetRequest;
-using am::commands::CreateInteractionChoiceSetResponse;
-using ::test::components::application_manager_test::MockApplication;
-
-namespace custom_str = utils::custom_string;
-namespace strings = ::application_manager::strings;
-namespace hmi_response = ::application_manager::hmi_response;
-
-typedef SharedPtr<CreateInteractionChoiceSetRequest>
- CreateInteractionChoiceSetRequestPtr;
-typedef SharedPtr<CreateInteractionChoiceSetResponse>
- CreateInteractionChoiceSetResponsePtr;
-
-typedef NiceMock<
- ::test::components::application_manager_test::MockHMICapabilities>
- MockHMICapabilities;
-
-namespace {
-const hmi_apis::FunctionID::eType kInvalidFunctionId =
- hmi_apis::FunctionID::INVALID_ENUM;
-const int32_t kCommandId = 1;
-const uint32_t kAppId = 1u;
-const uint32_t kCmdId = 1u;
-const uint32_t kConnectionKey = 2u;
-const uint32_t kCorrelationId = 10u;
-const uint32_t kGrammarId = 10u;
-const int32_t kMenuId = 5;
-const uint32_t kChoiceSetId = 1u;
-const uint32_t kChoiceId1 = 2u;
-const uint32_t kChoiceId2 = 3u;
-const std::string kImage = "image";
-const std::string kSecondImage = "second_image";
-const std::string kVrCommands1 = "vr_commands_1";
-const std::string kVrCommands2 = "vr_commands_2";
-const std::string kMenuName = "menu_name";
-
-} // namespace
-
-class CreateInteractionChoiceSetRequestTest
- : public CommandRequestTest<CommandsTestMocks::kIsNice> {
- public:
- CreateInteractionChoiceSetRequestTest()
- : message_(CreateMessage())
- , command_(CreateCommand<CreateInteractionChoiceSetRequest>(message_))
- , mock_app_(CreateMockApp()) {}
-
- MessageSharedPtr CreateFullParamsVRSO() {
- MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
- (*msg)[strings::params][strings::connection_key] = kConnectionKey;
- smart_objects::SmartObject msg_params =
- smart_objects::SmartObject(smart_objects::SmartType_Map);
- msg_params[strings::cmd_id] = kCmdId;
- msg_params[strings::vr_commands] =
- smart_objects::SmartObject(smart_objects::SmartType_Array);
- msg_params[strings::vr_commands][0] = "lamer";
- msg_params[strings::type] = 34;
- msg_params[strings::grammar_id] = 12;
- msg_params[strings::app_id] = kAppId;
- (*msg)[strings::msg_params] = msg_params;
-
- return msg;
- }
-
- void FillMessageFieldsItem1(MessageSharedPtr message) {
- (*message)[am::strings::msg_params][am::strings::choice_set][0]
- [am::strings::menu_name] = kMenuName;
- (*message)[am::strings::msg_params][am::strings::choice_set][0]
- [am::strings::image][am::strings::value] = kImage;
- (*message)[am::strings::msg_params][am::strings::choice_set][0]
- [am::strings::choice_id] = kChoiceId1;
- (*message)[am::strings::msg_params][am::strings::choice_set][0]
- [am::strings::vr_commands][0] = kVrCommands1;
- (*message)[am::strings::msg_params][am::strings::choice_set][0]
- [am::strings::secondary_image][am::strings::value] = kSecondImage;
- }
- void FillMessageFieldsItem2(MessageSharedPtr message) {
- (*message)[am::strings::msg_params][am::strings::choice_set][1]
- [am::strings::choice_id] = kChoiceId2;
- (*message)[am::strings::msg_params][am::strings::choice_set][1]
- [am::strings::menu_name] = kMenuName;
- (*message)[am::strings::msg_params][am::strings::choice_set][1]
- [am::strings::vr_commands][0] = kVrCommands2;
- (*message)[am::strings::msg_params]
- [am::strings::interaction_choice_set_id] = kChoiceSetId;
- }
-
- MessageSharedPtr message_;
- CreateInteractionChoiceSetRequestPtr command_;
- MockAppPtr mock_app_;
- sync_primitives::Lock lock_;
-};
-
-class CreateInteractionChoiceSetResponseTest
- : public CommandsTest<CommandsTestMocks::kIsNice> {};
-
-TEST_F(CreateInteractionChoiceSetRequestTest, OnTimeout_GENERIC_ERROR) {
- MessageSharedPtr msg_vr = CreateMessage(smart_objects::SmartType_Map);
- (*msg_vr)[strings::msg_params][strings::result_code] =
- am::mobile_api::Result::GENERIC_ERROR;
- (*msg_vr)[strings::msg_params][strings::success] = false;
-
- utils::SharedPtr<CreateInteractionChoiceSetRequest> req_vr =
- CreateCommand<CreateInteractionChoiceSetRequest>();
-
- MockAppPtr mock_app = CreateMockApp();
- EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(mock_app));
- ON_CALL(*mock_app, app_id()).WillByDefault(Return(kConnectionKey));
- ON_CALL(*mock_app, get_grammar_id()).WillByDefault(Return(kConnectionKey));
- ON_CALL(*mock_app, RemoveCommand(_)).WillByDefault(Return());
-
- MessageSharedPtr vr_command_result;
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
- .WillOnce(DoAll(SaveArg<0>(&vr_command_result), Return(true)));
-
- req_vr->onTimeOut();
- EXPECT_EQ(
- (*vr_command_result)[strings::msg_params][strings::success].asBool(),
- false);
- EXPECT_EQ(
- (*vr_command_result)[strings::msg_params][strings::result_code].asInt(),
- static_cast<int32_t>(am::mobile_api::Result::GENERIC_ERROR));
-}
-
-TEST_F(CreateInteractionChoiceSetRequestTest, OnEvent_VR_UNSUPPORTED_RESOURCE) {
- MessageSharedPtr msg_vr = CreateFullParamsVRSO();
- (*msg_vr)[strings::msg_params][strings::choice_set][0][strings::choice_id] =
- 10;
- (*msg_vr)[strings::msg_params][strings::choice_set][0][strings::menu_name] =
- "menu_name";
- (*msg_vr)[strings::msg_params][strings::interaction_choice_set_id] = 11;
- utils::SharedPtr<CreateInteractionChoiceSetRequest> req_vr =
- CreateCommand<CreateInteractionChoiceSetRequest>(msg_vr);
-
- ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app_));
-
- smart_objects::SmartObject* null_obj = NULL;
- ON_CALL(*mock_app_, FindChoiceSet(_)).WillByDefault(Return(null_obj));
-
- MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
- (*msg)[strings::params][hmi_response::code] =
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
- (*msg)[strings::msg_params][strings::info] = "VR is not supported by system";
- (*msg)[strings::msg_params][strings::cmd_id] = kCommandId;
-
- am::event_engine::Event event(hmi_apis::FunctionID::VR_AddCommand);
- event.set_smart_object(*msg);
-
- smart_objects::SmartObject* ptr = NULL;
- ON_CALL(*mock_app_, FindCommand(kCmdId)).WillByDefault(Return(ptr));
- EXPECT_EQ(NULL, ptr);
-
- am::CommandsMap commands_map;
- ON_CALL(*mock_app_, commands_map())
- .WillByDefault(
- Return(DataAccessor<am::CommandsMap>(commands_map, lock_)));
-
- ON_CALL(mock_hmi_interfaces_, GetInterfaceFromFunction(_))
- .WillByDefault(
- Return(am::HmiInterfaces::HMI_INTERFACE_BasicCommunication));
-
- EXPECT_CALL(app_mngr_, ManageHMICommand(_)).WillOnce(Return(true));
-
- req_vr->Run();
-
- MessageSharedPtr vr_command_result;
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
- .WillOnce(DoAll(SaveArg<0>(&vr_command_result), Return(true)));
-
- req_vr->on_event(event);
-
- EXPECT_EQ(
- (*vr_command_result)[strings::msg_params][strings::success].asBool(),
- false);
- EXPECT_EQ(
- (*vr_command_result)[strings::msg_params][strings::result_code].asInt(),
- static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE));
- if ((*vr_command_result)[strings::msg_params].keyExists(strings::info)) {
- EXPECT_EQ(
- (*vr_command_result)[strings::msg_params][strings::info].asString(),
- (*msg)[strings::msg_params][strings::info].asString());
- }
-}
-
-TEST_F(CreateInteractionChoiceSetRequestTest, Run_InvalidApp_UNSUCCESS) {
- MockAppPtr invalid_app;
- EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(invalid_app));
- EXPECT_CALL(app_mngr_, GenerateGrammarID()).Times(0);
-
- command_->Run();
-}
-
-TEST_F(CreateInteractionChoiceSetRequestTest, Run_VerifyImageFail_UNSUCCESS) {
- (*message_)[am::strings::msg_params][am::strings::choice_set][0]
- [am::strings::image] = kImage;
- (*message_)[am::strings::msg_params][am::strings::choice_set][0]
- [am::strings::secondary_image] = kSecondImage;
-
- EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(mock_app_));
- EXPECT_CALL(mock_message_helper_, VerifyImage(_, _, _))
- .WillRepeatedly(Return(mobile_apis::Result::INVALID_DATA));
- EXPECT_CALL(app_mngr_, GenerateGrammarID()).Times(0);
-
- command_->Run();
-}
-
-TEST_F(CreateInteractionChoiceSetRequestTest, Run_FindChoiceSetFail_UNSUCCESS) {
- (*message_)[am::strings::msg_params][am::strings::choice_set][0]
- [am::strings::image] = kImage;
- (*message_)[am::strings::msg_params][am::strings::choice_set][0]
- [am::strings::secondary_image] = kSecondImage;
- (*message_)[am::strings::msg_params][am::strings::interaction_choice_set_id] =
- kChoiceSetId;
-
- EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(mock_app_));
- EXPECT_CALL(mock_message_helper_, VerifyImage(_, _, _))
- .WillRepeatedly(Return(mobile_apis::Result::SUCCESS));
-
- smart_objects::SmartObject* invalid_choice_set_id =
- &((*message_)[am::strings::msg_params]
- [am::strings::interaction_choice_set_id]);
- EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
- .WillOnce(Return(invalid_choice_set_id));
- EXPECT_CALL(app_mngr_, GenerateGrammarID()).Times(0);
- command_->Run();
-}
-
-TEST_F(CreateInteractionChoiceSetRequestTest,
- Run_CheckChoiceSet_InvalidChoiceId_UNSUCCESS) {
- (*message_)[am::strings::msg_params][am::strings::choice_set][0]
- [am::strings::menu_name] = kMenuName;
- (*message_)[am::strings::msg_params][am::strings::choice_set][0]
- [am::strings::image][am::strings::value] = kImage;
- (*message_)[am::strings::msg_params][am::strings::choice_set][0]
- [am::strings::choice_id] = kChoiceId1;
- (*message_)[am::strings::msg_params][am::strings::choice_set][0]
- [am::strings::secondary_image][am::strings::value] = kSecondImage;
- (*message_)[am::strings::msg_params][am::strings::choice_set][0]
- [am::strings::vr_commands][0] = kVrCommands1;
-
- FillMessageFieldsItem2(message_);
- (*message_)[am::strings::msg_params][am::strings::choice_set][1]
- [am::strings::vr_commands][0] = kVrCommands1;
- (*message_)[am::strings::msg_params][am::strings::choice_set][1]
- [am::strings::vr_commands][1] = " kVrCommands2\t";
- (*message_)[am::strings::msg_params][am::strings::choice_set][1]
- [am::strings::vr_commands][0] = kVrCommands1;
-
- EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(mock_app_));
-
- EXPECT_CALL(mock_message_helper_, VerifyImage(_, _, _))
- .WillRepeatedly(Return(mobile_apis::Result::SUCCESS));
-
- smart_objects::SmartObject* choice_set_id = NULL;
- EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
- .WillOnce(Return(choice_set_id));
-
- EXPECT_CALL(app_mngr_, GenerateGrammarID()).Times(0);
- command_->Run();
-}
-
-TEST_F(CreateInteractionChoiceSetRequestTest,
- Run_IsWhiteSpaceVRCommandsExist_InvalidMenuName_UNSUCCESS) {
- (*message_)[am::strings::msg_params][am::strings::choice_set][0]
- [am::strings::menu_name] = "menu_name\t";
- (*message_)[am::strings::msg_params][am::strings::choice_set][0]
- [am::strings::secondary_text] = "secondary_text\t";
- (*message_)[am::strings::msg_params][am::strings::choice_set][0]
- [am::strings::tertiary_text] = "tertiary_text\t";
- (*message_)[am::strings::msg_params][am::strings::choice_set][0]
- [am::strings::image][am::strings::value] = "image\t";
- (*message_)[am::strings::msg_params][am::strings::choice_set][0]
- [am::strings::choice_id] = kChoiceId1;
- (*message_)[am::strings::msg_params][am::strings::choice_set][0]
- [am::strings::secondary_image][am::strings::value] =
- "second_image\t";
- (*message_)[am::strings::msg_params][am::strings::choice_set][0]
- [am::strings::vr_commands][0] = "vr_commands_1\t";
-
- (*message_)[am::strings::msg_params][am::strings::interaction_choice_set_id] =
- kChoiceSetId;
-
- smart_objects::SmartObject* choice_set_id = NULL;
- EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
- .WillRepeatedly(Return(choice_set_id));
- EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(mock_app_));
-
- EXPECT_CALL(mock_message_helper_, VerifyImage(_, _, _))
- .WillRepeatedly(Return(mobile_apis::Result::SUCCESS));
-
- if ((*message_)[am::strings::msg_params][am::strings::choice_set][0]
- .keyExists(am::strings::menu_name)) {
- CreateInteractionChoiceSetRequestPtr command(
- CreateCommand<CreateInteractionChoiceSetRequest>(message_));
-
- EXPECT_CALL(app_mngr_, GenerateGrammarID()).Times(0);
- command->Run();
- }
- if ((*message_)[am::strings::msg_params][am::strings::choice_set][0]
- .keyExists(am::strings::secondary_text)) {
- (*message_)[am::strings::msg_params][am::strings::choice_set][0]
- [am::strings::menu_name] = kMenuName;
- CreateInteractionChoiceSetRequestPtr command(
- CreateCommand<CreateInteractionChoiceSetRequest>(message_));
-
- EXPECT_CALL(app_mngr_, GenerateGrammarID()).Times(0);
- command->Run();
- }
- if ((*message_)[am::strings::msg_params][am::strings::choice_set][0]
- .keyExists(am::strings::tertiary_text)) {
- (*message_)[am::strings::msg_params][am::strings::choice_set][0]
- [am::strings::secondary_text] = "secondary_text";
- CreateInteractionChoiceSetRequestPtr command(
- CreateCommand<CreateInteractionChoiceSetRequest>(message_));
-
- EXPECT_CALL(app_mngr_, GenerateGrammarID()).Times(0);
- command->Run();
- }
- if ((*message_)[am::strings::msg_params][am::strings::choice_set][0]
- .keyExists(am::strings::vr_commands)) {
- (*message_)[am::strings::msg_params][am::strings::choice_set][0]
- [am::strings::tertiary_text] = "tertiary_text";
- CreateInteractionChoiceSetRequestPtr command(
- CreateCommand<CreateInteractionChoiceSetRequest>(message_));
-
- EXPECT_CALL(app_mngr_, GenerateGrammarID()).Times(0);
- command->Run();
- }
- if ((*message_)[am::strings::msg_params][am::strings::choice_set][0]
- .keyExists(am::strings::image)) {
- (*message_)[am::strings::msg_params][am::strings::choice_set][0]
- [am::strings::vr_commands][0] = "vr_commands";
- CreateInteractionChoiceSetRequestPtr command(
- CreateCommand<CreateInteractionChoiceSetRequest>(message_));
-
- EXPECT_CALL(app_mngr_, GenerateGrammarID()).Times(0);
- command->Run();
- }
- if ((*message_)[am::strings::msg_params][am::strings::choice_set][0]
- .keyExists(am::strings::secondary_image)) {
- (*message_)[am::strings::msg_params][am::strings::choice_set][0]
- [am::strings::image][am::strings::value] = kImage;
- CreateInteractionChoiceSetRequestPtr command(
- CreateCommand<CreateInteractionChoiceSetRequest>(message_));
-
- EXPECT_CALL(app_mngr_, GenerateGrammarID()).Times(0);
- command->Run();
- }
-}
-
-TEST_F(CreateInteractionChoiceSetRequestTest,
- Run_ValidAmountVrCommands_SUCCESS) {
- FillMessageFieldsItem1(message_);
- FillMessageFieldsItem2(message_);
- EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(mock_app_));
-
- EXPECT_CALL(mock_message_helper_, VerifyImage(_, _, _))
- .WillRepeatedly(Return(mobile_apis::Result::SUCCESS));
-
- smart_objects::SmartObject* choice_set_id = NULL;
- EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
- .WillOnce(Return(choice_set_id));
-
- EXPECT_CALL(app_mngr_, GenerateGrammarID()).WillOnce(Return(kGrammarId));
- EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _));
- EXPECT_CALL(app_mngr_, GetNextHMICorrelationID())
- .Times(AtLeast(2))
- .WillOnce(Return(kConnectionKey))
- .WillOnce(Return(kConnectionKey));
- command_->Run();
-}
-
-TEST_F(CreateInteractionChoiceSetRequestTest,
- Run_EmptyAmountVrCommands_SUCCESS) {
- (*message_)[am::strings::msg_params][am::strings::choice_set][0]
- [am::strings::menu_name] = kMenuName;
- (*message_)[am::strings::msg_params][am::strings::choice_set][0]
- [am::strings::image][am::strings::value] = kImage;
- (*message_)[am::strings::msg_params][am::strings::choice_set][0]
- [am::strings::choice_id] = kChoiceId1;
- (*message_)[am::strings::msg_params][am::strings::choice_set][0]
- [am::strings::secondary_image][am::strings::value] = kSecondImage;
- (*message_)[am::strings::msg_params][am::strings::choice_set][0]
- [am::strings::vr_commands][0] = kVrCommands1;
- (*message_)[am::strings::msg_params][am::strings::choice_set][1]
- [am::strings::choice_id] = kChoiceId2;
- (*message_)[am::strings::msg_params][am::strings::choice_set][1]
- [am::strings::menu_name] = kMenuName;
- (*message_)[am::strings::msg_params][am::strings::interaction_choice_set_id] =
- kChoiceSetId;
- (*message_)[am::strings::msg_params][am::strings::choice_set][1]
- [am::strings::vr_commands][0] = kVrCommands2;
-
- EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(mock_app_));
-
- EXPECT_CALL(mock_message_helper_, VerifyImage(_, _, _))
- .WillRepeatedly(Return(mobile_apis::Result::SUCCESS));
-
- smart_objects::SmartObject* choice_set_id = NULL;
- EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
- .WillOnce(Return(choice_set_id));
-
- EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _));
- command_->Run();
-}
-
-TEST_F(CreateInteractionChoiceSetRequestTest,
- OnEvent_InvalidEventId_UNSUCCESS) {
- Event event(hmi_apis::FunctionID::INVALID_ENUM);
-
- EXPECT_CALL(app_mngr_, TerminateRequest(_, _, _)).Times(0);
- command_->on_event(event);
-}
-
-TEST_F(CreateInteractionChoiceSetRequestTest,
- OnEvent_InvalidVrCommand_UNSUCCESS) {
- (*message_)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::eType::WARNINGS;
- (*message_)[am::strings::params][am::strings::correlation_id] =
- kCorrelationId;
-
- Event event(hmi_apis::FunctionID::VR_AddCommand);
- event.set_smart_object(*message_);
-
- EXPECT_CALL(app_mngr_, TerminateRequest(_, _, _)).Times(0);
- command_->on_event(event);
-}
-
-TEST_F(CreateInteractionChoiceSetRequestTest, OnEvent_ValidVrNoError_SUCCESS) {
- Event event(hmi_apis::FunctionID::VR_AddCommand);
-
- (*message_)[am::strings::params][am::strings::correlation_id] =
- kCorrelationId;
- (*message_)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::eType::WARNINGS;
-
- FillMessageFieldsItem1(message_);
- FillMessageFieldsItem2(message_);
-
- EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(mock_app_));
-
- EXPECT_CALL(mock_message_helper_, VerifyImage(_, _, _))
- .WillRepeatedly(Return(mobile_apis::Result::SUCCESS));
-
- smart_objects::SmartObject* choice_set_id = NULL;
- EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
- .WillOnce(Return(choice_set_id));
-
- EXPECT_CALL(app_mngr_, GenerateGrammarID()).WillOnce(Return(kGrammarId));
- EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _));
- ON_CALL(app_mngr_, GetNextHMICorrelationID())
- .WillByDefault(Return(kCorrelationId));
- command_->Run();
-
- EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _));
- EXPECT_CALL(app_mngr_, TerminateRequest(_, _, _)).Times(0);
- event.set_smart_object(*message_);
-
- command_->on_event(event);
-}
-
-TEST_F(CreateInteractionChoiceSetRequestTest,
- OnEvent_InValidVrNoError_UNSUCCESS) {
- Event event(hmi_apis::FunctionID::VR_AddCommand);
-
- (*message_)[am::strings::params][am::strings::correlation_id] =
- kCorrelationId;
- (*message_)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::eType::INVALID_DATA;
-
- FillMessageFieldsItem1(message_);
- FillMessageFieldsItem2(message_);
- EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(mock_app_));
-
- EXPECT_CALL(mock_message_helper_, VerifyImage(_, _, _))
- .WillRepeatedly(Return(mobile_apis::Result::SUCCESS));
-
- smart_objects::SmartObject* choice_set_id = NULL;
- EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
- .WillOnce(Return(choice_set_id));
-
- EXPECT_CALL(app_mngr_, GenerateGrammarID()).WillOnce(Return(kGrammarId));
- EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _));
- ON_CALL(app_mngr_, GetNextHMICorrelationID())
- .WillByDefault(Return(kCorrelationId));
- command_->Run();
- EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _));
- EXPECT_CALL(app_mngr_, TerminateRequest(_, _, _)).Times(0);
- event.set_smart_object(*message_);
-
- command_->on_event(event);
-}
-
-TEST_F(CreateInteractionChoiceSetRequestTest,
- OnEvent_ValidVrNoErrorAndExpectedChoiceLessThanReceiveChoice_SUCCESS) {
- Event event(hmi_apis::FunctionID::VR_AddCommand);
-
- (*message_)[am::strings::params][am::strings::correlation_id] =
- kCorrelationId;
- (*message_)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::eType::WARNINGS;
-
- FillMessageFieldsItem1(message_);
-
- (*message_)[am::strings::msg_params][am::strings::interaction_choice_set_id] =
- kChoiceSetId;
- ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app_));
-
- EXPECT_CALL(mock_message_helper_, VerifyImage(_, _, _))
- .WillRepeatedly(Return(mobile_apis::Result::SUCCESS));
-
- smart_objects::SmartObject* choice_set_id = NULL;
- EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
- .WillOnce(Return(choice_set_id));
-
- EXPECT_CALL(app_mngr_, GenerateGrammarID()).WillOnce(Return(kGrammarId));
- EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _));
- ON_CALL(app_mngr_, GetNextHMICorrelationID())
- .WillByDefault(Return(kCorrelationId));
- command_->Run();
-
- FillMessageFieldsItem2(message_);
-
- EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _)).Times(0);
- EXPECT_CALL(app_mngr_, TerminateRequest(_, _, _));
- event.set_smart_object(*message_);
- command_->on_event(event);
-}
-
-TEST_F(CreateInteractionChoiceSetRequestTest,
- OnTimeOut_InvalidErrorFromHMI_UNSUCCESS) {
- EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(mock_app_));
-
- EXPECT_CALL(app_mngr_,
- ManageMobileCommand(
- MobileResultCodeIs(mobile_apis::Result::GENERIC_ERROR),
- am::commands::Command::ORIGIN_SDL));
-
- EXPECT_CALL(app_mngr_, TerminateRequest(_, _, _));
- command_->onTimeOut();
-}
-
-TEST_F(CreateInteractionChoiceSetRequestTest,
- OnTimeOut_ValidErrorFromHMI_SUCCESS) {
- (*message_)[am::strings::params][am::strings::correlation_id] =
- kCorrelationId;
- (*message_)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::eType::INVALID_ENUM;
-
- FillMessageFieldsItem1(message_);
- (*message_)[am::strings::msg_params][am::strings::interaction_choice_set_id] =
- kChoiceSetId;
-
- ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app_));
-
- EXPECT_CALL(mock_message_helper_, VerifyImage(_, _, _))
- .WillRepeatedly(Return(mobile_apis::Result::SUCCESS));
-
- smart_objects::SmartObject* choice_set_id = NULL;
- EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
- .WillOnce(Return(choice_set_id));
-
- EXPECT_CALL(app_mngr_, GenerateGrammarID()).WillOnce(Return(kGrammarId));
- EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _));
- ON_CALL(app_mngr_, GetNextHMICorrelationID())
- .WillByDefault(Return(kCorrelationId));
- command_->Run();
-
- FillMessageFieldsItem2(message_);
- EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _)).Times(0);
- EXPECT_CALL(app_mngr_, TerminateRequest(_, _, _));
- Event event(hmi_apis::FunctionID::VR_AddCommand);
- event.set_smart_object(*message_);
- command_->on_event(event);
-
- EXPECT_CALL(*mock_app_, RemoveChoiceSet(kChoiceSetId));
- EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0);
- EXPECT_CALL(app_mngr_, TerminateRequest(_, _, _));
- command_->onTimeOut();
-}
-
-TEST_F(CreateInteractionChoiceSetRequestTest, OnTimeOut_InvalidApp_UNSUCCESS) {
- (*message_)[am::strings::params][am::strings::correlation_id] =
- kCorrelationId;
- (*message_)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
- (*message_)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::eType::INVALID_ENUM;
-
- FillMessageFieldsItem1(message_);
- (*message_)[am::strings::msg_params][am::strings::interaction_choice_set_id] =
- kChoiceSetId;
-
- EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(mock_app_));
-
- EXPECT_CALL(mock_message_helper_, VerifyImage(_, _, _))
- .WillRepeatedly(Return(mobile_apis::Result::SUCCESS));
-
- smart_objects::SmartObject* choice_set_id = NULL;
- EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
- .WillOnce(Return(choice_set_id));
-
- EXPECT_CALL(app_mngr_, GenerateGrammarID()).WillOnce(Return(kGrammarId));
- EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _));
- ON_CALL(app_mngr_, GetNextHMICorrelationID())
- .WillByDefault(Return(kCorrelationId));
- command_->Run();
-
- FillMessageFieldsItem2(message_);
- EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _)).Times(0);
- EXPECT_CALL(app_mngr_, TerminateRequest(_, _, _)).Times(2);
- Event event(hmi_apis::FunctionID::VR_AddCommand);
- event.set_smart_object(*message_);
- command_->on_event(event);
-
- MockAppPtr invalid_app;
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(invalid_app));
- EXPECT_CALL(*mock_app_, RemoveChoiceSet(_)).Times(0);
- command_->onTimeOut();
-}
-
-TEST_F(CreateInteractionChoiceSetRequestTest,
- OnTimeOut_SuccessfulResponseReceived_UNSUCCESS) {
- (*message_)[am::strings::params][am::strings::correlation_id] =
- kCorrelationId;
- (*message_)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
- (*message_)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::eType::SUCCESS;
-
- FillMessageFieldsItem1(message_);
- (*message_)[am::strings::msg_params][am::strings::interaction_choice_set_id] =
- kChoiceSetId;
-
- EXPECT_CALL(mock_message_helper_, VerifyImage(_, _, _))
- .WillRepeatedly(Return(mobile_apis::Result::SUCCESS));
-
- smart_objects::SmartObject* choice_set_id = NULL;
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
- EXPECT_CALL(app_mngr_, GenerateGrammarID()).WillOnce(Return(kGrammarId));
- ON_CALL(app_mngr_, GetNextHMICorrelationID())
- .WillByDefault(Return(kCorrelationId));
-
- EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
- .WillOnce(Return(choice_set_id));
- EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _));
-
- command_->Run();
-
- FillMessageFieldsItem2(message_);
-
- EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _)).Times(0);
- EXPECT_CALL(app_mngr_, TerminateRequest(_, _, _));
-
- Event event(hmi_apis::FunctionID::VR_AddCommand);
- event.set_smart_object(*message_);
-
- command_->on_event(event);
-
- EXPECT_CALL(app_mngr_, TerminateRequest(_, _, _));
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
- EXPECT_CALL(*mock_app_, RemoveChoiceSet(_));
-
- command_->onTimeOut();
-}
-
-TEST_F(CreateInteractionChoiceSetResponseTest, Run_SuccessFalse_UNSUCCESS) {
- MessageSharedPtr message(CreateMessage());
- (*message)[am::strings::msg_params][am::strings::success] = false;
- (*message)[am::strings::msg_params][am::strings::result_code] =
- mobile_apis::Result::INVALID_ENUM;
- CreateInteractionChoiceSetResponsePtr command(
- CreateCommand<CreateInteractionChoiceSetResponse>(message));
-
- EXPECT_CALL(app_mngr_, SendMessageToMobile(message, false));
- command->Run();
-}
-
-TEST_F(CreateInteractionChoiceSetResponseTest, Run_SuccessTrue_SUCCESS) {
- MessageSharedPtr message(CreateMessage());
- (*message)[am::strings::msg_params][am::strings::success] = true;
- (*message)[am::strings::msg_params][am::strings::result_code] =
- mobile_apis::Result::SUCCESS;
- CreateInteractionChoiceSetResponsePtr command(
- CreateCommand<CreateInteractionChoiceSetResponse>(message));
-
- EXPECT_CALL(app_mngr_, SendMessageToMobile(message, false));
- command->Run();
-}
-
-TEST_F(CreateInteractionChoiceSetRequestTest, Run_ErrorFromHmiFalse_UNSUCCESS) {
- Event event(hmi_apis::FunctionID::VR_AddCommand);
-
- (*message_)[am::strings::params][am::strings::correlation_id] =
- kCorrelationId;
- (*message_)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::GENERIC_ERROR;
-
- FillMessageFieldsItem1(message_);
-
- (*message_)[am::strings::msg_params][am::strings::interaction_choice_set_id] =
- kChoiceSetId;
- ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app_));
-
- EXPECT_CALL(mock_message_helper_, VerifyImage(_, _, _))
- .WillRepeatedly(Return(mobile_apis::Result::GENERIC_ERROR));
-
- smart_objects::SmartObject* choice_set_id = NULL;
- EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
- .WillRepeatedly(Return(choice_set_id));
-
- EXPECT_CALL(app_mngr_, GenerateGrammarID())
- .WillRepeatedly(Return(kGrammarId));
- EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _)).Times(2);
- ON_CALL(app_mngr_, GetNextHMICorrelationID())
- .WillByDefault(Return(kCorrelationId));
- command_->Run();
-
- FillMessageFieldsItem2(message_);
-
- EXPECT_CALL(app_mngr_,
- ManageMobileCommand(
- MobileResultCodeIs(mobile_apis::Result::GENERIC_ERROR),
- am::commands::Command::ORIGIN_SDL));
- EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _)).Times(0);
- EXPECT_CALL(app_mngr_, TerminateRequest(_, _, _));
- event.set_smart_object(*message_);
- command_->on_event(event);
- command_->Run();
-}
-
-} // namespace create_interaction_choice_set_request
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace tests
diff --git a/src/components/application_manager/test/commands/mobile/delete_command_request_test.cc b/src/components/application_manager/test/commands/mobile/delete_command_request_test.cc
deleted file mode 100644
index c92ec81a1f..0000000000
--- a/src/components/application_manager/test/commands/mobile/delete_command_request_test.cc
+++ /dev/null
@@ -1,258 +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 "application_manager/commands/mobile/delete_command_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/test/include/application_manager/commands/command_request_test.h"
-#include "application_manager/mock_application_manager.h"
-#include "application_manager/mock_application.h"
-#include "application_manager/mock_message_helper.h"
-#include "application_manager/mock_hmi_interface.h"
-#include "application_manager/event_engine/event.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace delete_command_request {
-
-using ::testing::_;
-using ::testing::Return;
-using ::testing::ReturnRef;
-namespace am = ::application_manager;
-using am::commands::DeleteCommandRequest;
-using am::commands::MessageSharedPtr;
-using am::event_engine::Event;
-using am::MockMessageHelper;
-using am::MockHmiInterfaces;
-
-typedef SharedPtr<DeleteCommandRequest> DeleteCommandPtr;
-
-namespace {
-const int32_t kCommandId = 1;
-const uint32_t kAppId = 1u;
-const uint32_t kCmdId = 1u;
-const uint32_t kConnectionKey = 2u;
-} // namespace
-
-class DeleteCommandRequestTest
- : public CommandRequestTest<CommandsTestMocks::kIsNice> {
- public:
- DeleteCommandRequestTest() : mock_app_(CreateMockApp()) {}
- MessageSharedPtr CreateFullParamsUISO() {
- MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
- (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey;
- smart_objects::SmartObject menu_params =
- smart_objects::SmartObject(smart_objects::SmartType_Map);
- menu_params[am::strings::position] = 10;
- menu_params[am::strings::menu_name] = "LG";
-
- smart_objects::SmartObject msg_params =
- smart_objects::SmartObject(smart_objects::SmartType_Map);
- msg_params[am::strings::cmd_id] = kCmdId;
- msg_params[am::strings::menu_params] = menu_params;
- msg_params[am::strings::app_id] = kAppId;
- msg_params[am::strings::cmd_icon] = 1;
- msg_params[am::strings::cmd_icon][am::strings::value] = "10";
- (*msg)[am::strings::msg_params] = msg_params;
-
- return msg;
- }
-
- MessageSharedPtr CreateFullParamsVRSO() {
- MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
- (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey;
- smart_objects::SmartObject msg_params =
- smart_objects::SmartObject(smart_objects::SmartType_Map);
- msg_params[am::strings::cmd_id] = kCmdId;
- msg_params[am::strings::vr_commands] =
- smart_objects::SmartObject(smart_objects::SmartType_Array);
- msg_params[am::strings::vr_commands][0] = "lamer";
- msg_params[am::strings::type] = 34;
- msg_params[am::strings::grammar_id] = 12;
- msg_params[am::strings::app_id] = kAppId;
- (*msg)[am::strings::msg_params] = msg_params;
-
- return msg;
- }
-
- void ResultCommandExpectations(MessageSharedPtr msg,
- const std::string& info) {
- EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::success].asBool(),
- true);
- EXPECT_EQ(
- (*msg)[am::strings::msg_params][am::strings::result_code].asInt(),
- static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE));
- EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::info].asString(),
- info);
- }
-
- void SetUp() OVERRIDE {
- ON_CALL(app_mngr_, application(kConnectionKey))
- .WillByDefault(Return(mock_app_));
- ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey));
- ON_CALL(app_mngr_, hmi_interfaces())
- .WillByDefault(ReturnRef(hmi_interfaces_));
- }
-
- NiceMock<MockHmiInterfaces> hmi_interfaces_;
- MockAppPtr mock_app_;
-};
-
-TEST_F(DeleteCommandRequestTest,
- OnEvent_VrHmiSendUnsupportedResource_UNSUPPORTED_RESOURCE) {
- MessageSharedPtr command_msg = CreateFullParamsVRSO();
- (*command_msg)[am::strings::msg_params][am::strings::cmd_id] = kCommandId;
- (*command_msg)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
-
- DeleteCommandPtr command(CreateCommand<DeleteCommandRequest>(command_msg));
-
- ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app_));
-
- MessageSharedPtr test_msg(CreateMessage(smart_objects::SmartType_Map));
- (*test_msg)[am::strings::vr_commands] = 0;
- (*test_msg)[am::strings::menu_params] = 0;
-
- ON_CALL(hmi_interfaces_, GetInterfaceFromFunction(_))
- .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_VR));
- ON_CALL(hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
- .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
- ON_CALL(hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR))
- .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
- ON_CALL(*mock_app_, FindCommand(kCommandId))
- .WillByDefault(Return(test_msg.get()));
- ON_CALL(*mock_app_, get_grammar_id()).WillByDefault(Return(kConnectionKey));
-
- MessageSharedPtr msg(CreateMessage(smart_objects::SmartType_Map));
- (*msg)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::SUCCESS;
- Event event_ui(hmi_apis::FunctionID::UI_DeleteCommand);
- event_ui.set_smart_object(*msg);
- command->Init();
- command->Run();
- command->on_event(event_ui);
-
- MessageSharedPtr event_msg(CreateMessage(smart_objects::SmartType_Map));
- (*event_msg)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
- (*event_msg)[am::strings::msg_params][am::strings::info] =
- "VR is not supported by system";
- Event event_vr(hmi_apis::FunctionID::VR_DeleteCommand);
- event_vr.set_smart_object(*event_msg);
-
- EXPECT_CALL(*mock_app_, RemoveCommand(kCommandId));
-
- EXPECT_CALL(*mock_app_, UpdateHash());
-
- MessageSharedPtr vr_command_result;
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
- .WillOnce(DoAll(SaveArg<0>(&vr_command_result), Return(true)));
-
- command->on_event(event_vr);
-
- ResultCommandExpectations(vr_command_result, "VR is not supported by system");
-}
-
-TEST_F(DeleteCommandRequestTest,
- OnEvent_UIHmiSendUnsupportedResource_UNSUPPORTED_RESOURCE) {
- MessageSharedPtr command_msg = CreateFullParamsUISO();
- (*command_msg)[am::strings::msg_params][am::strings::cmd_id] = kCommandId;
- (*command_msg)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
-
- DeleteCommandPtr command(CreateCommand<DeleteCommandRequest>(command_msg));
-
- MockAppPtr app = CreateMockApp();
- ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app));
-
- MessageSharedPtr test_msg(CreateMessage(smart_objects::SmartType_Map));
- (*test_msg)[am::strings::vr_commands] = 0;
- (*test_msg)[am::strings::menu_params] = 0;
-
- ON_CALL(hmi_interfaces_, GetInterfaceFromFunction(_))
- .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
- ON_CALL(hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
- .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
- ON_CALL(hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR))
- .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
- ON_CALL(*app, FindCommand(kCommandId)).WillByDefault(Return(test_msg.get()));
- ON_CALL(*app, get_grammar_id()).WillByDefault(Return(kConnectionKey));
-
- MessageSharedPtr msg(CreateMessage(smart_objects::SmartType_Map));
- (*msg)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::SUCCESS;
- Event event_vr(hmi_apis::FunctionID::VR_DeleteCommand);
- event_vr.set_smart_object(*msg);
-
- command->Init();
- command->Run();
- command->on_event(event_vr);
-
- MessageSharedPtr event_msg(CreateMessage(smart_objects::SmartType_Map));
- (*event_msg)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
- (*event_msg)[am::strings::msg_params][am::strings::info] =
- "UI is not supported by system";
- Event event_ui(hmi_apis::FunctionID::UI_DeleteCommand);
- event_ui.set_smart_object(*event_msg);
-
- EXPECT_CALL(*app, RemoveCommand(kCommandId));
-
- EXPECT_CALL(*app, UpdateHash());
-
- MessageSharedPtr result_msg(
- CatchMobileCommandResult(CallOnEvent(*command, event_ui)));
-
- ASSERT_TRUE(result_msg);
-
- ResultCommandExpectations(result_msg, "UI is not supported by system");
-}
-
-} // namespace delete_command_request
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/delete_file_test.cc b/src/components/application_manager/test/commands/mobile/delete_file_test.cc
deleted file mode 100644
index 3692f7298e..0000000000
--- a/src/components/application_manager/test/commands/mobile/delete_file_test.cc
+++ /dev/null
@@ -1,246 +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 <vector>
-#include <string>
-#include <map>
-
-#include "mobile/delete_file_request.h"
-#include "mobile/delete_file_response.h"
-
-#include "gtest/gtest.h"
-#include "utils/shared_ptr.h"
-#include "utils/file_system.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/application.h"
-#include "application_manager/mock_application_manager.h"
-#include "application_manager/mock_application.h"
-#include "application_manager/mock_message_helper.h"
-#include "application_manager/event_engine/event.h"
-#include "application_manager/mock_hmi_capabilities.h"
-#include "application_manager/policies/mock_policy_handler_interface.h"
-#include "application_manager/mock_application_manager_settings.h"
-
-#include "interfaces/MOBILE_API.h"
-#include "application_manager/policies/policy_handler_interface.h"
-#include "application_manager/policies/policy_handler.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace delete_file {
-
-using ::testing::_;
-using ::testing::Test;
-using ::testing::Return;
-using ::testing::ReturnRef;
-using ::testing::SetArgReferee;
-using ::testing::AtLeast;
-namespace am = ::application_manager;
-using am::commands::DeleteFileRequest;
-using am::commands::DeleteFileResponse;
-using am::commands::MessageSharedPtr;
-using am::event_engine::Event;
-using am::MockMessageHelper;
-
-typedef SharedPtr<DeleteFileRequest> DeleteFileRequestPtr;
-typedef SharedPtr<DeleteFileResponse> DeleteFileResponsePtr;
-typedef NiceMock<
- ::test::components::application_manager_test::MockHMICapabilities>
- MockHMICapabilities;
-
-ACTION_TEMPLATE(SetArgPointer,
- HAS_1_TEMPLATE_PARAMS(int, k),
- AND_1_VALUE_PARAMS(vec)) {
- *std::tr1::get<k>(args) = *vec;
-}
-
-MATCHER_P(CheckMessageResultCode, result_code, "") {
- return (*arg)[am::strings::msg_params][am::strings::result_code].asInt() ==
- result_code;
-}
-
-namespace {
-const uint32_t kConnectionKey = 1u;
-const uint32_t kCorrelationId = 10u;
-const int32_t kMenuId = 5;
-} // namespace
-
-class DeleteFileRequestTest
- : public CommandRequestTest<CommandsTestMocks::kIsNice> {
- protected:
- void SetUp() OVERRIDE {
- message_ = CreateMessage();
- command_ = CreateCommand<DeleteFileRequest>(message_);
- mock_app_ = CreateMockApp();
- }
- DeleteFileRequestPtr command_;
- MessageSharedPtr message_;
- MockAppPtr mock_app_;
-};
-
-class DeleteFileResponseTest : public CommandsTest<CommandsTestMocks::kIsNice> {
-};
-
-TEST_F(DeleteFileRequestTest, Run_InvalidApp_UNSUCCESS) {
- MockAppPtr invalid_app;
- EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(invalid_app));
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL));
- EXPECT_CALL(app_mngr_, get_settings()).Times(0);
-
- command_->Run();
-}
-
-TEST_F(DeleteFileRequestTest, Run_HMILevelNone_UNSUCCESS) {
- (*message_)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
- EXPECT_CALL(*mock_app_, hmi_level())
- .WillOnce(Return(am::mobile_api::HMILevel::HMI_NONE));
-
- EXPECT_CALL(app_mngr_, get_settings())
- .WillOnce(ReturnRef(app_mngr_settings_));
- const uint32_t num = 0;
- EXPECT_CALL(app_mngr_settings_, delete_file_in_none())
- .WillOnce(ReturnRef(num));
- EXPECT_CALL(*mock_app_, delete_file_in_none_count()).WillOnce(Return(1));
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(CheckMessageResultCode(mobile_apis::Result::REJECTED),
- am::commands::Command::CommandOrigin::ORIGIN_SDL));
-
- command_->Run();
-}
-
-TEST_F(DeleteFileRequestTest, Run_ValidFileName_SUCCESS) {
- const std::string file_name = "test_file.txt";
- EXPECT_TRUE(file_system::CreateFile(file_name));
- (*message_)[am::strings::msg_params][am::strings::sync_file_name] = file_name;
- (*message_)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillRepeatedly(Return(mock_app_));
- EXPECT_CALL(*mock_app_, hmi_level())
- .WillOnce(Return(am::mobile_api::HMILevel::HMI_FULL));
-
- EXPECT_CALL(app_mngr_, get_settings())
- .WillOnce(ReturnRef(app_mngr_settings_));
- const std::string kFullFilePath = file_system::CurrentWorkingDirectory();
- EXPECT_CALL(app_mngr_settings_, app_storage_folder())
- .WillOnce(ReturnRef(kFullFilePath));
-
- am::AppFile file;
- file.file_name = file_name;
- file.file_type = mobile_apis::FileType::BINARY;
-
- EXPECT_CALL(*mock_app_, GetFile(_)).WillOnce(Return(&file));
- EXPECT_CALL(*mock_app_, DeleteFile(_));
- EXPECT_CALL(*mock_app_, increment_delete_file_in_none_count());
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(CheckMessageResultCode(mobile_apis::Result::SUCCESS),
- am::commands::Command::CommandOrigin::ORIGIN_SDL));
-
- command_->Run();
-}
-
-TEST_F(DeleteFileRequestTest, Run_InvalidFile_UNSUCCESS) {
- const std::string file_name = "test_file.txt";
- (*message_)[am::strings::msg_params][am::strings::sync_file_name] = file_name;
-
- EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(mock_app_));
- EXPECT_CALL(*mock_app_, hmi_level())
- .WillOnce(Return(am::mobile_api::HMILevel::HMI_FULL));
-
- EXPECT_CALL(app_mngr_, get_settings())
- .WillOnce(ReturnRef(app_mngr_settings_));
- const std::string kFullFilePath = file_system::CurrentWorkingDirectory();
- EXPECT_CALL(app_mngr_settings_, app_storage_folder())
- .WillOnce(ReturnRef(kFullFilePath));
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::REJECTED),
- am::commands::Command::CommandOrigin::ORIGIN_SDL));
- command_->Run();
-}
-
-TEST_F(DeleteFileResponseTest, Run_InvalidApp_UNSUCCESS) {
- MessageSharedPtr message = CreateMessage();
- (*message)[am::strings::params][am::strings::connection_key] = kConnectionKey;
- DeleteFileResponsePtr command = CreateCommand<DeleteFileResponse>(message);
- MockAppPtr invalid_app;
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(invalid_app));
- EXPECT_CALL(
- app_mngr_,
- SendMessageToMobile(CheckMessageResultCode(
- mobile_apis::Result::APPLICATION_NOT_REGISTERED),
- false));
-
- command->Run();
-}
-
-TEST_F(DeleteFileResponseTest, Run_ValidApp_SUCCESS) {
- MessageSharedPtr message = CreateMessage();
- (*message)[am::strings::params][am::strings::connection_key] = kConnectionKey;
- (*message)[am::strings::msg_params][am::strings::success] = true;
-
- DeleteFileResponsePtr command = CreateCommand<DeleteFileResponse>(message);
- MockAppPtr app(CreateMockApp());
- EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app));
- const uint32_t kAvailableDiskSpace = 10u;
- EXPECT_CALL(*app, GetAvailableDiskSpace())
- .WillOnce(Return(kAvailableDiskSpace));
-
- EXPECT_CALL(app_mngr_,
- SendMessageToMobile(
- CheckMessageResultCode(mobile_apis::Result::SUCCESS), _));
-
- command->Run();
-}
-
-} // namespace delete_file
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/delete_interaction_choice_set_test.cc b/src/components/application_manager/test/commands/mobile/delete_interaction_choice_set_test.cc
deleted file mode 100644
index 192cad12b0..0000000000
--- a/src/components/application_manager/test/commands/mobile/delete_interaction_choice_set_test.cc
+++ /dev/null
@@ -1,284 +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 <map>
-
-#include "mobile/delete_interaction_choice_set_request.h"
-#include "mobile/delete_interaction_choice_set_response.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_request_test.h"
-#include "application_manager/mock_application_manager.h"
-#include "application_manager/mock_application.h"
-#include "application_manager/event_engine/event.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace delete_interaction_choice_set {
-
-using ::testing::_;
-using ::testing::Return;
-using ::testing::InSequence;
-
-namespace am = ::application_manager;
-
-using am::commands::DeleteInteractionChoiceSetRequest;
-using am::commands::DeleteInteractionChoiceSetResponse;
-using am::commands::MessageSharedPtr;
-using am::event_engine::Event;
-
-typedef SharedPtr<DeleteInteractionChoiceSetRequest>
- DeleteInteractionChoiceSetRequestPtr;
-typedef SharedPtr<DeleteInteractionChoiceSetResponse>
- DeleteInteractionChoiceSetResponsePtr;
-
-MATCHER_P(CheckMessageSuccess, success, "") {
- return success ==
- (*arg)[am::strings::msg_params][am::strings::success].asBool();
-}
-
-namespace {
-const uint32_t kConnectionKey = 2u;
-const uint32_t kChoiceSetId = 11u;
-const uint32_t kChoiceId = 110u;
-const uint32_t kGrammarId = 101u;
-} // namespace
-
-class DeleteInteractionChoiceSetRequestTest
- : public CommandRequestTest<CommandsTestMocks::kIsNice> {
- public:
- DeleteInteractionChoiceSetRequestTest()
- : accessor_(choice_set_map_, performinteraction_choice_set_lock_) {}
-
- ~DeleteInteractionChoiceSetRequestTest() {
- // Fix DataAccessor release and WinQt crash
- Mock::VerifyAndClearExpectations(&app_mngr_);
- }
-
- am::PerformChoiceSetMap choice_set_map_;
- mutable sync_primitives::Lock performinteraction_choice_set_lock_;
- DataAccessor<am::PerformChoiceSetMap> accessor_;
-
- protected:
- void SetUp() OVERRIDE {
- message_ = CreateMessage();
- command_ = CreateCommand<DeleteInteractionChoiceSetRequest>(message_);
- app_ = CreateMockApp();
- }
-
- DeleteInteractionChoiceSetRequestPtr command_;
- MessageSharedPtr message_;
- MockAppPtr app_;
-};
-
-class DeleteInteractionChoiceSetResponseTest
- : public CommandsTest<CommandsTestMocks::kIsNice> {
- protected:
- void SetUp() OVERRIDE {
- message_ = CreateMessage();
- command_ = CreateCommand<DeleteInteractionChoiceSetResponse>(message_);
- app_ = CreateMockApp();
- }
- DeleteInteractionChoiceSetResponsePtr command_;
- MessageSharedPtr message_;
- MockAppPtr app_;
-};
-
-TEST_F(DeleteInteractionChoiceSetRequestTest, Run_InvalidApp_UNSUCCESS) {
- MockAppPtr invalid_app;
- EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(invalid_app));
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL));
- EXPECT_CALL(*app_, FindChoiceSet(_)).Times(0);
- command_->Run();
-}
-
-TEST_F(DeleteInteractionChoiceSetRequestTest, Run_FindChoiceSetFail_UNSUCCESS) {
- (*message_)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
- (*message_)[am::strings::msg_params][am::strings::interaction_choice_set_id] =
- kChoiceSetId;
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app_));
-
- smart_objects::SmartObject* choice_set_id = NULL;
- EXPECT_CALL(*app_, FindChoiceSet(kChoiceSetId))
- .WillOnce(Return(choice_set_id));
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL));
-
- command_->Run();
-}
-
-TEST_F(DeleteInteractionChoiceSetRequestTest, Run_ChoiceSetInUse_SUCCESS) {
- (*message_)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
- (*message_)[am::strings::msg_params][am::strings::interaction_choice_set_id] =
- kChoiceSetId;
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app_));
-
- smart_objects::SmartObject* choice_set_id =
- &((*message_)[am::strings::msg_params]
- [am::strings::interaction_choice_set_id]);
-
- choice_set_map_[0].insert(
- std::make_pair(kChoiceSetId,
- &((*message_)[am::strings::msg_params]
- [am::strings::interaction_choice_set_id])));
-
- EXPECT_CALL(*app_, FindChoiceSet(kChoiceSetId))
- .WillOnce(Return(choice_set_id));
- EXPECT_CALL(*app_, is_perform_interaction_active()).WillOnce(Return(true));
- EXPECT_CALL(*app_, performinteraction_choice_set_map())
- .WillOnce(Return(accessor_));
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL));
-
- command_->Run();
-}
-
-TEST_F(DeleteInteractionChoiceSetRequestTest,
- Run_SendVrDeleteCommand_PerformInteractionFalse_UNSUCCESS) {
- (*message_)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
- (*message_)[am::strings::msg_params][am::strings::interaction_choice_set_id] =
- kChoiceSetId;
- smart_objects::SmartObject* choice_set_id =
- &((*message_)[am::strings::msg_params]
- [am::strings::interaction_choice_set_id]);
- smart_objects::SmartObject* invalid_choice_set_id = NULL;
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillRepeatedly(Return(app_));
-
- InSequence seq;
-
- EXPECT_CALL(*app_, FindChoiceSet(kChoiceSetId))
- .WillOnce(Return(choice_set_id));
- EXPECT_CALL(*app_, is_perform_interaction_active()).WillOnce(Return(false));
- EXPECT_CALL(*app_, performinteraction_choice_set_map()).Times(0);
-
- EXPECT_CALL(*app_, FindChoiceSet(kChoiceSetId))
- .WillOnce(Return(invalid_choice_set_id));
-
- EXPECT_CALL(*app_, app_id()).WillOnce(Return(kConnectionKey));
- EXPECT_CALL(*app_, RemoveChoiceSet(kChoiceSetId));
- EXPECT_CALL(*app_, UpdateHash());
-
- DeleteInteractionChoiceSetRequestPtr command =
- CreateCommand<DeleteInteractionChoiceSetRequest>(message_);
-
- command->Init();
- command->Run();
-}
-
-TEST_F(DeleteInteractionChoiceSetRequestTest, Run_SendVrDeleteCommand_SUCCESS) {
- (*message_)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
- (*message_)[am::strings::msg_params][am::strings::interaction_choice_set_id] =
- kChoiceSetId;
- (*message_)[am::strings::msg_params][am::strings::grammar_id] = kGrammarId;
- (*message_)[am::strings::msg_params][am::strings::choice_set][0]
- [am::strings::choice_id] = kChoiceId;
- smart_objects::SmartObject* choice_set_id =
- &((*message_)[am::strings::msg_params]);
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillRepeatedly(Return(app_));
-
- InSequence seq;
-
- EXPECT_CALL(*app_, FindChoiceSet(kChoiceSetId))
- .WillOnce(Return(choice_set_id));
- EXPECT_CALL(*app_, is_perform_interaction_active()).WillOnce(Return(false));
- EXPECT_CALL(*app_, performinteraction_choice_set_map()).Times(0);
-
- EXPECT_CALL(*app_, FindChoiceSet(kChoiceSetId))
- .WillOnce(Return(choice_set_id));
-
- EXPECT_CALL(*app_, app_id())
- .WillOnce(Return(kConnectionKey))
- .WillOnce(Return(kConnectionKey));
- EXPECT_CALL(*app_, RemoveChoiceSet(kChoiceSetId));
- EXPECT_CALL(*app_, UpdateHash());
-
- DeleteInteractionChoiceSetRequestPtr command =
- CreateCommand<DeleteInteractionChoiceSetRequest>(message_);
-
- command->Init();
- command->Run();
-}
-
-TEST_F(DeleteInteractionChoiceSetResponseTest, Run_SuccessFalse_UNSUCCESS) {
- (*message_)[am::strings::msg_params][am::strings::success] = false;
-
- EXPECT_CALL(app_mngr_,
- SendMessageToMobile(CheckMessageSuccess(false), false));
- command_->Run();
-}
-
-TEST_F(DeleteInteractionChoiceSetResponseTest, Run_ValidResultCode_SUCCESS) {
- (*message_)[am::strings::msg_params][am::strings::result_code] =
- hmi_apis::Common_Result::SUCCESS;
-
- EXPECT_CALL(app_mngr_, SendMessageToMobile(CheckMessageSuccess(true), false));
- command_->Run();
-}
-
-TEST_F(DeleteInteractionChoiceSetResponseTest,
- Run_InvalidResultCode_UNSUCCESS) {
- (*message_)[am::strings::msg_params][am::strings::result_code] =
- hmi_apis::Common_Result::INVALID_ENUM;
-
- EXPECT_CALL(app_mngr_,
- SendMessageToMobile(CheckMessageSuccess(false), false));
- command_->Run();
-}
-
-} // namespace delete_interaction_choice_set
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/delete_sub_menu_test.cc b/src/components/application_manager/test/commands/mobile/delete_sub_menu_test.cc
deleted file mode 100644
index cc21e5366e..0000000000
--- a/src/components/application_manager/test/commands/mobile/delete_sub_menu_test.cc
+++ /dev/null
@@ -1,338 +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 "application_manager/commands/mobile/delete_sub_menu_request.h"
-#include "application_manager/commands/mobile/delete_sub_menu_response.h"
-
-#include "gtest/gtest.h"
-#include "application_manager/commands/command_request_test.h"
-#include "application_manager/mock_application_manager.h"
-#include "application_manager/mock_application.h"
-#include "application_manager/mock_message_helper.h"
-#include "application_manager/event_engine/event.h"
-#include "application_manager/mock_hmi_interface.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace delete_sub_menu_request {
-
-using ::testing::_;
-using ::testing::Return;
-using ::testing::ReturnRef;
-using ::testing::InSequence;
-namespace am = ::application_manager;
-using am::commands::MessageSharedPtr;
-using am::event_engine::Event;
-using am::MockHmiInterfaces;
-using am::MockMessageHelper;
-
-using am::commands::DeleteSubMenuRequest;
-using am::commands::DeleteSubMenuResponse;
-
-typedef SharedPtr<DeleteSubMenuRequest> DeleteSubMenuRequestPtr;
-typedef SharedPtr<DeleteSubMenuResponse> DeleteSubMenuResponsePtr;
-
-MATCHER_P(CheckMessageResultCode, result_code, "") {
- return (*arg)[am::strings::msg_params][am::strings::result_code].asInt() ==
- result_code;
-}
-
-MATCHER_P(CheckMessageConnectionKey, connection_key, "") {
- return (*arg)[am::strings::msg_params][am::strings::connection_key].asInt() ==
- connection_key;
-}
-
-ACTION_P(DeleteCommand, commands_map) {
- am::CommandsMap::iterator it = (*commands_map).begin();
- if ((*commands_map).end() != it) {
- (*commands_map).erase(it);
- }
-}
-
-namespace {
-const uint32_t kConnectionKey = 2u;
-const uint32_t kCorrelationId = 10u;
-const uint32_t kMenuId = 100u;
-const uint32_t kGrammarId = 101u;
-const int32_t kCmdId = 102;
-} // namespace
-
-class DeleteSubMenuRequestTest
- : public CommandRequestTest<CommandsTestMocks::kIsNice> {
- public:
- DeleteSubMenuRequestTest()
- : accessor_(commands_map_, commands_lock_)
- , message_(CreateMessage())
- , command_(CreateCommand<DeleteSubMenuRequest>(message_))
- , app_(CreateMockApp()) {}
-
- am::CommandsMap commands_map_;
- mutable sync_primitives::Lock commands_lock_;
- DataAccessor<am::CommandsMap> accessor_;
-
- MessageSharedPtr message_;
- DeleteSubMenuRequestPtr command_;
- MockAppPtr app_;
-};
-
-class DeleteSubMenuResponseTest
- : public CommandsTest<CommandsTestMocks::kIsNice> {};
-
-TEST_F(DeleteSubMenuRequestTest, DISABLED_OnEvent_UI_UNSUPPORTED_RESOURCE) {
- MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
- (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey;
- (*msg)[am::strings::msg_params][am::strings::menu_id] = 10u;
-
- utils::SharedPtr<DeleteSubMenuRequest> command =
- CreateCommand<DeleteSubMenuRequest>(msg);
-
- MockAppPtr mock_app = CreateMockApp();
- ON_CALL(app_mngr_, application(kConnectionKey))
- .WillByDefault(Return(mock_app));
- ON_CALL(*mock_app, app_id()).WillByDefault(Return(kConnectionKey));
- EXPECT_CALL(*mock_app, RemoveSubMenu(_));
-
- MessageSharedPtr ev_msg = CreateMessage(smart_objects::SmartType_Map);
- (*ev_msg)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
- (*ev_msg)[am::strings::msg_params][am::strings::info] = "info";
-
- Event event(hmi_apis::FunctionID::UI_DeleteSubMenu);
- event.set_smart_object(*ev_msg);
-
- MockHmiInterfaces hmi_interfaces;
- ON_CALL(app_mngr_, hmi_interfaces()).WillByDefault(ReturnRef(hmi_interfaces));
- EXPECT_CALL(hmi_interfaces,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
- .WillOnce(Return(am::HmiInterfaces::STATE_AVAILABLE));
-
- am::CommandsMap commands_map;
- smart_objects::SmartObject commands_msg(smart_objects::SmartType_Map);
- commands_map.insert(std::pair<uint32_t, SmartObject*>(1u, &commands_msg));
- sync_primitives::Lock lock;
- DataAccessor<am::CommandsMap> accessor(commands_map, lock);
- EXPECT_CALL(*mock_app, commands_map())
- .WillOnce(Return(accessor))
- .WillOnce(Return(accessor));
-
- MessageSharedPtr ui_command_result;
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
- .WillOnce(DoAll(SaveArg<0>(&ui_command_result), Return(true)));
-
- command->on_event(event);
-
- EXPECT_EQ((*ui_command_result)[am::strings::msg_params][am::strings::success]
- .asBool(),
- true);
- EXPECT_EQ(
- (*ui_command_result)[am::strings::msg_params][am::strings::result_code]
- .asInt(),
- static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE));
- if ((*ui_command_result)[am::strings::msg_params].keyExists(
- am::strings::info)) {
- EXPECT_FALSE(
- (*ui_command_result)[am::strings::msg_params][am::strings::info]
- .asString()
- .empty());
- }
-}
-
-TEST_F(DeleteSubMenuRequestTest, Run_InvalidApp_UNSUCCESS) {
- MockAppPtr invalid_app;
- EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(invalid_app));
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(CheckMessageResultCode(
- mobile_apis::Result::APPLICATION_NOT_REGISTERED),
- am::commands::Command::CommandOrigin::ORIGIN_SDL));
- EXPECT_CALL(*app_, FindSubMenu(_)).Times(0);
- command_->Run();
-}
-
-TEST_F(DeleteSubMenuRequestTest, Run_FindSubMenuFalse_UNSUCCESS) {
- (*message_)[am::strings::msg_params][am::strings::menu_id] = kMenuId;
- (*message_)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
-
- smart_objects::SmartObject* invalid_sub_menu = NULL;
- EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app_));
- EXPECT_CALL(*app_, FindSubMenu(kMenuId)).WillOnce(Return(invalid_sub_menu));
-
- EXPECT_CALL(app_mngr_,
- ManageMobileCommand(
- CheckMessageResultCode(mobile_apis::Result::INVALID_ID),
- am::commands::Command::CommandOrigin::ORIGIN_SDL));
- EXPECT_CALL(*app_, app_id()).Times(0);
- command_->Run();
-}
-
-TEST_F(DeleteSubMenuRequestTest, Run_SendHMIRequest_SUCCESS) {
- (*message_)[am::strings::msg_params][am::strings::menu_id] = kMenuId;
- (*message_)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
-
- smart_objects::SmartObject* sub_menu =
- &((*message_)[am::strings::msg_params][am::strings::menu_id]);
- EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app_));
- EXPECT_CALL(*app_, FindSubMenu(kMenuId)).WillOnce(Return(sub_menu));
-
- EXPECT_CALL(*app_, app_id()).WillOnce(Return(kConnectionKey));
- EXPECT_CALL(app_mngr_, GetNextHMICorrelationID())
- .WillOnce(Return(kCorrelationId));
-
- command_->Run();
-}
-
-TEST_F(DeleteSubMenuRequestTest, OnEvent_UnknownEventId_UNSUCCESS) {
- Event event(hmi_apis::FunctionID::INVALID_ENUM);
- EXPECT_CALL(app_mngr_, application(_)).Times(0);
- command_->on_event(event);
-}
-
-TEST_F(DeleteSubMenuRequestTest, OnEvent_InvalidApp_UNSUCCESS) {
- Event event(hmi_apis::FunctionID::UI_DeleteSubMenu);
- (*message_)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::eType::SUCCESS;
- event.set_smart_object(*message_);
- MockAppPtr invalid_app;
- EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(invalid_app));
- EXPECT_CALL(*app_, RemoveSubMenu(_)).Times(0);
- command_->on_event(event);
-}
-
-TEST_F(DeleteSubMenuRequestTest, OnEvent_DeleteSubmenu_SUCCESS) {
- Event event(hmi_apis::FunctionID::UI_DeleteSubMenu);
- (*message_)[am::strings::msg_params][am::strings::menu_id] = kMenuId;
- (*message_)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
- (*message_)[am::strings::msg_params][am::strings::vr_commands] =
- "vr_commands";
- (*message_)[am::strings::msg_params][am::strings::cmd_id] = kCmdId;
- (*message_)[am::strings::msg_params][am::strings::menu_params]
- [am::hmi_request::parent_id] = kMenuId;
- const hmi_apis::Common_Result::eType result_code =
- hmi_apis::Common_Result::SUCCESS;
- (*message_)[am::strings::params][am::hmi_response::code] = result_code;
- event.set_smart_object(*message_);
-
- commands_map_.insert(
- std::make_pair(0, &((*message_)[am::strings::msg_params])));
-
- EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(app_));
-
- InSequence seq;
- EXPECT_CALL(*app_, commands_map()).WillOnce(Return(accessor_));
- EXPECT_CALL(*app_, app_id()).WillOnce(Return(kConnectionKey));
- EXPECT_CALL(*app_, get_grammar_id()).WillOnce(Return(kGrammarId));
-
- EXPECT_CALL(*app_, commands_map()).WillOnce(Return(accessor_));
- EXPECT_CALL(*app_, app_id()).WillOnce(Return(kConnectionKey));
- EXPECT_CALL(*app_, RemoveCommand(_)).WillOnce(DeleteCommand(&commands_map_));
-
- EXPECT_CALL(*app_, RemoveSubMenu(_));
- EXPECT_CALL(*app_, UpdateHash());
-
- DeleteSubMenuRequestPtr command =
- CreateCommand<DeleteSubMenuRequest>(message_);
-
- command->Init();
- command->on_event(event);
-}
-
-TEST_F(DeleteSubMenuResponseTest, Run_SUCCESS) {
- MessageSharedPtr message(CreateMessage());
- (*message)[am::strings::msg_params][am::strings::connection_key] =
- kConnectionKey;
- DeleteSubMenuResponsePtr command(
- CreateCommand<DeleteSubMenuResponse>(message));
- EXPECT_CALL(
- app_mngr_,
- SendMessageToMobile(CheckMessageConnectionKey(kConnectionKey), _));
- command->Run();
-}
-
-TEST_F(DeleteSubMenuRequestTest,
- DeleteSubmenu_CommandhaventVrCommadsAndMenuParams_DontSendHMIRequest) {
- Event event(hmi_apis::FunctionID::UI_DeleteSubMenu);
- (*message_)[am::strings::msg_params][am::strings::menu_id] = kMenuId;
- (*message_)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
- (*message_)[am::strings::params][am::hmi_response::code] =
- am::mobile_api::Result::SUCCESS;
- event.set_smart_object(*message_);
-
- commands_map_.insert(
- std::make_pair(0, &((*message_)[am::strings::msg_params])));
-
- EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(app_));
- EXPECT_CALL(app_mngr_, ManageHMICommand(_)).Times(0);
- EXPECT_CALL(*app_, commands_map()).Times(2).WillRepeatedly(Return(accessor_));
- EXPECT_CALL(*app_, RemoveCommand(_)).Times(0);
-
- command_->on_event(event);
-}
-
-TEST_F(DeleteSubMenuRequestTest,
- DeleteSubmenu_NotAChildOfMenupartam_DontSendHMIRequest) {
- Event event(hmi_apis::FunctionID::UI_DeleteSubMenu);
- (*message_)[am::strings::msg_params][am::strings::menu_id] = kMenuId;
- (*message_)[am::strings::msg_params][am::strings::menu_params]
- [am::hmi_request::parent_id] = kMenuId + 1;
- (*message_)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
- (*message_)[am::strings::params][am::hmi_response::code] =
- am::mobile_api::Result::SUCCESS;
- event.set_smart_object(*message_);
-
- commands_map_.insert(
- std::make_pair(0, &((*message_)[am::strings::msg_params])));
-
- EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(app_));
- EXPECT_CALL(app_mngr_, ManageHMICommand(_)).Times(0);
- EXPECT_CALL(*app_, commands_map()).Times(2).WillRepeatedly(Return(accessor_));
- EXPECT_CALL(*app_, RemoveCommand(_)).Times(0);
-
- command_->on_event(event);
-}
-
-} // namespace delete_sub_menu_request
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/diagnostic_message_request_test.cc b/src/components/application_manager/test/commands/mobile/diagnostic_message_request_test.cc
deleted file mode 100644
index 4f46a6f715..0000000000
--- a/src/components/application_manager/test/commands/mobile/diagnostic_message_request_test.cc
+++ /dev/null
@@ -1,185 +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 "application_manager/test/include/application_manager/commands/commands_test.h"
-#include "application_manager/test/include/application_manager/commands/command_request_test.h"
-#include "application_manager/application.h"
-#include "application_manager/mock_application_manager.h"
-#include "application_manager/mock_application.h"
-#include "application_manager/event_engine/event.h"
-#include "application_manager/mock_message_helper.h"
-#include "application_manager/commands/mobile/diagnostic_message_request.h"
-#include "interfaces/MOBILE_API.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace diagnostic_message_request {
-
-using ::testing::_;
-using ::testing::Return;
-using ::testing::ReturnRef;
-namespace am = ::application_manager;
-using am::commands::MessageSharedPtr;
-using am::commands::DiagnosticMessageRequest;
-using am::event_engine::Event;
-namespace mobile_result = mobile_apis::Result;
-
-typedef SharedPtr<DiagnosticMessageRequest> DiagnosticMessageRequestPtr;
-
-namespace {
-const uint32_t kConnectionKey = 2u;
-const uint32_t kDiagnosticMode = 5u;
-} // namespace
-
-class DiagnosticMessageRequestTest
- : public CommandRequestTest<CommandsTestMocks::kIsNice> {};
-
-TEST_F(DiagnosticMessageRequestTest, Run_ApplicationIsNotRegistered_UNSUCCESS) {
- MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
- (*command_msg)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
-
- DiagnosticMessageRequestPtr command(
- CreateCommand<DiagnosticMessageRequest>(command_msg));
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(ApplicationSharedPtr()));
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(
- MobileResultCodeIs(mobile_result::APPLICATION_NOT_REGISTERED), _));
-
- command->Run();
-}
-
-TEST_F(DiagnosticMessageRequestTest, Run_NotSupportedDiagnosticMode_UNSUCCESS) {
- MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
- (*command_msg)[am::strings::msg_params][am::strings::message_data][0] =
- kDiagnosticMode;
- (*command_msg)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
-
- DiagnosticMessageRequestPtr command(
- CreateCommand<DiagnosticMessageRequest>(command_msg));
-
- MockAppPtr app(CreateMockApp());
- EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app));
-
- EXPECT_CALL(app_mngr_, get_settings())
- .WillOnce(ReturnRef(app_mngr_settings_));
-
- const std::vector<uint32_t> empty_supported_diag_modes;
- EXPECT_CALL(app_mngr_settings_, supported_diag_modes())
- .WillOnce(ReturnRef(empty_supported_diag_modes));
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(MobileResultCodeIs(mobile_result::REJECTED), _));
-
- command->Run();
-}
-
-TEST_F(DiagnosticMessageRequestTest, Run_SUCCESS) {
- MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
- (*command_msg)[am::strings::msg_params][am::strings::message_data][0] =
- kDiagnosticMode;
- (*command_msg)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
-
- DiagnosticMessageRequestPtr command(
- CreateCommand<DiagnosticMessageRequest>(command_msg));
-
- MockAppPtr app(CreateMockApp());
- EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app));
-
- EXPECT_CALL(app_mngr_, get_settings())
- .WillOnce(ReturnRef(app_mngr_settings_));
-
- std::vector<uint32_t> supported_diag_modes;
- supported_diag_modes.push_back(kDiagnosticMode);
-
- EXPECT_CALL(app_mngr_settings_, supported_diag_modes())
- .WillOnce(ReturnRef(supported_diag_modes));
-
- EXPECT_CALL(app_mngr_,
- ManageHMICommand(HMIResultCodeIs(
- hmi_apis::FunctionID::VehicleInfo_DiagnosticMessage)));
-
- command->Run();
-}
-
-TEST_F(DiagnosticMessageRequestTest, OnEvent_UNSUCCESS) {
- Event event(hmi_apis::FunctionID::INVALID_ENUM);
-
- DiagnosticMessageRequestPtr command(
- CreateCommand<DiagnosticMessageRequest>());
-
- EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0);
-
- command->on_event(event);
-}
-
-TEST_F(DiagnosticMessageRequestTest, OnEvent_SUCCESS) {
- Event event(hmi_apis::FunctionID::VehicleInfo_DiagnosticMessage);
-
- MessageSharedPtr event_message(CreateMessage(smart_objects::SmartType_Map));
- (*event_message)[am::strings::msg_params] = 0;
- (*event_message)[am::strings::params][am::hmi_response::code] =
- mobile_result::SUCCESS;
- event.set_smart_object(*event_message);
-
- DiagnosticMessageRequestPtr command(
- CreateCommand<DiagnosticMessageRequest>());
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(MobileResultCodeIs(mobile_result::SUCCESS), _));
-
- command->on_event(event);
-}
-
-} // namespace diagnostic_message_request
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/dial_number_request_test.cc b/src/components/application_manager/test/commands/mobile/dial_number_request_test.cc
deleted file mode 100644
index 33c84d305a..0000000000
--- a/src/components/application_manager/test/commands/mobile/dial_number_request_test.cc
+++ /dev/null
@@ -1,187 +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 "application_manager/test/include/application_manager/commands/commands_test.h"
-#include "application_manager/test/include/application_manager/commands/command_request_test.h"
-#include "application_manager/application.h"
-#include "application_manager/mock_application_manager.h"
-#include "application_manager/mock_application.h"
-#include "application_manager/event_engine/event.h"
-#include "application_manager/commands/mobile/dial_number_request.h"
-#include "interfaces/MOBILE_API.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace dial_number_request {
-
-using ::testing::_;
-using ::testing::Return;
-namespace am = ::application_manager;
-using am::commands::MessageSharedPtr;
-using am::commands::DialNumberRequest;
-using am::event_engine::Event;
-namespace mobile_result = mobile_apis::Result;
-
-typedef SharedPtr<DialNumberRequest> DialNumberRequestPtr;
-
-namespace {
-const uint32_t kConnectionKey = 2u;
-} // namespace
-
-class DialNumberRequestTest
- : public CommandRequestTest<CommandsTestMocks::kIsNice> {};
-
-TEST_F(DialNumberRequestTest, Run_ApplicationIsNotRegistered_UNSUCCESS) {
- DialNumberRequestPtr command(CreateCommand<DialNumberRequest>());
-
- EXPECT_CALL(app_mngr_, application(_))
- .WillOnce(Return(ApplicationSharedPtr()));
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(
- MobileResultCodeIs(mobile_result::APPLICATION_NOT_REGISTERED), _));
-
- command->Run();
-}
-
-TEST_F(DialNumberRequestTest, Run_InvalidNumber_UNSUCCESS) {
- MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
- (*command_msg)[am::strings::msg_params][am::strings::number] = "\t\n";
- (*command_msg)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
-
- DialNumberRequestPtr command(CreateCommand<DialNumberRequest>(command_msg));
-
- MockAppPtr app(CreateMockApp());
- EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app));
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(MobileResultCodeIs(mobile_result::INVALID_DATA), _));
-
- command->Run();
-}
-
-TEST_F(DialNumberRequestTest, Run_EmptyNumber_UNSUCCESS) {
- MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
- (*command_msg)[am::strings::msg_params][am::strings::number] = "NotANumber";
- (*command_msg)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
-
- DialNumberRequestPtr command(CreateCommand<DialNumberRequest>(command_msg));
-
- MockAppPtr app(CreateMockApp());
- EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app));
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(MobileResultCodeIs(mobile_result::INVALID_DATA), _));
-
- command->Run();
-}
-
-TEST_F(DialNumberRequestTest, 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;
-
- DialNumberRequestPtr command(CreateCommand<DialNumberRequest>(command_msg));
-
- MockAppPtr app(CreateMockApp());
- EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app));
-
- EXPECT_CALL(app_mngr_,
- ManageHMICommand(HMIResultCodeIs(
- hmi_apis::FunctionID::BasicCommunication_DialNumber)));
-
- command->Run();
-}
-
-TEST_F(DialNumberRequestTest, OnEvent_UnknownEvent_UNSUCCESS) {
- MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
- (*command_msg)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
-
- DialNumberRequestPtr command(CreateCommand<DialNumberRequest>(command_msg));
-
- MockAppPtr app(CreateMockApp());
- EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app));
-
- Event event(hmi_apis::FunctionID::INVALID_ENUM);
-
- EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0);
-
- command->on_event(event);
-}
-
-TEST_F(DialNumberRequestTest, OnEvent_SUCCESS) {
- MessageSharedPtr event_msg(CreateMessage(smart_objects::SmartType_Map));
- (*event_msg)[am::strings::params][am::hmi_response::code] =
- mobile_apis::Result::SUCCESS;
- (*event_msg)[am::strings::params][am::strings::info] = "test_info";
-
- Event event(hmi_apis::FunctionID::BasicCommunication_DialNumber);
- event.set_smart_object(*event_msg);
-
- MockAppPtr app(CreateMockApp());
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillRepeatedly(Return(app));
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS), _));
-
- MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
- (*command_msg)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
-
- DialNumberRequestPtr command(CreateCommand<DialNumberRequest>(command_msg));
- command->on_event(event);
-}
-
-} // namespace dial_number_request
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/dummy_mobile_commands_test.cc b/src/components/application_manager/test/commands/mobile/dummy_mobile_commands_test.cc
deleted file mode 100644
index 27a8499c09..0000000000
--- a/src/components/application_manager/test/commands/mobile/dummy_mobile_commands_test.cc
+++ /dev/null
@@ -1,342 +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 "commands/command_request_test.h"
-
-#include <stdint.h>
-#include <string>
-#include <vector>
-#include "gtest/gtest.h"
-
-#include "mobile/add_command_request.h"
-#include "mobile/add_command_response.h"
-#include "mobile/add_sub_menu_request.h"
-#include "mobile/add_sub_menu_response.h"
-#include "mobile/alert_maneuver_request.h"
-#include "mobile/alert_maneuver_response.h"
-#include "mobile/alert_request.h"
-#include "mobile/alert_response.h"
-#include "mobile/change_registration_request.h"
-#include "mobile/change_registration_response.h"
-#include "mobile/create_interaction_choice_set_request.h"
-#include "mobile/create_interaction_choice_set_response.h"
-#include "mobile/delete_command_request.h"
-#include "mobile/delete_command_response.h"
-#include "mobile/delete_file_request.h"
-#include "mobile/delete_file_response.h"
-#include "mobile/delete_interaction_choice_set_request.h"
-#include "mobile/delete_interaction_choice_set_response.h"
-#include "mobile/delete_sub_menu_request.h"
-#include "mobile/delete_sub_menu_response.h"
-#include "mobile/diagnostic_message_request.h"
-#include "mobile/diagnostic_message_response.h"
-#include "mobile/dial_number_request.h"
-#include "mobile/dial_number_response.h"
-#include "mobile/end_audio_pass_thru_request.h"
-#include "mobile/end_audio_pass_thru_response.h"
-#include "mobile/generic_response.h"
-#include "mobile/get_dtcs_request.h"
-#include "mobile/get_dtcs_response.h"
-#include "mobile/get_vehicle_data_request.h"
-#include "mobile/get_vehicle_data_response.h"
-#include "mobile/get_way_points_request.h"
-#include "mobile/get_way_points_response.h"
-#include "mobile/list_files_request.h"
-#include "mobile/list_files_response.h"
-#include "mobile/on_app_interface_unregistered_notification.h"
-#include "mobile/on_audio_pass_thru_notification.h"
-#include "mobile/on_button_event_notification.h"
-#include "mobile/on_button_press_notification.h"
-#include "mobile/on_command_notification.h"
-#include "mobile/on_driver_distraction_notification.h"
-#include "mobile/on_hash_change_notification.h"
-#include "mobile/on_hmi_status_notification.h"
-#include "mobile/on_hmi_status_notification_from_mobile.h"
-#include "mobile/on_keyboard_input_notification.h"
-#include "mobile/on_language_change_notification.h"
-#include "mobile/on_permissions_change_notification.h"
-#include "mobile/on_system_request_notification.h"
-#include "mobile/on_tbt_client_state_notification.h"
-#include "mobile/on_touch_event_notification.h"
-#include "mobile/on_vehicle_data_notification.h"
-#include "mobile/on_way_point_change_notification.h"
-#include "mobile/perform_audio_pass_thru_request.h"
-#include "mobile/perform_audio_pass_thru_response.h"
-#include "mobile/perform_interaction_request.h"
-#include "mobile/perform_interaction_response.h"
-#include "mobile/put_file_request.h"
-#include "mobile/put_file_response.h"
-#include "mobile/read_did_request.h"
-#include "mobile/read_did_response.h"
-#include "mobile/register_app_interface_request.h"
-#include "mobile/register_app_interface_response.h"
-#include "mobile/reset_global_properties_request.h"
-#include "mobile/reset_global_properties_response.h"
-#include "mobile/scrollable_message_request.h"
-#include "mobile/scrollable_message_response.h"
-#include "mobile/send_location_request.h"
-#include "mobile/send_location_response.h"
-#include "mobile/set_app_icon_request.h"
-#include "mobile/set_app_icon_response.h"
-#include "mobile/set_display_layout_request.h"
-#include "mobile/set_display_layout_response.h"
-#include "mobile/set_global_properties_request.h"
-#include "mobile/set_global_properties_response.h"
-#include "mobile/set_media_clock_timer_request.h"
-#include "mobile/set_media_clock_timer_response.h"
-#include "mobile/show_constant_tbt_request.h"
-#include "mobile/show_constant_tbt_response.h"
-#include "mobile/show_request.h"
-#include "mobile/show_response.h"
-#include "mobile/slider_request.h"
-#include "mobile/slider_response.h"
-#include "mobile/speak_request.h"
-#include "mobile/speak_response.h"
-#include "mobile/subscribe_button_request.h"
-#include "mobile/subscribe_button_response.h"
-#include "mobile/subscribe_vehicle_data_request.h"
-#include "mobile/subscribe_vehicle_data_response.h"
-#include "mobile/subscribe_way_points_request.h"
-#include "mobile/subscribe_way_points_response.h"
-#include "mobile/system_response.h"
-#include "mobile/unregister_app_interface_request.h"
-#include "mobile/unregister_app_interface_response.h"
-#include "mobile/unsubscribe_button_request.h"
-#include "mobile/unsubscribe_button_response.h"
-#include "mobile/unsubscribe_vehicle_data_request.h"
-#include "mobile/unsubscribe_vehicle_data_response.h"
-#include "mobile/unsubscribe_way_points_request.h"
-#include "mobile/unsubscribe_way_points_response.h"
-#include "mobile/update_turn_list_request.h"
-#include "mobile/update_turn_list_response.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 mobile_commands_test {
-namespace dummy_mobile_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;
-
-namespace {
-const std::string kEmptyString_ = "";
-} // namespace
-
-template <class Command>
-class MobileCommandsTest : public components::commands_test::CommandRequestTest<
- CommandsTestMocks::kIsNice> {
- public:
- typedef Command CommandType;
-
- void InitCommand(const uint32_t& timeout) OVERRIDE {
- 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_, app_icons_folder())
- .WillByDefault(ReturnRef(kEmptyString_));
- }
-};
-
-template <class Command>
-class MobileCommandsTestFirst : public MobileCommandsTest<Command> {
- public:
- using typename MobileCommandsTest<Command>::CommandType;
-};
-
-template <class Command>
-class MobileCommandsTestSecond : public MobileCommandsTest<Command> {
- public:
- using typename MobileCommandsTest<Command>::CommandType;
-};
-
-template <class Command>
-class MobileCommandsTestThird : public MobileCommandsTest<Command> {
- public:
- using typename MobileCommandsTest<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::AddCommandRequest,
- commands::AddCommandResponse,
- commands::AddSubMenuRequest,
- commands::AddSubMenuResponse,
- commands::AlertManeuverRequest,
- commands::AlertManeuverResponse,
- commands::AlertRequest,
- commands::AlertResponse,
- commands::ChangeRegistrationRequest,
- commands::ChangeRegistrationResponse,
- commands::CreateInteractionChoiceSetRequest,
- commands::CreateInteractionChoiceSetResponse,
- commands::DeleteCommandRequest,
- commands::DeleteCommandResponse,
- commands::DeleteFileRequest,
- commands::DeleteFileResponse,
- commands::DeleteInteractionChoiceSetRequest,
- commands::DeleteInteractionChoiceSetResponse,
- commands::DeleteSubMenuRequest,
- commands::DeleteSubMenuResponse,
- commands::DiagnosticMessageRequest,
- commands::DiagnosticMessageResponse,
- commands::DialNumberRequest,
- commands::DialNumberResponse,
- commands::EndAudioPassThruRequest,
- commands::EndAudioPassThruResponse,
- commands::GenericResponse,
- commands::GetDTCsRequest,
- commands::GetDTCsResponse,
- commands::GetVehicleDataRequest,
- commands::GetVehicleDataResponse,
- commands::GetWayPointsRequest,
- commands::GetWayPointsResponse,
- commands::ListFilesRequest,
- commands::ListFilesResponse,
- commands::OnAppInterfaceUnregisteredNotification,
- commands::OnAudioPassThruNotification,
- commands::mobile::OnButtonEventNotification,
- commands::mobile::OnButtonPressNotification,
- commands::OnCommandNotification,
- commands::mobile::OnDriverDistractionNotification,
- commands::mobile::OnHashChangeNotification,
- commands::OnHMIStatusNotification,
- commands::OnHMIStatusNotificationFromMobile,
- commands::mobile::OnKeyBoardInputNotification,
- commands::OnLanguageChangeNotification,
- commands::OnPermissionsChangeNotification,
- commands::mobile::OnSystemRequestNotification,
- commands::OnTBTClientStateNotification,
- commands::mobile::OnTouchEventNotification>
- MobileCommandsListFirst;
-
-typedef Types<commands::OnVehicleDataNotification,
- commands::OnWayPointChangeNotification,
- commands::PerformAudioPassThruRequest,
- commands::PerformAudioPassThruResponse,
- commands::PerformInteractionRequest,
- commands::PerformInteractionResponse,
- commands::PutFileRequest,
- commands::PutFileResponse,
- commands::ReadDIDRequest,
- commands::ReadDIDResponse,
- commands::RegisterAppInterfaceRequest,
- commands::RegisterAppInterfaceResponse,
- commands::ResetGlobalPropertiesRequest,
- commands::ResetGlobalPropertiesResponse,
- commands::ScrollableMessageRequest,
- commands::ScrollableMessageResponse,
- commands::SendLocationRequest,
- commands::SendLocationResponse,
- commands::SetAppIconRequest,
- commands::SetAppIconResponse,
- commands::SetDisplayLayoutRequest,
- commands::SetDisplayLayoutResponse,
- commands::SetGlobalPropertiesRequest,
- commands::SetGlobalPropertiesResponse,
- commands::SetMediaClockRequest,
- commands::SetMediaClockTimerResponse,
- commands::ShowConstantTBTRequest,
- commands::ShowConstantTBTResponse,
- commands::ShowRequest,
- commands::ShowResponse,
- commands::SliderRequest,
- commands::SliderResponse,
- commands::SpeakRequest,
- commands::SpeakResponse,
- commands::SubscribeButtonRequest,
- commands::SubscribeButtonResponse,
- commands::SubscribeVehicleDataRequest,
- commands::SubscribeVehicleDataResponse,
- commands::SubscribeWayPointsRequest,
- commands::SubscribeWayPointsResponse,
- commands::SystemResponse,
- commands::UnregisterAppInterfaceRequest,
- commands::UnregisterAppInterfaceResponse,
- commands::UnsubscribeButtonRequest,
- commands::UnsubscribeButtonResponse,
- commands::UnsubscribeVehicleDataRequest> MobileCommandsListSecond;
-
-typedef Types<commands::UnsubscribeVehicleDataResponse,
- commands::UnSubscribeWayPointsRequest,
- commands::UnsubscribeWayPointsResponse,
- commands::UpdateTurnListRequest,
- commands::UpdateTurnListResponse> MobileCommandsListThird;
-
-TYPED_TEST_CASE(MobileCommandsTestFirst, MobileCommandsListFirst);
-TYPED_TEST_CASE(MobileCommandsTestSecond, MobileCommandsListSecond);
-TYPED_TEST_CASE(MobileCommandsTestThird, MobileCommandsListThird);
-
-TYPED_TEST(MobileCommandsTestFirst, CtorAndDtorCall) {
- utils::SharedPtr<typename TestFixture::CommandType> command =
- this->template CreateCommand<typename TestFixture::CommandType>();
- UNUSED(command);
-}
-
-TYPED_TEST(MobileCommandsTestSecond, CtorAndDtorCall) {
- utils::SharedPtr<typename TestFixture::CommandType> command =
- this->template CreateCommand<typename TestFixture::CommandType>();
- UNUSED(command);
-}
-TYPED_TEST(MobileCommandsTestThird, CtorAndDtorCall) {
- utils::SharedPtr<typename TestFixture::CommandType> command =
- this->template CreateCommand<typename TestFixture::CommandType>();
- UNUSED(command);
-}
-
-} // namespace dummy_mobile_commands_test
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/end_audio_pass_thru_request_test.cc b/src/components/application_manager/test/commands/mobile/end_audio_pass_thru_request_test.cc
deleted file mode 100644
index 6b1d909121..0000000000
--- a/src/components/application_manager/test/commands/mobile/end_audio_pass_thru_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 <stdint.h>
-#include <string>
-#include <vector>
-
-#include "application_manager/commands/mobile/end_audio_pass_thru_request.h"
-
-#include "gtest/gtest.h"
-#include "application_manager/smart_object_keys.h"
-#include "application_manager/test/include/application_manager/commands/commands_test.h"
-#include "application_manager/test/include/application_manager/commands/command_request_test.h"
-#include "application_manager/mock_application_manager.h"
-#include "application_manager/event_engine/event.h"
-#include "application_manager/mock_message_helper.h"
-#include "application_manager/mock_hmi_interface.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace end_audio_pass_thru_request {
-
-namespace am = ::application_manager;
-using ::testing::_;
-using ::testing::Return;
-using ::testing::ReturnRef;
-using am::commands::MessageSharedPtr;
-using am::commands::EndAudioPassThruRequest;
-using am::event_engine::Event;
-using am::MockMessageHelper;
-
-typedef SharedPtr<EndAudioPassThruRequest> EndAudioPassThruRequestPtr;
-
-class EndAudioPassThruRequestTest
- : public CommandRequestTest<CommandsTestMocks::kIsNice> {};
-
-TEST_F(EndAudioPassThruRequestTest, OnEvent_UI_UNSUPPORTED_RESOUCRE) {
- const uint32_t kConnectionKey = 2u;
- const uint32_t app_id = kConnectionKey;
-
- MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
- (*command_msg)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
-
- EndAudioPassThruRequestPtr command(
- CreateCommand<EndAudioPassThruRequest>(command_msg));
-
- MessageSharedPtr event_msg(CreateMessage(smart_objects::SmartType_Map));
- (*event_msg)[am::strings::msg_params] = 0;
- (*event_msg)[am::strings::params][am::hmi_response::code] =
- mobile_apis::Result::UNSUPPORTED_RESOURCE;
-
- Event event(hmi_apis::FunctionID::UI_EndAudioPassThru);
- event.set_smart_object(*event_msg);
-
- EXPECT_CALL(app_mngr_, EndAudioPassThru(app_id)).WillOnce(Return(false));
-
- MessageSharedPtr ui_command_result;
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
- .WillOnce(DoAll(SaveArg<0>(&ui_command_result), Return(true)));
-
- MockAppPtr app(CreateMockApp());
- EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(app));
-
- command->on_event(event);
-
- EXPECT_EQ((*ui_command_result)[am::strings::msg_params][am::strings::success]
- .asBool(),
- true);
- EXPECT_EQ(
- (*ui_command_result)[am::strings::msg_params][am::strings::result_code]
- .asInt(),
- static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE));
- if ((*ui_command_result)[am::strings::msg_params].keyExists(
- am::strings::info)) {
- EXPECT_FALSE(
- (*ui_command_result)[am::strings::msg_params][am::strings::info]
- .asString()
- .empty());
- }
-}
-
-} // namespace end_audio_pass_thru_request
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/get_dtcs_request_test.cc b/src/components/application_manager/test/commands/mobile/get_dtcs_request_test.cc
deleted file mode 100644
index 106a59803b..0000000000
--- a/src/components/application_manager/test/commands/mobile/get_dtcs_request_test.cc
+++ /dev/null
@@ -1,142 +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 "application_manager/test/include/application_manager/commands/commands_test.h"
-#include "application_manager/test/include/application_manager/commands/command_request_test.h"
-#include "application_manager/application.h"
-#include "application_manager/mock_application_manager.h"
-#include "application_manager/mock_application.h"
-#include "application_manager/event_engine/event.h"
-#include "application_manager/commands/mobile/get_dtcs_request.h"
-#include "application_manager/mock_message_helper.h"
-#include "interfaces/MOBILE_API.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace get_dtcs_request {
-
-using ::testing::_;
-using ::testing::Return;
-namespace am = ::application_manager;
-using am::commands::MessageSharedPtr;
-using am::commands::GetDTCsRequest;
-using am::event_engine::Event;
-using am::MockMessageHelper;
-using testing::Mock;
-namespace mobile_result = mobile_apis::Result;
-
-typedef SharedPtr<GetDTCsRequest> GetDTCsRequestPtr;
-
-class GetDTCsRequestTest
- : public CommandRequestTest<CommandsTestMocks::kIsNice> {
- public:
- GetDTCsRequestTest() : CommandRequestTest<CommandsTestMocks::kIsNice>() {}
-};
-
-TEST_F(GetDTCsRequestTest, Run_ApplicationIsNotRegistered_UNSUCCESS) {
- GetDTCsRequestPtr command(CreateCommand<GetDTCsRequest>());
-
- EXPECT_CALL(app_mngr_, application(_))
- .WillOnce(Return(ApplicationSharedPtr()));
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(
- MobileResultCodeIs(mobile_result::APPLICATION_NOT_REGISTERED), _));
-
- command->Run();
-}
-
-TEST_F(GetDTCsRequestTest, Run_SUCCESS) {
- const uint32_t kConnectionKey = 2u;
- MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
- (*command_msg)[am::strings::msg_params][am::strings::dtc_mask] = 0;
- (*command_msg)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
-
- GetDTCsRequestPtr command(CreateCommand<GetDTCsRequest>(command_msg));
-
- MockAppPtr app(CreateMockApp());
- EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app));
-
- EXPECT_CALL(app_mngr_,
- ManageHMICommand(
- HMIResultCodeIs(hmi_apis::FunctionID::VehicleInfo_GetDTCs)));
-
- command->Run();
-}
-
-TEST_F(GetDTCsRequestTest, OnEvent_UnknownEvent_UNSUCCESS) {
- GetDTCsRequestPtr command(CreateCommand<GetDTCsRequest>());
-
- Event event(hmi_apis::FunctionID::INVALID_ENUM);
-
- EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0);
-
- command->on_event(event);
-}
-
-TEST_F(GetDTCsRequestTest, OnEvent_SUCCESS) {
- MessageSharedPtr event_msg(CreateMessage(smart_objects::SmartType_Map));
- (*event_msg)[am::strings::msg_params] = 0;
- (*event_msg)[am::strings::params][am::hmi_response::code] =
- mobile_apis::Result::SUCCESS;
-
- Event event(hmi_apis::FunctionID::VehicleInfo_GetDTCs);
- event.set_smart_object(*event_msg);
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS), _));
-
- MockAppPtr app(CreateMockApp());
- EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(app));
-
- GetDTCsRequestPtr command(CreateCommand<GetDTCsRequest>());
- command->on_event(event);
-}
-
-} // namespace get_dtcs_request
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/get_vehicle_data_request_test.cc b/src/components/application_manager/test/commands/mobile/get_vehicle_data_request_test.cc
deleted file mode 100644
index 52aed6feb8..0000000000
--- a/src/components/application_manager/test/commands/mobile/get_vehicle_data_request_test.cc
+++ /dev/null
@@ -1,254 +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 "application_manager/test/include/application_manager/commands/commands_test.h"
-#include "application_manager/test/include/application_manager/commands/command_request_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/commands/mobile/get_vehicle_data_request.h"
-#include "interfaces/MOBILE_API.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace get_vehicle_data_request {
-
-using ::testing::_;
-using ::testing::Return;
-using ::testing::ReturnRef;
-namespace am = ::application_manager;
-using am::commands::MessageSharedPtr;
-using am::commands::GetVehicleDataRequest;
-using am::event_engine::Event;
-namespace mobile_result = mobile_apis::Result;
-
-typedef SharedPtr<GetVehicleDataRequest> GetVehicleDataRequestPtr;
-
-namespace {
-const uint32_t kConnectionKey = 2u;
-} // namespace
-
-class GetVehicleDataRequestTest
- : public CommandRequestTest<CommandsTestMocks::kIsNice> {};
-
-class UnwrappedGetVehicleDataRequest : public GetVehicleDataRequest {
- public:
- UnwrappedGetVehicleDataRequest(const MessageSharedPtr& message,
- am::ApplicationManager& application_manager)
- : GetVehicleDataRequest(message, application_manager) {}
-
- policy::RPCParams& get_disallowed_params() {
- return removed_parameters_permissions_.disallowed_params;
- }
-
- using GetVehicleDataRequest::on_event;
-};
-
-#ifdef HMI_DBUS_API
-// HMI_DBUS_API currently not supported
-#else
-
-TEST_F(GetVehicleDataRequestTest, Run_ApplicationIsNotRegistered_UNSUCCESS) {
- GetVehicleDataRequestPtr command(CreateCommand<GetVehicleDataRequest>());
-
- EXPECT_CALL(app_mngr_, application(_))
- .WillOnce(Return(ApplicationSharedPtr()));
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(
- MobileResultCodeIs(mobile_result::APPLICATION_NOT_REGISTERED), _));
-
- command->Run();
-}
-
-TEST_F(GetVehicleDataRequestTest, Run_TooHighFrequency_UNSUCCESS) {
- const mobile_apis::FunctionID::eType kFunctionId =
- mobile_apis::FunctionID::GetVehicleDataID;
- MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
- (*command_msg)[am::strings::params][am::strings::function_id] = kFunctionId;
- (*command_msg)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
-
- GetVehicleDataRequestPtr command(
- CreateCommand<GetVehicleDataRequest>(command_msg));
-
- MockAppPtr app(CreateMockApp());
- EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app));
-
- EXPECT_CALL(
- *app,
- AreCommandLimitsExceeded(kFunctionId, am::TLimitSource::CONFIG_FILE))
- .WillOnce(Return(true));
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(MobileResultCodeIs(mobile_result::REJECTED), _));
-
- command->Run();
-}
-
-TEST_F(GetVehicleDataRequestTest, Run_EmptyMsgParams_UNSUCCESS) {
- MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
- (*command_msg)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
-
- GetVehicleDataRequestPtr command(
- CreateCommand<GetVehicleDataRequest>(command_msg));
-
- const am::VehicleData kEmptyVehicleData;
- EXPECT_CALL(mock_message_helper_, vehicle_data())
- .WillOnce(ReturnRef(kEmptyVehicleData));
-
- MockAppPtr app(CreateMockApp());
- EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app));
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(MobileResultCodeIs(mobile_result::INVALID_DATA), _));
-
- command->Run();
-}
-
-TEST_F(GetVehicleDataRequestTest,
- Run_EmptyMsgParamsAndHasDisallowedParams_UNSUCCESS) {
- MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
- (*command_msg)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
-
- SharedPtr<UnwrappedGetVehicleDataRequest> command(
- CreateCommand<UnwrappedGetVehicleDataRequest>(command_msg));
-
- const am::VehicleData kEmptyVehicleData;
- EXPECT_CALL(mock_message_helper_, vehicle_data())
- .WillRepeatedly(ReturnRef(kEmptyVehicleData));
-
- policy::RPCParams& disallowed_params = command->get_disallowed_params();
- disallowed_params.insert("test_param");
-
- MockAppPtr app(CreateMockApp());
- EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app));
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(MobileResultCodeIs(mobile_result::DISALLOWED), _));
-
- command->Run();
-}
-
-TEST_F(GetVehicleDataRequestTest, Run_SUCCESS) {
- const std::string kMsgParamKey("test_key");
-
- MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
- (*command_msg)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
- (*command_msg)[am::strings::msg_params][kMsgParamKey] = true;
-
- GetVehicleDataRequestPtr command(
- CreateCommand<GetVehicleDataRequest>(command_msg));
-
- am::VehicleData vehicle_data;
- vehicle_data.insert(am::VehicleData::value_type(
- kMsgParamKey, mobile_apis::VehicleDataType::VEHICLEDATA_SPEED));
- EXPECT_CALL(mock_message_helper_, vehicle_data())
- .WillOnce(ReturnRef(vehicle_data));
-
- MockAppPtr app(CreateMockApp());
- EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app));
-
- EXPECT_CALL(app_mngr_,
- ManageHMICommand(HMIResultCodeIs(
- hmi_apis::FunctionID::VehicleInfo_GetVehicleData)));
-
- command->Run();
-}
-
-TEST_F(GetVehicleDataRequestTest, OnEvent_UnknownEvent_UNSUCCESS) {
- MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
- (*command_msg)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
-
- SharedPtr<UnwrappedGetVehicleDataRequest> command(
- CreateCommand<UnwrappedGetVehicleDataRequest>(command_msg));
-
- Event event(hmi_apis::FunctionID::INVALID_ENUM);
-
- EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0);
-
- command->on_event(event);
-}
-
-TEST_F(GetVehicleDataRequestTest, OnEvent_DataNotAvailable_SUCCESS) {
- const hmi_apis::Common_Result::eType hmi_response_code =
- hmi_apis::Common_Result::DATA_NOT_AVAILABLE;
- const mobile_result::eType mobile_response_code =
- mobile_result::DATA_NOT_AVAILABLE;
-
- MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
- (*command_msg)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
-
- SharedPtr<UnwrappedGetVehicleDataRequest> command(
- CreateCommand<UnwrappedGetVehicleDataRequest>(command_msg));
-
- MessageSharedPtr event_msg(CreateMessage(smart_objects::SmartType_Map));
- (*event_msg)[am::strings::params][am::hmi_response::code] = hmi_response_code;
- (*event_msg)[am::strings::params][am::strings::error_msg] = "test_error";
- (*event_msg)[am::strings::msg_params][am::hmi_response::method] = 0;
-
- Event event(hmi_apis::FunctionID::VehicleInfo_GetVehicleData);
- event.set_smart_object(*event_msg);
- EXPECT_CALL(app_mngr_,
- ManageMobileCommand(MobileResultCodeIs(mobile_response_code), _));
-
- command->on_event(event);
-}
-
-#endif // HMI_DBUS_API
-
-} // namespace get_vehicle_data_request
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/get_way_points_request_test.cc b/src/components/application_manager/test/commands/mobile/get_way_points_request_test.cc
deleted file mode 100644
index 979fb0cc83..0000000000
--- a/src/components/application_manager/test/commands/mobile/get_way_points_request_test.cc
+++ /dev/null
@@ -1,284 +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 "commands/commands_test.h"
-#include "commands/command_request_test.h"
-#include "application_manager/application.h"
-#include "application_manager/mock_application_manager.h"
-#include "application_manager/mock_application.h"
-#include "mobile/get_way_points_request.h"
-#include "application_manager/smart_object_keys.h"
-#include "mock_message_helper.h"
-#include "interfaces/HMI_API.h"
-#include "interfaces/MOBILE_API.h"
-#include "application_manager/mock_hmi_interface.h"
-#include "application_manager/mock_message_helper.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace get_way_points_request {
-
-using namespace mobile_apis::Result;
-using ::testing::Return;
-using ::testing::_;
-using application_manager::commands::GetWayPointsRequest;
-using application_manager::MockMessageHelper;
-using application_manager::MockHmiInterfaces;
-
-typedef SharedPtr<GetWayPointsRequest> CommandPtr;
-typedef mobile_apis::Result::eType MobileResult;
-typedef hmi_apis::Common_Result::eType HmiResult;
-
-namespace {
-const uint32_t kCorrelationId = 2u;
-const uint32_t kAppId = 3u;
-const uint32_t kConnectionKey = kAppId;
-const std::string kMethodName = "Navigation.GetWayPoints";
-}
-
-class GetWayPointsRequestTest
- : public CommandRequestTest<CommandsTestMocks::kIsNice> {
- public:
- GetWayPointsRequestTest() : mock_app_(CreateMockApp()) {}
-
- void SetUp() OVERRIDE {
- message_ = utils::MakeShared<SmartObject>(::smart_objects::SmartType_Map);
- (*message_)[am::strings::msg_params] =
- ::smart_objects::SmartObject(::smart_objects::SmartType_Map);
-
- command_sptr_ =
- CreateCommand<application_manager::commands::GetWayPointsRequest>(
- message_);
- ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app_));
- }
-
- MockAppPtr mock_app_;
- MessageSharedPtr message_;
- utils::SharedPtr<application_manager::commands::GetWayPointsRequest>
- command_sptr_;
-};
-
-class GetWayPointsRequestOnEventTest
- : public CommandRequestTest<CommandsTestMocks::kIsNice> {
- public:
- GetWayPointsRequestOnEventTest() : app_(CreateMockApp()) {}
-
- void CheckOnEventResponse(const std::string& wayPointsParam,
- const HmiResult ResultCode,
- const bool success) {
- Event event(Event::EventID::Navigation_GetWayPoints);
- CommandPtr command(CreateCommand<GetWayPointsRequest>());
- MessageSharedPtr event_msg(CreateMessage(smart_objects::SmartType_Map));
- (*event_msg)[am::strings::params][am::hmi_response::code] = ResultCode;
- if ("0" == wayPointsParam) {
- (*event_msg)[am::strings::msg_params] = 0;
- } else {
- (*event_msg)[am::strings::msg_params][am::strings::way_points][0]["123"] =
- wayPointsParam;
- }
-
- event.set_smart_object(*event_msg);
-
- const MobileResult mobile_result = static_cast<MobileResult>(ResultCode);
-
- MessageSharedPtr result_msg(
- CatchMobileCommandResult(CallOnEvent(*command, event)));
- EXPECT_EQ(
- mobile_result,
- static_cast<MobileResult>(
- (*result_msg)[am::strings::msg_params][am::strings::result_code]
- .asInt()));
- EXPECT_EQ(
- success,
- (*result_msg)[am::strings::msg_params][am::strings::success].asBool());
- }
-
- protected:
- MockAppPtr app_;
- MockHmiInterfaces hmi_interfaces_;
-};
-
-TEST_F(GetWayPointsRequestTest,
- Run_InvalidApp_ApplicationNotRegisteredResponce) {
- (*message_)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
-
- utils::SharedPtr<am::Application> null_application_sptr;
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(null_application_sptr));
-
- CallRun caller(*command_sptr_);
-
- MessageSharedPtr result_message = CatchMobileCommandResult(caller);
-
- const mobile_apis::Result::eType result =
- static_cast<mobile_apis::Result::eType>(
- (*result_message)[am::strings::msg_params][am::strings::result_code]
- .asInt());
-
- EXPECT_EQ(mobile_apis::Result::APPLICATION_NOT_REGISTERED, result);
-}
-
-TEST_F(GetWayPointsRequestTest, Run_ApplicationRegistered_Success) {
- (*message_)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
-
- MockAppPtr application_sptr = CreateMockApp();
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(application_sptr));
- EXPECT_CALL(*application_sptr, app_id()).WillOnce(Return(1));
-
- EXPECT_CALL(app_mngr_, GetNextHMICorrelationID())
- .WillOnce(Return(kCorrelationId));
-
- CallRun caller(*command_sptr_);
-
- MessageSharedPtr result_message = CatchHMICommandResult(caller);
-
- const hmi_apis::FunctionID::eType result_function_id =
- static_cast<hmi_apis::FunctionID::eType>(
- (*result_message)[am::strings::params][am::strings::function_id]
- .asInt());
-
- EXPECT_EQ(hmi_apis::FunctionID::Navigation_GetWayPoints, result_function_id);
- EXPECT_EQ(kCorrelationId,
- (*result_message)[am::strings::params][am::strings::correlation_id]
- .asUInt());
-}
-
-TEST_F(GetWayPointsRequestTest,
- OnEvent_NavigationGetWayPointsEvent_SendResponse) {
- am::event_engine::Event event(hmi_apis::FunctionID::Navigation_GetWayPoints);
-
- (*message_)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::SUCCESS;
-
- event.set_smart_object(*message_);
-
- CallOnEvent caller(*command_sptr_, event);
-
- MessageSharedPtr result_message = CatchMobileCommandResult(caller);
-
- const mobile_apis::Result::eType result =
- static_cast<mobile_apis::Result::eType>(
- (*result_message)[am::strings::msg_params][am::strings::result_code]
- .asInt());
-
- EXPECT_EQ(mobile_apis::Result::SUCCESS, result);
-}
-
-TEST_F(GetWayPointsRequestTest, OnEvent_DefaultCase) {
- am::event_engine::Event event(hmi_apis::FunctionID::INVALID_ENUM);
-
- event.set_smart_object(*message_);
-
- EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _)).Times(0);
- EXPECT_CALL(app_mngr_, ManageHMICommand(_)).Times(0);
-
- CallOnEvent caller(*command_sptr_, event);
- caller();
-}
-
-TEST_F(GetWayPointsRequestOnEventTest, OnEvent_WrongEventId_UNSUCCESS) {
- Event event(Event::EventID::INVALID_ENUM);
- CommandPtr command(CreateCommand<GetWayPointsRequest>());
-
- EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0);
- command->on_event(event);
-}
-
-TEST_F(GetWayPointsRequestOnEventTest, OnEvent_Expect_SUCCESS_Case1) {
- CheckOnEventResponse("0", HmiResult::SUCCESS, true);
-}
-
-TEST_F(GetWayPointsRequestOnEventTest, OnEvent_Expect_SUCCESS_Case2) {
- CheckOnEventResponse("", HmiResult::SUCCESS, true);
-}
-
-TEST_F(GetWayPointsRequestOnEventTest, OnEvent_Expect_SUCCESS_Case3) {
- CheckOnEventResponse("test", HmiResult::SUCCESS, true);
-}
-
-TEST_F(GetWayPointsRequestOnEventTest, OnEvent_Expect_GENERIC_ERROR_Case1) {
- EXPECT_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
- .WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE));
- EXPECT_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_Navigation))
- .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
-
- CheckOnEventResponse(" ", HmiResult::GENERIC_ERROR, false);
-}
-
-TEST_F(GetWayPointsRequestOnEventTest, OnEvent_Expect_GENERIC_ERROR_Case2) {
- EXPECT_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
- .WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE));
- EXPECT_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_Navigation))
- .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
-
- CheckOnEventResponse("test\t", HmiResult::GENERIC_ERROR, false);
-}
-
-TEST_F(GetWayPointsRequestOnEventTest, OnEvent_Expect_GENERIC_ERROR_Case3) {
- EXPECT_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
- .WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE));
- EXPECT_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_Navigation))
- .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
-
- CheckOnEventResponse("test\n", HmiResult::GENERIC_ERROR, false);
-}
-
-TEST_F(GetWayPointsRequestOnEventTest, OnEvent_Expect_GENERIC_ERROR_Case4) {
- EXPECT_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
- .WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE));
- EXPECT_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_Navigation))
- .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
-
- CheckOnEventResponse("test\t\n", HmiResult::GENERIC_ERROR, false);
-}
-
-} // namespace get_way_points_request
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/list_files_request_test.cc b/src/components/application_manager/test/commands/mobile/list_files_request_test.cc
deleted file mode 100644
index ae0e523832..0000000000
--- a/src/components/application_manager/test/commands/mobile/list_files_request_test.cc
+++ /dev/null
@@ -1,145 +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/test/include/application_manager/commands/commands_test.h"
-#include "application_manager/test/include/application_manager/commands/command_request_test.h"
-#include "application_manager/application.h"
-#include "application_manager/mock_application_manager.h"
-#include "application_manager/mock_application.h"
-#include "application_manager/commands/mobile/list_files_request.h"
-#include "interfaces/MOBILE_API.h"
-#include "application_manager/smart_object_keys.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace list_files_request {
-
-using ::testing::_;
-using ::testing::Return;
-using ::testing::ReturnRef;
-using ::testing::DoAll;
-using ::testing::SaveArg;
-namespace am = ::application_manager;
-using am::commands::ListFilesRequest;
-using am::commands::MessageSharedPtr;
-
-class ListFilesRequestTest
- : public CommandRequestTest<CommandsTestMocks::kIsNice> {
- public:
- ListFilesRequestTest() : kStoragePath_("storage"), kResponseSize_(1) {}
- const std::string kStoragePath_;
- const uint32_t kResponseSize_;
-};
-
-TEST_F(ListFilesRequestTest, Run_AppNotRegistered_UNSUCCESS) {
- SharedPtr<ListFilesRequest> command(CreateCommand<ListFilesRequest>());
-
- ON_CALL(app_mngr_, application(_))
- .WillByDefault(Return(SharedPtr<am::Application>()));
-
- MessageSharedPtr result_msg(CatchMobileCommandResult(CallRun(*command)));
- EXPECT_EQ(mobile_apis::Result::APPLICATION_NOT_REGISTERED,
- static_cast<mobile_apis::Result::eType>(
- (*result_msg)[am::strings::msg_params][am::strings::result_code]
- .asInt()));
-}
-
-TEST_F(ListFilesRequestTest, Run_TooManyHmiNone_UNSUCCESS) {
- MockAppPtr app(CreateMockApp());
- SharedPtr<ListFilesRequest> command(CreateCommand<ListFilesRequest>());
-
- ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app));
- ON_CALL(*app, hmi_level())
- .WillByDefault(Return(mobile_apis::HMILevel::HMI_NONE));
-
- const uint32_t kListFilesInNoneAllowed = 1u;
- const uint32_t kListFilesInNoneCount = 2u;
-
- EXPECT_CALL(app_mngr_, get_settings())
- .WillOnce(ReturnRef(app_mngr_settings_));
- ON_CALL(app_mngr_settings_, list_files_in_none())
- .WillByDefault(ReturnRef(kListFilesInNoneAllowed));
- ON_CALL(*app, list_files_in_none_count())
- .WillByDefault(Return(kListFilesInNoneCount));
-
- MessageSharedPtr result_msg(CatchMobileCommandResult(CallRun(*command)));
- EXPECT_EQ(mobile_apis::Result::REJECTED,
- static_cast<mobile_apis::Result::eType>(
- (*result_msg)[am::strings::msg_params][am::strings::result_code]
- .asInt()));
-}
-
-TEST_F(ListFilesRequestTest, Run_SUCCESS) {
- MockAppPtr app(CreateMockApp());
- SharedPtr<ListFilesRequest> command(CreateCommand<ListFilesRequest>());
-
- EXPECT_CALL(app_mngr_, get_settings())
- .WillRepeatedly(ReturnRef(app_mngr_settings_));
-
- ON_CALL(app_mngr_settings_, app_storage_folder())
- .WillByDefault(ReturnRef(kStoragePath_));
-
- ON_CALL(app_mngr_settings_, list_files_response_size())
- .WillByDefault(ReturnRef(kResponseSize_));
-
- ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app));
-
- ON_CALL(*app, hmi_level())
- .WillByDefault(Return(mobile_apis::HMILevel::HMI_FULL));
-
- ON_CALL(*app, increment_list_files_in_none_count()).WillByDefault(Return());
-
- ON_CALL(*app, GetAvailableDiskSpace()).WillByDefault(Return(0));
-
- am::AppFilesMap files_map;
- ON_CALL(*app, getAppFiles()).WillByDefault(ReturnRef(files_map));
-
- MessageSharedPtr result_msg(CatchMobileCommandResult(CallRun(*command)));
- EXPECT_EQ(mobile_apis::Result::SUCCESS,
- static_cast<mobile_apis::Result::eType>(
- (*result_msg)[am::strings::msg_params][am::strings::result_code]
- .asInt()));
-}
-
-} // namespace list_files_request
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/on_button_notification_commands_test.cc b/src/components/application_manager/test/commands/mobile/on_button_notification_commands_test.cc
deleted file mode 100644
index 48f4497033..0000000000
--- a/src/components/application_manager/test/commands/mobile/on_button_notification_commands_test.cc
+++ /dev/null
@@ -1,355 +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/mock_application_manager.h"
-#include "application_manager/mock_application.h"
-
-#include "application_manager/include/application_manager/commands/command_impl.h"
-#include "application_manager/test/include/application_manager/commands/commands_test.h"
-#include "application_manager/test/include/application_manager/commands/command_request_test.h"
-#include "application_manager/commands/mobile/on_button_event_notification.h"
-#include "application_manager/commands/mobile/on_button_press_notification.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace on_button_notification {
-
-namespace am = ::application_manager;
-namespace commands = am::commands;
-
-using ::testing::_;
-using ::testing::Types;
-using ::testing::Return;
-
-using ::utils::SharedPtr;
-using am::commands::MessageSharedPtr;
-
-namespace {
-const uint32_t kAppId = 5u;
-const uint32_t kCustomButtonId = 3u;
-const mobile_apis::ButtonName::eType kButtonName = mobile_apis::ButtonName::OK;
-} // namespace
-
-template <class NotificationT,
- mobile_apis::FunctionID::eType kExpectedFunctionId>
-struct NotificationData {
- typedef NotificationT Notification;
- enum { kFunctionId = kExpectedFunctionId };
-};
-
-template <class NotificationDataT>
-class OnButtonNotificationCommandsTest
- : public CommandsTest<CommandsTestMocks::kNotNice>,
- public NotificationDataT {};
-
-typedef Types<NotificationData<commands::mobile::OnButtonEventNotification,
- mobile_apis::FunctionID::OnButtonEventID>,
- NotificationData<commands::mobile::OnButtonPressNotification,
- mobile_apis::FunctionID::OnButtonPressID> >
- OnButtonNotificationCommandsList;
-
-MATCHER_P(CheckNotificationMessage, function_id, "") {
- const bool kIsMobileProtocolTypeCorrect =
- (*arg)[am::strings::params][am::strings::protocol_type].asInt() ==
- commands::CommandImpl::mobile_protocol_type_;
-
- const bool kIsProtocolVersionCorrect =
- (*arg)[am::strings::params][am::strings::protocol_version].asInt() ==
- commands::CommandImpl::protocol_version_;
-
- const bool kIsNotificationCorrect =
- (*arg)[am::strings::params][am::strings::message_type].asInt() ==
- am::MessageType::kNotification;
-
- const bool kIsFunctionIdCorrect =
- (*arg)[am::strings::params][am::strings::function_id].asInt() ==
- function_id;
-
- bool is_custom_button_id_correct = true;
- if ((*arg)[am::strings::msg_params].keyExists(
- am::hmi_response::custom_button_id)) {
- is_custom_button_id_correct =
- (*arg)[am::strings::msg_params][am::strings::custom_button_id] ==
- kCustomButtonId;
- }
-
- return kIsMobileProtocolTypeCorrect && kIsProtocolVersionCorrect &&
- kIsNotificationCorrect && kIsFunctionIdCorrect &&
- is_custom_button_id_correct;
-}
-
-TYPED_TEST_CASE(OnButtonNotificationCommandsTest,
- OnButtonNotificationCommandsList);
-
-TYPED_TEST(OnButtonNotificationCommandsTest,
- Run_CustomButton_NoAppId_UNSUCCESS) {
- typedef typename TestFixture::Notification Notification;
-
- MessageSharedPtr notification_msg(
- this->CreateMessage(smart_objects::SmartType_Map));
-
- (*notification_msg)[am::strings::msg_params][am::hmi_response::button_name] =
- mobile_apis::ButtonName::CUSTOM_BUTTON;
-
- SharedPtr<Notification> command(
- this->template CreateCommand<Notification>(notification_msg));
-
- EXPECT_CALL(this->app_mngr_, SendMessageToMobile(_, _)).Times(0);
-
- command->Run();
-}
-
-TYPED_TEST(OnButtonNotificationCommandsTest,
- Run_CustomButton_NoCustomButtonId_UNSUCCESS) {
- typedef typename TestFixture::Notification Notification;
-
- MessageSharedPtr notification_msg(
- this->CreateMessage(smart_objects::SmartType_Map));
-
- (*notification_msg)[am::strings::msg_params][am::hmi_response::button_name] =
- mobile_apis::ButtonName::CUSTOM_BUTTON;
- (*notification_msg)[am::strings::msg_params][am::strings::app_id] = kAppId;
-
- SharedPtr<Notification> command(
- this->template CreateCommand<Notification>(notification_msg));
-
- typename TestFixture::MockAppPtr mock_app = this->CreateMockApp();
- EXPECT_CALL(this->app_mngr_, application(kAppId)).WillOnce(Return(mock_app));
-
- EXPECT_CALL(this->app_mngr_, SendMessageToMobile(_, _)).Times(0);
-
- command->Run();
-}
-
-TYPED_TEST(OnButtonNotificationCommandsTest,
- Run_CustomButton_AppNotRegistered_UNSUCCESS) {
- typedef typename TestFixture::Notification Notification;
-
- MessageSharedPtr notification_msg(
- this->CreateMessage(smart_objects::SmartType_Map));
-
- (*notification_msg)[am::strings::msg_params][am::hmi_response::button_name] =
- mobile_apis::ButtonName::CUSTOM_BUTTON;
- (*notification_msg)[am::strings::msg_params][am::strings::app_id] = kAppId;
- (*notification_msg)[am::strings::msg_params]
- [am::hmi_response::custom_button_id] = kCustomButtonId;
-
- SharedPtr<Notification> command(
- this->template CreateCommand<Notification>(notification_msg));
-
- EXPECT_CALL(this->app_mngr_, application(kAppId))
- .WillOnce(Return(ApplicationSharedPtr()));
-
- EXPECT_CALL(this->app_mngr_, SendMessageToMobile(_, _)).Times(0);
-
- command->Run();
-}
-
-TYPED_TEST(OnButtonNotificationCommandsTest,
- Run_CustomButton_AppNotSubscribedToCustomButtonId_UNSUCCESS) {
- typedef typename TestFixture::Notification Notification;
-
- MessageSharedPtr notification_msg(
- this->CreateMessage(smart_objects::SmartType_Map));
-
- (*notification_msg)[am::strings::msg_params][am::hmi_response::button_name] =
- mobile_apis::ButtonName::CUSTOM_BUTTON;
- (*notification_msg)[am::strings::msg_params][am::strings::app_id] = kAppId;
- (*notification_msg)[am::strings::msg_params]
- [am::hmi_response::custom_button_id] = kCustomButtonId;
-
- SharedPtr<Notification> command(
- this->template CreateCommand<Notification>(notification_msg));
-
- typename TestFixture::MockAppPtr mock_app = this->CreateMockApp();
- EXPECT_CALL(this->app_mngr_, application(kAppId)).WillOnce(Return(mock_app));
-
- EXPECT_CALL(*mock_app, IsSubscribedToSoftButton(kCustomButtonId))
- .WillOnce(Return(false));
-
- EXPECT_CALL(this->app_mngr_, SendMessageToMobile(_, _)).Times(0);
-
- command->Run();
-}
-
-TYPED_TEST(OnButtonNotificationCommandsTest, Run_CustomButton_SUCCESS) {
- typedef typename TestFixture::Notification Notification;
-
- MessageSharedPtr notification_msg(
- this->CreateMessage(smart_objects::SmartType_Map));
-
- (*notification_msg)[am::strings::msg_params][am::hmi_response::button_name] =
- mobile_apis::ButtonName::CUSTOM_BUTTON;
- (*notification_msg)[am::strings::msg_params][am::strings::app_id] = kAppId;
- (*notification_msg)[am::strings::msg_params]
- [am::hmi_response::custom_button_id] = kCustomButtonId;
-
- SharedPtr<Notification> command(
- this->template CreateCommand<Notification>(notification_msg));
-
- typename TestFixture::MockAppPtr mock_app = this->CreateMockApp();
- ON_CALL(*mock_app, hmi_level())
- .WillByDefault(Return(mobile_apis::HMILevel::HMI_FULL));
- EXPECT_CALL(this->app_mngr_, application(kAppId)).WillOnce(Return(mock_app));
- EXPECT_CALL(*mock_app, IsSubscribedToSoftButton(kCustomButtonId))
- .WillOnce(Return(true));
-
- EXPECT_CALL(this->app_mngr_,
- SendMessageToMobile(
- CheckNotificationMessage(TestFixture::kFunctionId), _));
-
- command->Run();
-}
-
-TYPED_TEST(OnButtonNotificationCommandsTest, Run_NoSubscribedApps_UNSUCCESS) {
- typedef typename TestFixture::Notification Notification;
-
- MessageSharedPtr notification_msg(
- this->CreateMessage(smart_objects::SmartType_Map));
-
- (*notification_msg)[am::strings::msg_params][am::hmi_response::button_name] =
- kButtonName;
-
- SharedPtr<Notification> command(
- this->template CreateCommand<Notification>(notification_msg));
-
- const std::vector<ApplicationSharedPtr> empty_subscribed_apps_list;
- EXPECT_CALL(this->app_mngr_, applications_by_button(kButtonName))
- .WillOnce(Return(empty_subscribed_apps_list));
-
- EXPECT_CALL(this->app_mngr_, SendMessageToMobile(_, _)).Times(0);
-
- command->Run();
-}
-
-TYPED_TEST(OnButtonNotificationCommandsTest, Run_InvalidHmiLevel_UNSUCCESS) {
- typedef typename TestFixture::Notification Notification;
-
- MessageSharedPtr notification_msg(
- this->CreateMessage(smart_objects::SmartType_Map));
-
- (*notification_msg)[am::strings::msg_params][am::hmi_response::button_name] =
- kButtonName;
-
- SharedPtr<Notification> command(
- this->template CreateCommand<Notification>(notification_msg));
-
- typename TestFixture::MockAppPtr mock_app = this->CreateMockApp();
- std::vector<ApplicationSharedPtr> subscribed_apps_list;
- subscribed_apps_list.push_back(mock_app);
-
- EXPECT_CALL(*mock_app, hmi_level())
- .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_NONE));
-
- EXPECT_CALL(this->app_mngr_, applications_by_button(kButtonName))
- .WillOnce(Return(subscribed_apps_list));
-
- EXPECT_CALL(this->app_mngr_, SendMessageToMobile(_, _)).Times(0);
-
- command->Run();
-}
-
-TYPED_TEST(OnButtonNotificationCommandsTest,
- Run_ButtonOkOnlyForHmiLevelFull_UNSUCCESS) {
- typedef typename TestFixture::Notification Notification;
-
- MessageSharedPtr notification_msg(
- this->CreateMessage(smart_objects::SmartType_Map));
-
- (*notification_msg)[am::strings::msg_params][am::hmi_response::button_name] =
- kButtonName;
-
- SharedPtr<Notification> command(
- this->template CreateCommand<Notification>(notification_msg));
-
- typename TestFixture::MockAppPtr mock_app = this->CreateMockApp();
- std::vector<ApplicationSharedPtr> subscribed_apps_list;
- subscribed_apps_list.push_back(mock_app);
-
- EXPECT_CALL(*mock_app, hmi_level())
- .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_LIMITED));
-
- EXPECT_CALL(this->app_mngr_, applications_by_button(kButtonName))
- .WillOnce(Return(subscribed_apps_list));
-
- EXPECT_CALL(this->app_mngr_, SendMessageToMobile(_, _)).Times(0);
-
- command->Run();
-}
-
-TYPED_TEST(OnButtonNotificationCommandsTest, Run_SUCCESS) {
- typedef typename TestFixture::Notification Notification;
-
- MessageSharedPtr notification_msg(
- this->CreateMessage(smart_objects::SmartType_Map));
-
- (*notification_msg)[am::strings::msg_params][am::strings::app_id] = kAppId;
- (*notification_msg)[am::strings::msg_params][am::hmi_response::button_name] =
- kButtonName;
-
- SharedPtr<Notification> command(
- this->template CreateCommand<Notification>(notification_msg));
-
- typename TestFixture::MockAppPtr mock_app = this->CreateMockApp();
- std::vector<ApplicationSharedPtr> subscribed_apps_list;
- subscribed_apps_list.push_back(mock_app);
-
- EXPECT_CALL(*mock_app, hmi_level())
- .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_FULL));
-
- ON_CALL(*mock_app, IsFullscreen()).WillByDefault(Return(true));
-
- EXPECT_CALL(this->app_mngr_, applications_by_button(kButtonName))
- .WillOnce(Return(subscribed_apps_list));
-
- EXPECT_CALL(this->app_mngr_,
- SendMessageToMobile(
- CheckNotificationMessage(TestFixture::kFunctionId), _));
-
- command->Run();
-}
-
-} // namespace on_button_notification
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/on_command_notification_test.cc b/src/components/application_manager/test/commands/mobile/on_command_notification_test.cc
deleted file mode 100644
index def324bfb6..0000000000
--- a/src/components/application_manager/test/commands/mobile/on_command_notification_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 <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/commands_test.h"
-#include "application_manager/commands/command_impl.h"
-#include "application_manager/commands/mobile/on_command_notification.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace on_command_notification {
-
-namespace am = ::application_manager;
-
-using ::testing::_;
-using ::testing::Return;
-
-using am::commands::MessageSharedPtr;
-using am::commands::OnCommandNotification;
-
-typedef ::utils::SharedPtr<OnCommandNotification> CommandPtr;
-
-namespace {
-const uint32_t kAppId = 1u;
-const uint32_t kCommandId = 5u;
-} // namespace
-
-class OnCommandNotificationTest
- : public CommandsTest<CommandsTestMocks::kNotNice> {};
-
-TEST_F(OnCommandNotificationTest, Run_AppNotRegistered_UNSUCCESS) {
- CommandPtr command(CreateCommand<OnCommandNotification>());
-
- EXPECT_CALL(app_mngr_, application(_))
- .WillOnce(Return(ApplicationSharedPtr()));
-
- EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0);
-
- command->Run();
-}
-
-TEST_F(OnCommandNotificationTest, Run_NoAppsForTheCommand_UNSUCCESS) {
- MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
- (*command_msg)[am::strings::msg_params][am::strings::app_id] = kAppId;
- (*command_msg)[am::strings::msg_params][am::strings::cmd_id] = kCommandId;
-
- CommandPtr command(CreateCommand<OnCommandNotification>(command_msg));
-
- MockAppPtr mock_app(CreateMockApp());
- EXPECT_CALL(app_mngr_, application(kAppId)).WillOnce(Return(mock_app));
-
- EXPECT_CALL(*mock_app, FindCommand(kCommandId))
- .WillOnce(Return(static_cast<SmartObject*>(NULL)));
-
- EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0);
-
- command->Run();
-}
-
-MATCHER(CheckNotificationMessage, "") {
- const bool kIsMobileProtocolTypeCorrect =
- (*arg)[am::strings::params][am::strings::protocol_type].asInt() ==
- am::commands::CommandImpl::mobile_protocol_type_;
-
- const bool kIsProtocolVersionCorrect =
- (*arg)[am::strings::params][am::strings::protocol_version].asInt() ==
- am::commands::CommandImpl::protocol_version_;
-
- const bool kIsNotificationCorrect =
- (*arg)[am::strings::params][am::strings::message_type].asInt() ==
- am::MessageType::kNotification;
-
- return kIsMobileProtocolTypeCorrect && kIsProtocolVersionCorrect &&
- kIsNotificationCorrect;
-}
-
-TEST_F(OnCommandNotificationTest, Run_SUCCESS) {
- MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
- (*command_msg)[am::strings::msg_params][am::strings::app_id] = kAppId;
- (*command_msg)[am::strings::msg_params][am::strings::cmd_id] = kCommandId;
-
- CommandPtr command(CreateCommand<OnCommandNotification>(command_msg));
-
- MockAppPtr mock_app(CreateMockApp());
- EXPECT_CALL(app_mngr_, application(kAppId)).WillOnce(Return(mock_app));
-
- MessageSharedPtr dummy_msg(CreateMessage());
- EXPECT_CALL(*mock_app, FindCommand(kCommandId))
- .WillOnce(Return(dummy_msg.get()));
-
- EXPECT_CALL(app_mngr_, SendMessageToMobile(CheckNotificationMessage(), _));
-
- command->Run();
-}
-
-} // namespace on_command_notification
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/on_hash_change_notification_test.cc b/src/components/application_manager/test/commands/mobile/on_hash_change_notification_test.cc
deleted file mode 100644
index 6d7ccb1fa0..0000000000
--- a/src/components/application_manager/test/commands/mobile/on_hash_change_notification_test.cc
+++ /dev/null
@@ -1,117 +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/mobile/on_hash_change_notification.h"
-#include "application_manager/mock_message_helper.h"
-#include "application_manager/smart_object_keys.h"
-#include "application_manager/commands/command_impl.h"
-#include "application_manager/test/include/application_manager/commands/commands_test.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace on_hash_change_notification {
-
-namespace strings = application_manager::strings;
-
-using application_manager::commands::mobile::OnHashChangeNotification;
-using application_manager::MockMessageHelper;
-using application_manager::commands::CommandImpl;
-using testing::Mock;
-using testing::Return;
-using testing::ReturnRef;
-using testing::_;
-
-class OnHashChangeNotificationTest
- : public CommandsTest<CommandsTestMocks::kIsNice> {};
-
-TEST_F(OnHashChangeNotificationTest, Run_ValidApp_SUCCESS) {
- const uint32_t kConnectionKey = 1u;
- MessageSharedPtr msg = CreateMessage();
- (*msg)[strings::params][strings::connection_key] = kConnectionKey;
-
- SharedPtr<OnHashChangeNotification> command =
- CreateCommand<OnHashChangeNotification>(msg);
-
- std::string return_string = "1234";
- MockAppPtr mock_app = CreateMockApp();
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app));
- EXPECT_CALL(*mock_app, curHash()).WillOnce(ReturnRef(return_string));
- EXPECT_CALL(mock_message_helper_, PrintSmartObject(_))
- .WillOnce(Return(false));
- EXPECT_CALL(app_mngr_, SendMessageToMobile(msg, _));
-
- command->Run();
-
- ASSERT_EQ(application_manager::MessageType::kNotification,
- (*msg)[strings::params][strings::message_type].asInt());
- ASSERT_EQ(CommandImpl::mobile_protocol_type_,
- (*msg)[strings::params][strings::protocol_type].asInt());
- ASSERT_EQ(CommandImpl::protocol_version_,
- (*msg)[strings::params][strings::protocol_version].asInt());
- ASSERT_EQ(return_string,
- (*msg)[strings::msg_params][strings::hash_id].asString());
-}
-
-TEST_F(OnHashChangeNotificationTest, Run_InvalidApp_NoNotification) {
- const uint32_t kConnectionKey = 1u;
- MessageSharedPtr msg = CreateMessage();
- (*msg)[strings::params][strings::connection_key] = kConnectionKey;
-
- SharedPtr<OnHashChangeNotification> command =
- CreateCommand<OnHashChangeNotification>(msg);
-
- std::string return_string;
- MockAppPtr mock_app = CreateMockApp();
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(MockAppPtr()));
- EXPECT_CALL(*mock_app, curHash()).Times(0);
- EXPECT_CALL(mock_message_helper_, PrintSmartObject(_)).Times(0);
- EXPECT_CALL(app_mngr_, SendMessageToMobile(msg, _)).Times(0);
-
- command->Run();
-
- ASSERT_EQ(application_manager::MessageType::kNotification,
- (*msg)[strings::params][strings::message_type].asInt());
-}
-
-} // namespace on_hash_change_notification
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/on_hmi_status_notification_from_mobile_test.cc b/src/components/application_manager/test/commands/mobile/on_hmi_status_notification_from_mobile_test.cc
deleted file mode 100644
index 78875ad164..0000000000
--- a/src/components/application_manager/test/commands/mobile/on_hmi_status_notification_from_mobile_test.cc
+++ /dev/null
@@ -1,282 +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/mobile/on_hmi_status_notification_from_mobile.h"
-#include "application_manager/test/include/application_manager/commands/commands_test.h"
-#include <application_manager/smart_object_keys.h>
-#include "application_manager/message.h"
-#include "application_manager/application_manager.h"
-#include "application_manager/mock_message_helper.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace on_hmi_status_notification_from_mobile {
-
-namespace {
-const uint32_t kConnectionKey = 1u;
-const connection_handler::DeviceHandle kHandle = 2u;
-} // namespace
-
-namespace strings = application_manager::strings;
-
-using application_manager::commands::OnHMIStatusNotificationFromMobile;
-using protocol_handler::MajorProtocolVersion;
-using application_manager::ApplicationSet;
-using testing::Mock;
-using testing::Return;
-using testing::_;
-
-class OnHMIStatusNotificationFromMobileTest
- : public CommandsTest<CommandsTestMocks::kIsNice> {
- public:
- MessageSharedPtr CreateMsgParams(
- const mobile_apis::HMILevel::eType kHMIState) {
- MessageSharedPtr msg = CreateMessage();
- (*msg)[strings::params][strings::connection_key] = kConnectionKey;
- (*msg)[strings::msg_params][strings::hmi_level] = kHMIState;
- return msg;
- }
- ApplicationSet app_set_;
- sync_primitives::Lock lock_;
-};
-
-TEST_F(OnHMIStatusNotificationFromMobileTest,
- Run_CurrentStateForeground_SUCCESS) {
- MessageSharedPtr msg = CreateMsgParams(mobile_apis::HMILevel::HMI_FULL);
-
- SharedPtr<OnHMIStatusNotificationFromMobile> command =
- CreateCommand<OnHMIStatusNotificationFromMobile>(msg);
-
- MockAppPtr mock_app = CreateMockApp();
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app));
- EXPECT_CALL(*mock_app, set_foreground(true));
-
- EXPECT_CALL(*mock_app, device()).WillOnce(Return(kHandle));
- EXPECT_CALL(app_mngr_, IsAppsQueriedFrom(kHandle)).WillOnce(Return(true));
-
- DataAccessor<ApplicationSet> accessor(app_set_, lock_);
- EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(accessor));
-
- EXPECT_CALL(*mock_app, protocol_version())
- .WillRepeatedly(
- Return(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_5));
- EXPECT_CALL(*mock_app, is_foreground()).WillRepeatedly(Return(true));
-
- command->Run();
-
- ASSERT_EQ(application_manager::MessageType::kNotification,
- (*msg)[strings::params][strings::message_type].asInt());
-}
-
-TEST_F(OnHMIStatusNotificationFromMobileTest, Run_InvalidApp_NoNotification) {
- MessageSharedPtr msg = CreateMsgParams(mobile_apis::HMILevel::HMI_FULL);
-
- SharedPtr<OnHMIStatusNotificationFromMobile> command =
- CreateCommand<OnHMIStatusNotificationFromMobile>(msg);
-
- MockAppPtr mock_app = CreateMockApp();
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(MockAppPtr()));
- EXPECT_CALL(*mock_app, set_foreground(true)).Times(0);
-
- EXPECT_CALL(*mock_app, device()).Times(0);
- EXPECT_CALL(app_mngr_, IsAppsQueriedFrom(kHandle)).Times(0);
-
- EXPECT_CALL(app_mngr_, applications()).Times(0);
-
- EXPECT_CALL(*mock_app, protocol_version()).Times(0);
- EXPECT_CALL(*mock_app, is_foreground()).Times(0);
-
- command->Run();
-
- ASSERT_EQ(application_manager::MessageType::kNotification,
- (*msg)[strings::params][strings::message_type].asInt());
-}
-
-TEST_F(OnHMIStatusNotificationFromMobileTest,
- Run_CurrentStateNotForeground_SUCCESS) {
- MessageSharedPtr msg = CreateMsgParams(mobile_apis::HMILevel::HMI_BACKGROUND);
-
- SharedPtr<OnHMIStatusNotificationFromMobile> command =
- CreateCommand<OnHMIStatusNotificationFromMobile>(msg);
-
- MockAppPtr mock_app = CreateMockApp();
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app));
- EXPECT_CALL(*mock_app, set_foreground(false));
-
- EXPECT_CALL(*mock_app, device()).WillOnce(Return(kHandle));
- EXPECT_CALL(app_mngr_, IsAppsQueriedFrom(kHandle)).WillOnce(Return(true));
-
- DataAccessor<ApplicationSet> accessor(app_set_, lock_);
- EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(accessor));
-
- EXPECT_CALL(*mock_app, protocol_version())
- .WillRepeatedly(
- Return(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_5));
- EXPECT_CALL(*mock_app, is_foreground()).WillRepeatedly(Return(true));
-
- command->Run();
-
- ASSERT_EQ(application_manager::MessageType::kNotification,
- (*msg)[strings::params][strings::message_type].asInt());
-}
-
-TEST_F(OnHMIStatusNotificationFromMobileTest,
- Run_ProtocolVersionKV3_NoNotification) {
- MessageSharedPtr msg = CreateMsgParams(mobile_apis::HMILevel::HMI_BACKGROUND);
-
- SharedPtr<OnHMIStatusNotificationFromMobile> command =
- CreateCommand<OnHMIStatusNotificationFromMobile>(msg);
-
- MockAppPtr mock_app = CreateMockApp();
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app));
- EXPECT_CALL(*mock_app, set_foreground(false));
-
- EXPECT_CALL(*mock_app, device()).WillOnce(Return(kHandle));
- EXPECT_CALL(app_mngr_, IsAppsQueriedFrom(kHandle)).WillOnce(Return(true));
-
- DataAccessor<ApplicationSet> accessor(app_set_, lock_);
- EXPECT_CALL(app_mngr_, applications()).Times(0);
-
- EXPECT_CALL(*mock_app, protocol_version())
- .WillOnce(
- Return(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_3));
- EXPECT_CALL(*mock_app, is_foreground()).Times(0);
-
- command->Run();
-
- ASSERT_EQ(application_manager::MessageType::kNotification,
- (*msg)[strings::params][strings::message_type].asInt());
-}
-
-TEST_F(OnHMIStatusNotificationFromMobileTest,
- Run_AppNotRequestedBeforeAndKV3_NoNotification) {
- MessageSharedPtr msg = CreateMsgParams(mobile_apis::HMILevel::HMI_FULL);
-
- SharedPtr<OnHMIStatusNotificationFromMobile> command =
- CreateCommand<OnHMIStatusNotificationFromMobile>(msg);
-
- MockAppPtr mock_app = CreateMockApp();
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app));
- EXPECT_CALL(*mock_app, set_foreground(true));
-
- EXPECT_CALL(*mock_app, device()).WillOnce(Return(kHandle));
- EXPECT_CALL(app_mngr_, IsAppsQueriedFrom(kHandle)).WillOnce(Return(false));
-
- EXPECT_CALL(app_mngr_, applications()).Times(0);
-
- EXPECT_CALL(*mock_app, protocol_version())
- .WillOnce(
- Return(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_3));
- EXPECT_CALL(*mock_app, is_foreground()).Times(0);
-
- command->Run();
-
- ASSERT_EQ(application_manager::MessageType::kNotification,
- (*msg)[strings::params][strings::message_type].asInt());
-}
-
-TEST_F(OnHMIStatusNotificationFromMobileTest,
- Run_AppNotRequestedBefore_SUCCESS) {
- MessageSharedPtr msg = CreateMsgParams(mobile_apis::HMILevel::HMI_FULL);
-
- SharedPtr<OnHMIStatusNotificationFromMobile> command =
- CreateCommand<OnHMIStatusNotificationFromMobile>(msg);
-
- MockAppPtr mock_app = CreateMockApp();
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app));
- EXPECT_CALL(*mock_app, set_foreground(true));
-
- EXPECT_CALL(*mock_app, device()).WillOnce(Return(kHandle));
- EXPECT_CALL(app_mngr_, IsAppsQueriedFrom(kHandle)).WillOnce(Return(false));
-
- EXPECT_CALL(*mock_app, protocol_version())
- .WillOnce(
- Return(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_5));
-
- EXPECT_CALL(app_mngr_, applications()).Times(0);
-
- EXPECT_CALL(*mock_app, is_foreground()).WillOnce(Return(true));
-
- EXPECT_CALL(mock_message_helper_, SendQueryApps(kConnectionKey, _));
-
- command->Run();
-
- ASSERT_EQ(application_manager::MessageType::kNotification,
- (*msg)[strings::params][strings::message_type].asInt());
-}
-
-TEST_F(OnHMIStatusNotificationFromMobileTest,
- Run_AnotherForegroundSDLApp_SUCCESS) {
- MessageSharedPtr msg = CreateMsgParams(mobile_apis::HMILevel::HMI_FULL);
-
- SharedPtr<OnHMIStatusNotificationFromMobile> command =
- CreateCommand<OnHMIStatusNotificationFromMobile>(msg);
-
- MockAppPtr mock_app = CreateMockApp();
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app));
- EXPECT_CALL(*mock_app, set_foreground(true));
-
- EXPECT_CALL(*mock_app, device()).WillOnce(Return(kHandle));
- EXPECT_CALL(app_mngr_, IsAppsQueriedFrom(kHandle)).WillOnce(Return(true));
-
- DataAccessor<ApplicationSet> accessor(app_set_, lock_);
- EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(accessor));
-
- EXPECT_CALL(*mock_app, protocol_version())
- .WillRepeatedly(
- Return(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_5));
- EXPECT_CALL(*mock_app, is_foreground()).WillRepeatedly(Return(false));
-
- EXPECT_CALL(app_mngr_, MarkAppsGreyOut(kHandle, false));
- EXPECT_CALL(app_mngr_, SendUpdateAppList());
-
- command->Run();
-
- ASSERT_EQ(application_manager::MessageType::kNotification,
- (*msg)[strings::params][strings::message_type].asInt());
-}
-
-} // namespace on_hmi_status_notification_from_mobile
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/on_hmi_status_notification_test.cc b/src/components/application_manager/test/commands/mobile/on_hmi_status_notification_test.cc
deleted file mode 100644
index 9cb5610621..0000000000
--- a/src/components/application_manager/test/commands/mobile/on_hmi_status_notification_test.cc
+++ /dev/null
@@ -1,206 +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/mobile/on_hmi_status_notification.h"
-#include "application_manager/test/include/application_manager/commands/commands_test.h"
-#include "application_manager/mock_message_helper.h"
-#include "application_manager/commands/command_impl.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace on_hmi_status_notification {
-
-namespace {
-const uint32_t kConnectionKey = 1u;
-} // namespace
-
-namespace strings = application_manager::strings;
-
-using application_manager::commands::OnHMIStatusNotification;
-using protocol_handler::MajorProtocolVersion;
-using application_manager::MockMessageHelper;
-using application_manager::commands::CommandImpl;
-using testing::Mock;
-using testing::Return;
-using testing::_;
-
-class OnHMIStatusNotificationTest
- : public CommandsTest<CommandsTestMocks::kIsNice> {
- public:
- MessageSharedPtr CreateMsgParams(
- const mobile_apis::HMILevel::eType kHMIState) {
- MessageSharedPtr msg = CreateMessage();
- (*msg)[strings::params][strings::connection_key] = kConnectionKey;
- (*msg)[strings::msg_params][strings::hmi_level] = kHMIState;
- return msg;
- }
-
- void SetSendNotificationExpectations(MessageSharedPtr& msg) {
- EXPECT_CALL(mock_message_helper_, PrintSmartObject(_))
- .WillOnce(Return(false));
- EXPECT_CALL(app_mngr_, SendMessageToMobile(msg, _));
- }
-
- void VerifySendNotificationData(MessageSharedPtr& msg) {
- ASSERT_EQ(application_manager::MessageType::kNotification,
- (*msg)[strings::params][strings::message_type].asInt());
- ASSERT_EQ(CommandImpl::mobile_protocol_type_,
- (*msg)[strings::params][strings::protocol_type].asInt());
- ASSERT_EQ(CommandImpl::protocol_version_,
- (*msg)[strings::params][strings::protocol_version].asInt());
- }
-};
-
-TEST_F(OnHMIStatusNotificationTest, Run_InvalidApp_NoNotification) {
- MessageSharedPtr msg = CreateMsgParams(mobile_apis::HMILevel::HMI_FULL);
-
- SharedPtr<OnHMIStatusNotification> command =
- CreateCommand<OnHMIStatusNotification>(msg);
-
- MockAppPtr mock_app = CreateMockApp();
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(MockAppPtr()));
-
- EXPECT_CALL(*mock_app, tts_properties_in_full()).Times(0);
- EXPECT_CALL(*mock_app, set_tts_properties_in_full(_)).Times(0);
- EXPECT_CALL(*mock_app, app_id()).Times(0);
- EXPECT_CALL(app_mngr_, AddAppToTTSGlobalPropertiesList(kConnectionKey))
- .Times(0);
-
- command->Run();
-}
-
-TEST_F(OnHMIStatusNotificationTest, Run_InvalidEnum_SUCCESS) {
- MessageSharedPtr msg = CreateMsgParams(mobile_apis::HMILevel::INVALID_ENUM);
-
- SharedPtr<OnHMIStatusNotification> command =
- CreateCommand<OnHMIStatusNotification>(msg);
-
- MockAppPtr mock_app = CreateMockApp();
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app));
-
- SetSendNotificationExpectations(msg);
-
- command->Run();
-
- VerifySendNotificationData(msg);
-}
-
-TEST_F(OnHMIStatusNotificationTest, Run_BackgroundAndFalseProperties_SUCCESS) {
- MessageSharedPtr msg = CreateMsgParams(mobile_apis::HMILevel::HMI_BACKGROUND);
- SetSendNotificationExpectations(msg);
-
- SharedPtr<OnHMIStatusNotification> command =
- CreateCommand<OnHMIStatusNotification>(msg);
-
- MockAppPtr mock_app = CreateMockApp();
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app));
-
- EXPECT_CALL(*mock_app, tts_properties_in_none()).WillOnce(Return(false));
- EXPECT_CALL(*mock_app, set_tts_properties_in_none(true));
- EXPECT_CALL(mock_message_helper_, SendTTSGlobalProperties(_, false, _));
-
- command->Run();
-
- VerifySendNotificationData(msg);
-}
-
-TEST_F(OnHMIStatusNotificationTest, Run_BackgroundAndTrueProperties_SUCCESS) {
- MessageSharedPtr msg = CreateMsgParams(mobile_apis::HMILevel::HMI_BACKGROUND);
-
- SharedPtr<OnHMIStatusNotification> command =
- CreateCommand<OnHMIStatusNotification>(msg);
-
- MockAppPtr mock_app = CreateMockApp();
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app));
-
- EXPECT_CALL(*mock_app, tts_properties_in_none()).WillOnce(Return(true));
-
- SetSendNotificationExpectations(msg);
-
- command->Run();
-
- VerifySendNotificationData(msg);
-}
-
-TEST_F(OnHMIStatusNotificationTest, Run_FullAndFalseProperties_SUCCESS) {
- MessageSharedPtr msg = CreateMsgParams(mobile_apis::HMILevel::HMI_FULL);
-
- SharedPtr<OnHMIStatusNotification> command =
- CreateCommand<OnHMIStatusNotification>(msg);
-
- MockAppPtr mock_app = CreateMockApp();
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app));
-
- EXPECT_CALL(*mock_app, tts_properties_in_full()).WillOnce(Return(false));
- EXPECT_CALL(*mock_app, set_tts_properties_in_full(true));
- EXPECT_CALL(*mock_app, app_id()).WillOnce(Return(kConnectionKey));
- EXPECT_CALL(app_mngr_, AddAppToTTSGlobalPropertiesList(kConnectionKey));
-
- SetSendNotificationExpectations(msg);
-
- command->Run();
-
- VerifySendNotificationData(msg);
-}
-
-TEST_F(OnHMIStatusNotificationTest, Run_FullAndTrueProperties_SUCCESS) {
- MessageSharedPtr msg = CreateMsgParams(mobile_apis::HMILevel::HMI_FULL);
-
- SharedPtr<OnHMIStatusNotification> command =
- CreateCommand<OnHMIStatusNotification>(msg);
-
- MockAppPtr mock_app = CreateMockApp();
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app));
-
- EXPECT_CALL(*mock_app, tts_properties_in_full()).WillOnce(Return(true));
-
- SetSendNotificationExpectations(msg);
-
- command->Run();
-
- VerifySendNotificationData(msg);
-}
-
-} // namespace on_hmi_status_notification
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/on_keyboard_input_notification_test.cc b/src/components/application_manager/test/commands/mobile/on_keyboard_input_notification_test.cc
deleted file mode 100644
index 7313f32dca..0000000000
--- a/src/components/application_manager/test/commands/mobile/on_keyboard_input_notification_test.cc
+++ /dev/null
@@ -1,164 +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/mobile/on_keyboard_input_notification.h"
-#include "application_manager/test/include/application_manager/commands/commands_test.h"
-#include <application_manager/smart_object_keys.h>
-#include "application_manager/message.h"
-#include "application_manager/mock_message_helper.h"
-#include "application_manager/commands/command_impl.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace on_keyboard_input_notification {
-
-namespace strings = application_manager::strings;
-
-namespace {
-const uint32_t kConnectionKey = 1u;
-} // namespace
-
-using application_manager::commands::mobile::OnKeyBoardInputNotification;
-using application_manager::MockMessageHelper;
-using application_manager::commands::CommandImpl;
-using application_manager::ApplicationSet;
-using testing::Mock;
-using testing::Return;
-using testing::_;
-
-class OnKeyBoardInputNotificationTest
- : public CommandsTest<CommandsTestMocks::kIsNice> {
- public:
- void SetSendNotificationExpectations(MessageSharedPtr msg) {
- EXPECT_CALL(mock_message_helper_, PrintSmartObject(_))
- .WillOnce(Return(false));
- EXPECT_CALL(app_mngr_, SendMessageToMobile(msg, _));
- }
-
- void SetSendNotificationVariables(MessageSharedPtr msg) {
- ASSERT_EQ(application_manager::MessageType::kNotification,
- (*msg)[strings::params][strings::message_type].asInt());
- ASSERT_EQ(CommandImpl::mobile_protocol_type_,
- (*msg)[strings::params][strings::protocol_type].asInt());
- ASSERT_EQ(CommandImpl::protocol_version_,
- (*msg)[strings::params][strings::protocol_version].asInt());
- }
-
- MockAppPtr InitAppSetDataAccessor(SharedPtr<ApplicationSet>& app_set) {
- app_set = (!app_set ? ::utils::MakeShared<ApplicationSet>() : app_set);
- MockAppPtr app(CreateMockApp());
- app_set->insert(app);
- EXPECT_CALL(app_mngr_, applications())
- .WillOnce(Return(DataAccessor<ApplicationSet>(*app_set, lock_)));
- return app;
- }
-
- SharedPtr<ApplicationSet> app_set_;
- sync_primitives::Lock lock_;
-};
-
-TEST_F(OnKeyBoardInputNotificationTest, Run_ActionActive_SUCCESS) {
- MessageSharedPtr msg = CreateMessage();
-
- SharedPtr<OnKeyBoardInputNotification> command =
- CreateCommand<OnKeyBoardInputNotification>(msg);
-
- MockAppPtr mock_app(InitAppSetDataAccessor(app_set_));
- EXPECT_CALL(*mock_app, is_perform_interaction_active()).WillOnce(Return(1));
- EXPECT_CALL(*mock_app, perform_interaction_layout())
- .WillOnce(Return(mobile_apis::LayoutMode::KEYBOARD));
- EXPECT_CALL(*mock_app, hmi_level()).Times(0);
-
- EXPECT_CALL(*mock_app, app_id()).WillOnce(Return(kConnectionKey));
-
- SetSendNotificationExpectations(msg);
-
- command->Run();
-
- SetSendNotificationVariables(msg);
-
- ASSERT_EQ(kConnectionKey,
- (*msg)[strings::params][strings::connection_key].asInt());
-}
-
-TEST_F(OnKeyBoardInputNotificationTest, Run_ActionNotActive_SUCCESS) {
- MessageSharedPtr msg = CreateMessage();
-
- SharedPtr<OnKeyBoardInputNotification> command =
- CreateCommand<OnKeyBoardInputNotification>(msg);
-
- MockAppPtr mock_app(InitAppSetDataAccessor(app_set_));
- EXPECT_CALL(*mock_app, is_perform_interaction_active())
- .WillRepeatedly(Return(0));
-
- EXPECT_CALL(*mock_app, hmi_level())
- .WillOnce(Return(mobile_apis::HMILevel::eType::HMI_FULL));
-
- EXPECT_CALL(*mock_app, app_id()).WillOnce(Return(kConnectionKey));
-
- SetSendNotificationExpectations(msg);
-
- command->Run();
-
- SetSendNotificationVariables(msg);
-
- ASSERT_EQ(kConnectionKey,
- (*msg)[strings::params][strings::connection_key].asInt());
-}
-
-TEST_F(OnKeyBoardInputNotificationTest, Run_InvalidApp_NoNotification) {
- MessageSharedPtr msg = CreateMessage();
-
- SharedPtr<OnKeyBoardInputNotification> command =
- CreateCommand<OnKeyBoardInputNotification>(msg);
-
- MockAppPtr mock_app(InitAppSetDataAccessor(app_set_));
- EXPECT_CALL(*mock_app, is_perform_interaction_active())
- .WillRepeatedly(Return(0));
-
- EXPECT_CALL(*mock_app, hmi_level())
- .WillOnce(Return(mobile_apis::HMILevel::eType::HMI_BACKGROUND));
-
- EXPECT_CALL(mock_message_helper_, PrintSmartObject(_)).Times(0);
- EXPECT_CALL(app_mngr_, SendMessageToMobile(msg, _)).Times(0);
-
- command->Run();
-}
-
-} // namespace on_keyboard_input_notification
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/on_system_request_notification_test.cc b/src/components/application_manager/test/commands/mobile/on_system_request_notification_test.cc
deleted file mode 100644
index 7840e35cec..0000000000
--- a/src/components/application_manager/test/commands/mobile/on_system_request_notification_test.cc
+++ /dev/null
@@ -1,206 +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/mobile/on_system_request_notification.h"
-#include "application_manager/mock_message_helper.h"
-#include "application_manager/policies/mock_policy_handler_interface.h"
-#include "application_manager/mock_message_helper.h"
-#include "application_manager/test/include/application_manager/commands/commands_test.h"
-#include "application_manager/commands/command_impl.h"
-#include "interfaces/MOBILE_API.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace on_system_request_notification {
-
-namespace strings = application_manager::strings;
-
-using application_manager::commands::mobile::OnSystemRequestNotification;
-using application_manager::commands::CommandImpl;
-using application_manager::MockMessageHelper;
-using test::components::policy_test::MockPolicyHandlerInterface;
-using namespace mobile_apis;
-using testing::Mock;
-using testing::Return;
-using testing::ReturnRef;
-using testing::_;
-
-namespace {
-const uint32_t kConnectionKey = 1u;
-} // namespace
-
-class OnSystemRequestNotificationTest
- : public CommandsTest<CommandsTestMocks::kIsNice> {};
-
-TEST_F(OnSystemRequestNotificationTest, Run_ProprietaryType_SUCCESS) {
- const RequestType::eType kRequestType = RequestType::PROPRIETARY;
-
- MessageSharedPtr msg = CreateMessage();
- (*msg)[strings::params][strings::connection_key] = kConnectionKey;
- (*msg)[strings::msg_params][strings::request_type] = kRequestType;
-
- SharedPtr<OnSystemRequestNotification> command =
- CreateCommand<OnSystemRequestNotification>(msg);
-
- MockAppPtr mock_app = CreateMockApp();
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app));
- MockPolicyHandlerInterface mock_policy_handler;
- EXPECT_CALL(app_mngr_, GetPolicyHandler())
- .WillRepeatedly(ReturnRef(mock_policy_handler));
- std::string policy_app_id;
- EXPECT_CALL(*mock_app, policy_app_id()).WillOnce(Return(policy_app_id));
- EXPECT_CALL(mock_policy_handler, IsRequestTypeAllowed(_, _))
- .WillOnce(Return(true));
-
-#ifdef PROPRIETARY_MODE
- EXPECT_CALL(app_mngr_, GetPolicyHandler())
- .Times(2)
- .WillRepeatedly(ReturnRef(mock_policy_handler));
- EXPECT_CALL(mock_policy_handler, TimeoutExchangeSec()).WillOnce(Return(5u));
-#endif // PROPRIETARY_MODE
-
- EXPECT_CALL(mock_message_helper_, PrintSmartObject(_))
- .WillOnce(Return(false));
- EXPECT_CALL(app_mngr_, SendMessageToMobile(msg, _));
-
- command->Run();
-
- ASSERT_EQ(FileType::JSON,
- (*msg)[strings::msg_params][strings::file_type].asInt());
- ASSERT_EQ(application_manager::MessageType::kNotification,
- (*msg)[strings::params][strings::message_type].asInt());
- ASSERT_EQ(CommandImpl::mobile_protocol_type_,
- (*msg)[strings::params][strings::protocol_type].asInt());
- ASSERT_EQ(CommandImpl::protocol_version_,
- (*msg)[strings::params][strings::protocol_version].asInt());
-}
-
-TEST_F(OnSystemRequestNotificationTest, Run_HTTPType_SUCCESS) {
- const RequestType::eType kRequestType = RequestType::HTTP;
-
- MessageSharedPtr msg = CreateMessage();
- (*msg)[strings::params][strings::connection_key] = kConnectionKey;
- (*msg)[strings::msg_params][strings::request_type] = kRequestType;
-
- SharedPtr<OnSystemRequestNotification> command =
- CreateCommand<OnSystemRequestNotification>(msg);
-
- MockAppPtr mock_app = CreateMockApp();
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app));
- MockPolicyHandlerInterface mock_policy_handler;
- EXPECT_CALL(app_mngr_, GetPolicyHandler())
- .WillOnce(ReturnRef(mock_policy_handler));
- std::string policy_app_id;
- EXPECT_CALL(*mock_app, policy_app_id()).WillOnce(Return(policy_app_id));
- EXPECT_CALL(mock_policy_handler, IsRequestTypeAllowed(_, _))
- .WillOnce(Return(true));
-
- EXPECT_CALL(mock_message_helper_, PrintSmartObject(_))
- .WillOnce(Return(false));
- EXPECT_CALL(app_mngr_, SendMessageToMobile(msg, _));
-
- command->Run();
-
- ASSERT_EQ(FileType::BINARY,
- (*msg)[strings::msg_params][strings::file_type].asInt());
- ASSERT_EQ(application_manager::MessageType::kNotification,
- (*msg)[strings::params][strings::message_type].asInt());
- ASSERT_EQ(CommandImpl::mobile_protocol_type_,
- (*msg)[strings::params][strings::protocol_type].asInt());
- ASSERT_EQ(CommandImpl::protocol_version_,
- (*msg)[strings::params][strings::protocol_version].asInt());
-}
-
-TEST_F(OnSystemRequestNotificationTest, Run_InvalidApp_NoNotification) {
- const RequestType::eType kRequestType = RequestType::HTTP;
-
- MessageSharedPtr msg = CreateMessage();
- (*msg)[strings::params][strings::connection_key] = kConnectionKey;
- (*msg)[strings::msg_params][strings::request_type] = kRequestType;
-
- SharedPtr<OnSystemRequestNotification> command =
- CreateCommand<OnSystemRequestNotification>(msg);
-
- MockAppPtr mock_app = CreateMockApp();
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(MockAppPtr()));
- EXPECT_CALL(app_mngr_, GetPolicyHandler()).Times(0);
- EXPECT_CALL(*mock_app, policy_app_id()).Times(0);
- MockPolicyHandlerInterface mock_policy_handler;
- EXPECT_CALL(mock_policy_handler, IsRequestTypeAllowed(_, _)).Times(0);
-
- EXPECT_CALL(mock_message_helper_, PrintSmartObject(_)).Times(0);
- EXPECT_CALL(app_mngr_, SendMessageToMobile(msg, _)).Times(0);
-
- command->Run();
-}
-
-TEST_F(OnSystemRequestNotificationTest, Run_RequestNotAllowed_NoNotification) {
- const RequestType::eType kRequestType = RequestType::HTTP;
-
- MessageSharedPtr msg = CreateMessage();
- (*msg)[strings::params][strings::connection_key] = kConnectionKey;
- (*msg)[strings::msg_params][strings::request_type] = kRequestType;
-
- SharedPtr<OnSystemRequestNotification> command =
- CreateCommand<OnSystemRequestNotification>(msg);
-
- MockAppPtr mock_app = CreateMockApp();
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app));
- MockPolicyHandlerInterface mock_policy_handler;
- EXPECT_CALL(app_mngr_, GetPolicyHandler())
- .WillOnce(ReturnRef(mock_policy_handler));
- std::string policy_app_id;
- EXPECT_CALL(*mock_app, policy_app_id()).WillOnce(Return(policy_app_id));
- EXPECT_CALL(mock_policy_handler, IsRequestTypeAllowed(_, _))
- .WillOnce(Return(false));
-
- EXPECT_CALL(mock_message_helper_, PrintSmartObject(_)).Times(0);
- EXPECT_CALL(app_mngr_, SendMessageToMobile(msg, _)).Times(0);
- ;
-
- command->Run();
-}
-
-} // namespace on_system_request_notification
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/on_tbt_client_state_notification_test.cc b/src/components/application_manager/test/commands/mobile/on_tbt_client_state_notification_test.cc
deleted file mode 100644
index 59cddc325f..0000000000
--- a/src/components/application_manager/test/commands/mobile/on_tbt_client_state_notification_test.cc
+++ /dev/null
@@ -1,140 +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 <vector>
-
-#include "gtest/gtest.h"
-#include "application_manager/commands/mobile/on_tbt_client_state_notification.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_impl.h"
-#include "utils/helpers.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace on_tbt_client_state_notification {
-
-namespace am = ::application_manager;
-
-using ::testing::_;
-using ::testing::Return;
-
-using am::commands::MessageSharedPtr;
-using am::commands::OnTBTClientStateNotification;
-
-typedef ::utils::SharedPtr<OnTBTClientStateNotification> NotificationPtr;
-
-namespace {
-const uint32_t kAppId = 1u;
-} // namespace
-
-class OnTBTClientStateNotificationTest
- : public CommandsTest<CommandsTestMocks::kIsNice> {
- public:
- OnTBTClientStateNotificationTest()
- : command_(CreateCommand<OnTBTClientStateNotification>()) {}
-
- NotificationPtr command_;
-};
-
-TEST_F(OnTBTClientStateNotificationTest, Run_HmiLevelNone_UNSUCCESS) {
- MockAppPtr mock_app(CreateMockApp());
- std::vector<ApplicationSharedPtr> applications_with_navi;
- applications_with_navi.push_back(mock_app);
-
- EXPECT_CALL(app_mngr_, applications_with_navi())
- .WillOnce(Return(applications_with_navi));
-
- EXPECT_CALL(*mock_app, hmi_level())
- .WillOnce(Return(mobile_apis::HMILevel::HMI_NONE));
-
- EXPECT_CALL(*mock_app, app_id()).Times(0);
-
- EXPECT_CALL(app_mngr_, SendMessageToMobile(_, _)).Times(0);
-
- command_->Run();
-}
-
-MATCHER(CheckMessageData, "") {
- const bool kIsMobileProtocolTypeCorrect =
- (*arg)[am::strings::params][am::strings::protocol_type].asInt() ==
- am::commands::CommandImpl::mobile_protocol_type_;
-
- const bool kIsProtocolVersionCorrect =
- (*arg)[am::strings::params][am::strings::protocol_version].asInt() ==
- am::commands::CommandImpl::protocol_version_;
-
- const bool kIsNotificationCorrect =
- (*arg)[am::strings::params][am::strings::message_type].asInt() ==
- am::MessageType::kNotification;
-
- const bool kIsConnectionKeyCorrect =
- (*arg)[am::strings::params][am::strings::connection_key].asUInt() ==
- kAppId;
-
- using namespace helpers;
- return Compare<bool, EQ, ALL>(true,
- kIsMobileProtocolTypeCorrect,
- kIsProtocolVersionCorrect,
- kIsNotificationCorrect,
- kIsConnectionKeyCorrect);
-}
-
-TEST_F(OnTBTClientStateNotificationTest,
- Run_NotEmptyListOfAppsWithNavi_SUCCESS) {
- MockAppPtr mock_app(CreateMockApp());
- std::vector<ApplicationSharedPtr> applications_with_navi;
- applications_with_navi.push_back(mock_app);
-
- EXPECT_CALL(app_mngr_, applications_with_navi())
- .WillOnce(Return(applications_with_navi));
-
- EXPECT_CALL(*mock_app, hmi_level())
- .WillOnce(Return(mobile_apis::HMILevel::HMI_FULL));
-
- EXPECT_CALL(*mock_app, app_id()).WillOnce(Return(kAppId));
-
- EXPECT_CALL(app_mngr_, SendMessageToMobile(CheckMessageData(), _));
-
- command_->Run();
-}
-
-} // namespace on_tbt_client_state_notification
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/on_touch_event_notification_test.cc b/src/components/application_manager/test/commands/mobile/on_touch_event_notification_test.cc
deleted file mode 100644
index c90991fdf7..0000000000
--- a/src/components/application_manager/test/commands/mobile/on_touch_event_notification_test.cc
+++ /dev/null
@@ -1,149 +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 <vector>
-
-#include "gtest/gtest.h"
-#include "application_manager/commands/mobile/on_touch_event_notification.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_impl.h"
-#include "utils/helpers.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace on_touch_event_notification {
-
-namespace am = ::application_manager;
-
-using ::testing::_;
-using ::testing::Return;
-
-using am::commands::MessageSharedPtr;
-using am::commands::mobile::OnTouchEventNotification;
-
-typedef ::utils::SharedPtr<OnTouchEventNotification> NotificationPtr;
-
-namespace {
-const uint32_t kAppId = 1u;
-} // namespace
-
-class OnTouchEventNotificationTest
- : public CommandsTest<CommandsTestMocks::kIsNice> {
- public:
- OnTouchEventNotificationTest()
- : command_(CreateCommand<OnTouchEventNotification>()) {}
-
- NotificationPtr command_;
-};
-
-TEST_F(OnTouchEventNotificationTest, Run_AppIsNotFullscreen_UNSUCCESS) {
- MockAppPtr mock_app(CreateMockApp());
- std::vector<ApplicationSharedPtr> applications_with_navi;
- applications_with_navi.push_back(mock_app);
-
- std::vector<ApplicationSharedPtr> applications_with_mobile_projection;
- applications_with_mobile_projection.push_back(mock_app);
-
- EXPECT_CALL(app_mngr_, applications_with_navi())
- .WillOnce(Return(applications_with_navi));
-
- EXPECT_CALL(app_mngr_, applications_with_mobile_projection())
- .WillOnce(Return(applications_with_mobile_projection));
-
- EXPECT_CALL(*mock_app, IsFullscreen()).WillRepeatedly(Return(false));
-
- EXPECT_CALL(*mock_app, app_id()).Times(0);
-
- EXPECT_CALL(app_mngr_, SendMessageToMobile(_, _)).Times(0);
-
- command_->Run();
-}
-
-MATCHER(CheckMessageData, "") {
- const bool kIsMobileProtocolTypeCorrect =
- (*arg)[am::strings::params][am::strings::protocol_type].asInt() ==
- am::commands::CommandImpl::mobile_protocol_type_;
-
- const bool kIsProtocolVersionCorrect =
- (*arg)[am::strings::params][am::strings::protocol_version].asInt() ==
- am::commands::CommandImpl::protocol_version_;
-
- const bool kIsNotificationCorrect =
- (*arg)[am::strings::params][am::strings::message_type].asInt() ==
- am::MessageType::kNotification;
-
- const bool kIsConnectionKeyCorrect =
- (*arg)[am::strings::params][am::strings::connection_key].asUInt() ==
- kAppId;
-
- using namespace helpers;
- return Compare<bool, EQ, ALL>(true,
- kIsMobileProtocolTypeCorrect,
- kIsProtocolVersionCorrect,
- kIsNotificationCorrect,
- kIsConnectionKeyCorrect);
-}
-
-TEST_F(OnTouchEventNotificationTest, Run_NotEmptyListOfAppsWithNavi_SUCCESS) {
- MockAppPtr mock_app(CreateMockApp());
- std::vector<ApplicationSharedPtr> applications_with_navi;
- applications_with_navi.push_back(mock_app);
-
- std::vector<ApplicationSharedPtr> applications_with_mobile_projection;
- applications_with_mobile_projection.push_back(mock_app);
-
- EXPECT_CALL(app_mngr_, applications_with_navi())
- .WillOnce(Return(applications_with_navi));
-
- EXPECT_CALL(app_mngr_, applications_with_mobile_projection())
- .WillOnce(Return(applications_with_mobile_projection));
-
- EXPECT_CALL(*mock_app, IsFullscreen()).WillRepeatedly(Return(true));
-
- EXPECT_CALL(*mock_app, app_id()).WillRepeatedly(Return(kAppId));
-
- EXPECT_CALL(app_mngr_, SendMessageToMobile(CheckMessageData(), _)).Times(2);
-
- command_->Run();
-}
-
-} // namespace on_touch_event_notification
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/on_vehicle_data_notification_test.cc b/src/components/application_manager/test/commands/mobile/on_vehicle_data_notification_test.cc
deleted file mode 100644
index 05d97856e4..0000000000
--- a/src/components/application_manager/test/commands/mobile/on_vehicle_data_notification_test.cc
+++ /dev/null
@@ -1,148 +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 <vector>
-#include <map>
-
-#include "gtest/gtest.h"
-#include "application_manager/commands/mobile/on_vehicle_data_notification.h"
-#include "utils/shared_ptr.h"
-#include "utils/custom_string.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_impl.h"
-#include "application_manager/message_helper.h"
-#include "application_manager/mock_message_helper.h"
-#include "utils/helpers.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace on_vehicle_data_notification {
-
-namespace am = ::application_manager;
-
-using ::testing::_;
-using ::testing::Return;
-using ::testing::ReturnRef;
-
-using am::commands::MessageSharedPtr;
-using am::commands::OnVehicleDataNotification;
-
-typedef ::utils::SharedPtr<OnVehicleDataNotification> NotificationPtr;
-
-namespace {
-const uint32_t kAppId = 1u;
-} // namespace
-
-class OnVehicleDataNotificationTest
- : public CommandsTest<CommandsTestMocks::kIsNice> {
- public:
- OnVehicleDataNotificationTest()
- : command_msg_(CreateMessage(smart_objects::SmartType_Map))
- , command_(CreateCommand<OnVehicleDataNotification>(command_msg_)) {}
-
- MessageSharedPtr command_msg_;
- NotificationPtr command_;
-};
-
-MATCHER_P2(CheckMessageData, key, value, "") {
- const bool kIsMobileProtocolTypeCorrect =
- (*arg)[am::strings::params][am::strings::protocol_type].asInt() ==
- am::commands::CommandImpl::mobile_protocol_type_;
-
- const bool kIsProtocolVersionCorrect =
- (*arg)[am::strings::params][am::strings::protocol_version].asInt() ==
- am::commands::CommandImpl::protocol_version_;
-
- const bool kIsNotificationCorrect =
- (*arg)[am::strings::params][am::strings::message_type].asInt() ==
- am::MessageType::kNotification;
-
- const bool kIsConnectionKeyCorrect =
- (*arg)[am::strings::params][am::strings::connection_key].asUInt() ==
- kAppId;
-
- const bool kAreMsgParamsCorrect =
- (*arg)[am::strings::msg_params][key].asInt() == value;
-
- using namespace helpers;
- return Compare<bool, EQ, ALL>(true,
- kIsMobileProtocolTypeCorrect,
- kIsProtocolVersionCorrect,
- kIsNotificationCorrect,
- kIsConnectionKeyCorrect,
- kAreMsgParamsCorrect);
-}
-
-TEST_F(OnVehicleDataNotificationTest,
- Run_NotEmptyListOfAppsSubscribedForEvent_SUCCESS) {
- am::VehicleData test_vehicle_data;
- test_vehicle_data.insert(am::VehicleData::value_type(
- am::strings::fuel_level,
- mobile_apis::VehicleDataType::VEHICLEDATA_FUELLEVEL));
-
- EXPECT_CALL(mock_message_helper_, vehicle_data())
- .WillOnce(ReturnRef(test_vehicle_data));
-
- const int kFuelLevel = 100;
- (*command_msg_)[am::strings::msg_params][am::strings::fuel_level] =
- kFuelLevel;
-
- MockAppPtr mock_app(CreateMockApp());
- std::vector<ApplicationSharedPtr> applications;
- applications.push_back(mock_app);
-
- EXPECT_CALL(
- app_mngr_,
- IviInfoUpdated(mobile_apis::VehicleDataType::VEHICLEDATA_FUELLEVEL,
- kFuelLevel)).WillOnce(Return(applications));
-
- EXPECT_CALL(*mock_app, app_id()).WillRepeatedly(Return(kAppId));
- ::utils::custom_string::CustomString dummy_name("test_app");
- ON_CALL(*mock_app, name()).WillByDefault(ReturnRef(dummy_name));
-
- EXPECT_CALL(app_mngr_,
- SendMessageToMobile(
- CheckMessageData(am::strings::fuel_level, kFuelLevel), _));
-
- command_->Run();
-}
-
-} // namespace on_vehicle_data_notification
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/on_way_point_change_notification_test.cc b/src/components/application_manager/test/commands/mobile/on_way_point_change_notification_test.cc
deleted file mode 100644
index b0dd3c142c..0000000000
--- a/src/components/application_manager/test/commands/mobile/on_way_point_change_notification_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 <set>
-
-#include "gtest/gtest.h"
-#include "application_manager/commands/mobile/on_way_point_change_notification.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_impl.h"
-#include "utils/helpers.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace on_way_point_change_notification {
-
-namespace am = ::application_manager;
-
-using ::testing::_;
-using ::testing::Return;
-
-using am::commands::MessageSharedPtr;
-using am::commands::OnWayPointChangeNotification;
-
-typedef ::utils::SharedPtr<OnWayPointChangeNotification> NotificationPtr;
-
-namespace {
-const uint32_t kAppId = 1u;
-} // namespace
-
-class OnWayPointChangeNotificationTest
- : public CommandsTest<CommandsTestMocks::kIsNice> {
- public:
- OnWayPointChangeNotificationTest()
- : command_(CreateCommand<OnWayPointChangeNotification>()) {}
-
- NotificationPtr command_;
-};
-
-MATCHER(CheckMessageData, "") {
- const bool kIsMobileProtocolTypeCorrect =
- (*arg)[am::strings::params][am::strings::protocol_type].asInt() ==
- am::commands::CommandImpl::mobile_protocol_type_;
-
- const bool kIsProtocolVersionCorrect =
- (*arg)[am::strings::params][am::strings::protocol_version].asInt() ==
- am::commands::CommandImpl::protocol_version_;
-
- const bool kIsNotificationCorrect =
- (*arg)[am::strings::params][am::strings::message_type].asInt() ==
- am::MessageType::kNotification;
-
- const bool kIsConnectionKeyCorrect =
- (*arg)[am::strings::params][am::strings::connection_key].asUInt() ==
- kAppId;
-
- using namespace helpers;
- return Compare<bool, EQ, ALL>(true,
- kIsMobileProtocolTypeCorrect,
- kIsProtocolVersionCorrect,
- kIsNotificationCorrect,
- kIsConnectionKeyCorrect);
-}
-
-TEST_F(OnWayPointChangeNotificationTest,
- Run_NotEmptyListOfAppsSubscribedForWayPoints_SUCCESS) {
- std::set<int32_t> apps_subscribed_for_way_points;
- apps_subscribed_for_way_points.insert(kAppId);
-
- EXPECT_CALL(app_mngr_, GetAppsSubscribedForWayPoints())
- .WillOnce(Return(apps_subscribed_for_way_points));
-
- EXPECT_CALL(app_mngr_, SendMessageToMobile(CheckMessageData(), _));
-
- command_->Run();
-}
-
-} // namespace on_way_point_change_notification
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/perform_audio_pass_thru_test.cc b/src/components/application_manager/test/commands/mobile/perform_audio_pass_thru_test.cc
deleted file mode 100644
index a27bac970c..0000000000
--- a/src/components/application_manager/test/commands/mobile/perform_audio_pass_thru_test.cc
+++ /dev/null
@@ -1,801 +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 <set>
-
-#include "application_manager/commands/mobile/perform_audio_pass_thru_request.h"
-
-#include "gtest/gtest.h"
-#include "application_manager/commands/command_request_test.h"
-#include "application_manager/mock_application.h"
-#include "application_manager/mock_application_manager.h"
-#include "application_manager/mock_message_helper.h"
-#include "application_manager/event_engine/event.h"
-#include "application_manager/mock_hmi_interface.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace perform_audio_pass_thru_request {
-
-namespace am = application_manager;
-using am::commands::PerformAudioPassThruRequest;
-using am::commands::CommandImpl;
-using am::commands::MessageSharedPtr;
-using am::MockMessageHelper;
-using ::utils::SharedPtr;
-using ::testing::_;
-using ::testing::Return;
-using ::testing::ReturnRef;
-using ::testing::InSequence;
-
-namespace {
-const int32_t kCommandId = 1;
-const uint32_t kAppId = 1u;
-const uint32_t kCmdId = 1u;
-const uint32_t kConnectionKey = 2u;
-const uint32_t kCorrelationId = 2u;
-const std::string kCorrectPrompt = "CorrectPrompt";
-const std::string kCorrectType = "CorrectType";
-const std::string kCorrectDisplayText1 = "CorrectDisplayText1";
-const std::string kCorrectDisplayText2 = "CorrectDisplayText2";
-const std::string kFunctionId = "FunctionId";
-const uint32_t kTimeoutForTTSSpeak = 1u;
-} // namespace
-
-class PerformAudioPassThruRequestTest
- : public CommandRequestTest<CommandsTestMocks::kIsNice> {
- public:
- PerformAudioPassThruRequestTest()
- : mock_app_(CreateMockApp())
- , message_(utils::MakeShared<SmartObject>(::smart_objects::SmartType_Map))
- , msg_params_((*message_)[am::strings::msg_params]) {}
-
- MessageSharedPtr CreateFullParamsUISO() {
- MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
- (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey;
- smart_objects::SmartObject menu_params =
- smart_objects::SmartObject(smart_objects::SmartType_Map);
- menu_params[am::strings::position] = 10;
- menu_params[am::strings::menu_name] = "LG";
-
- smart_objects::SmartObject msg_params =
- smart_objects::SmartObject(smart_objects::SmartType_Map);
- msg_params[am::strings::cmd_id] = kCmdId;
- msg_params[am::strings::menu_params] = menu_params;
- msg_params[am::strings::app_id] = kAppId;
- msg_params[am::strings::cmd_icon] = 1;
- msg_params[am::strings::cmd_icon][am::strings::value] = "10";
- (*msg)[am::strings::msg_params] = msg_params;
-
- return msg;
- }
-
- void TestWrongSyntaxInField(const std::string& field) {
- if (field == am::strings::initial_prompt) {
- msg_params_[field][0][am::strings::text] = "prompt\\n";
- } else {
- msg_params_[field] = "prompt\\n";
- }
-
- EXPECT_CALL(*application_sptr_, hmi_level())
- .WillOnce(Return(am::mobile_api::HMILevel::HMI_FULL));
-
- CallRun caller(*command_sptr_);
- MessageSharedPtr result_message = CatchMobileCommandResult(caller);
-
- const am::mobile_api::Result::eType result =
- static_cast<am::mobile_api::Result::eType>(
- (*result_message)[am::strings::msg_params][am::strings::result_code]
- .asInt());
-
- EXPECT_EQ(am::mobile_api::Result::INVALID_DATA, result);
- }
-
- void SetUp() OVERRIDE {
- ON_CALL(app_mngr_, application(kConnectionKey))
- .WillByDefault(Return(mock_app_));
- ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey));
- (*message_)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
- command_sptr_ =
- CreateCommand<am::commands::PerformAudioPassThruRequest>(message_);
-
- application_sptr_ = CreateMockApp();
- ON_CALL(app_mngr_, application(_)).WillByDefault(Return(application_sptr_));
- }
-
- void ResultCommandExpectations(MessageSharedPtr msg,
- const std::string& info) {
- EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::success].asBool(),
- true);
- EXPECT_EQ(
- (*msg)[am::strings::msg_params][am::strings::result_code].asInt(),
- static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE));
- EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::info].asString(),
- info);
- }
-
- sync_primitives::Lock lock_;
- MockAppPtr mock_app_;
- MessageSharedPtr message_;
- ::smart_objects::SmartObject& msg_params_;
- utils::SharedPtr<am::commands::PerformAudioPassThruRequest> command_sptr_;
- MockAppPtr application_sptr_;
-};
-
-TEST_F(PerformAudioPassThruRequestTest, OnTimeout_GENERIC_ERROR) {
- MessageSharedPtr msg_ui = CreateMessage(smart_objects::SmartType_Map);
- (*msg_ui)[am::strings::msg_params][am::strings::result_code] =
- am::mobile_api::Result::GENERIC_ERROR;
- (*msg_ui)[am::strings::msg_params][am::strings::success] = false;
-
- MessageSharedPtr message =
- utils::MakeShared<SmartObject>(::smart_objects::SmartType_Map);
- (*message)[am::strings::params][am::strings::connection_key] = kConnectionKey;
-
- utils::SharedPtr<PerformAudioPassThruRequest> command =
- CreateCommand<PerformAudioPassThruRequest>(message);
-
- uint32_t app_id = kConnectionKey;
- EXPECT_CALL(app_mngr_, EndAudioPassThru(app_id)).WillOnce(Return(true));
- EXPECT_CALL(app_mngr_, StopAudioPassThru(_));
-
- EXPECT_CALL(
- mock_message_helper_,
- CreateNegativeResponse(_, _, _, am::mobile_api::Result::GENERIC_ERROR))
- .WillOnce(Return(msg_ui));
-
- MessageSharedPtr vr_command_result;
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
- .WillOnce(DoAll(SaveArg<0>(&vr_command_result), Return(true)));
-
- command->onTimeOut();
- EXPECT_EQ((*vr_command_result)[am::strings::msg_params][am::strings::success]
- .asBool(),
- false);
- EXPECT_EQ(
- (*vr_command_result)[am::strings::msg_params][am::strings::result_code]
- .asInt(),
- static_cast<int32_t>(am::mobile_api::Result::GENERIC_ERROR));
-}
-
-TEST_F(PerformAudioPassThruRequestTest,
- OnEvent_UIHmiSendUnsupportedResource_UNSUPPORTED_RESOURCE) {
- MessageSharedPtr mobile_request = CreateFullParamsUISO();
- (*mobile_request)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
-
- smart_objects::SmartObject initial_prompt =
- smart_objects::SmartObject(smart_objects::SmartType_Array);
- initial_prompt[0] = smart_objects::SmartObject(smart_objects::SmartType_Map);
- initial_prompt[0][am::strings::text] = "tts chunk text";
- initial_prompt[0][am::strings::type] = 0;
- (*mobile_request)[am::strings::msg_params][am::strings::initial_prompt] =
- initial_prompt;
-
- EXPECT_CALL(*application_sptr_, hmi_level())
- .WillOnce(Return(am::mobile_api::HMILevel::HMI_FULL));
- utils::SharedPtr<PerformAudioPassThruRequest> command =
- CreateCommand<PerformAudioPassThruRequest>(mobile_request);
-
- ON_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
- .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
- ON_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS))
- .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
-
- MessageSharedPtr response_msg_tts =
- CreateMessage(smart_objects::SmartType_Map);
- (*response_msg_tts)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::SUCCESS;
- (*response_msg_tts)[am::strings::msg_params][am::strings::cmd_id] = kCmdId;
- am::event_engine::Event event_tts(hmi_apis::FunctionID::TTS_Speak);
- event_tts.set_smart_object(*response_msg_tts);
-
- MessageSharedPtr response_ui = CreateMessage(smart_objects::SmartType_Map);
- (*response_ui)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
- (*response_ui)[am::strings::msg_params][am::strings::cmd_id] = kCommandId;
- (*response_ui)[am::strings::msg_params][am::strings::info] =
- "UI is not supported by system";
- am::event_engine::Event event_ui(
- hmi_apis::FunctionID::UI_PerformAudioPassThru);
- event_ui.set_smart_object(*response_ui);
-
- MessageSharedPtr response_to_mobile;
- uint32_t app_id = kConnectionKey;
- EXPECT_CALL(app_mngr_, EndAudioPassThru(app_id)).WillOnce(Return(false));
- EXPECT_CALL(app_mngr_, ManageHMICommand(_)).WillRepeatedly(Return(true));
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
- .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true)));
-
- command->Run();
- command->on_event(event_tts);
- command->on_event(event_ui);
-
- EXPECT_EQ((*response_to_mobile)[am::strings::msg_params][am::strings::success]
- .asBool(),
- false);
- EXPECT_EQ(
- (*response_to_mobile)[am::strings::msg_params][am::strings::result_code]
- .asInt(),
- static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE));
- EXPECT_EQ((*response_to_mobile)[am::strings::msg_params][am::strings::info]
- .asString(),
- "UI is not supported by system");
-}
-
-TEST_F(PerformAudioPassThruRequestTest,
- Run_InvalidApp_ApplicationNotRegisteredResponce) {
- utils::SharedPtr<am::Application> null_application_sptr;
- EXPECT_CALL(app_mngr_, application(_))
- .WillOnce(Return(null_application_sptr));
-
- CallRun caller(*command_sptr_);
- MessageSharedPtr result_message = CatchMobileCommandResult(caller);
-
- const am::mobile_api::Result::eType result =
- static_cast<am::mobile_api::Result::eType>(
- (*result_message)[am::strings::msg_params][am::strings::result_code]
- .asInt());
- EXPECT_EQ(am::mobile_api::Result::APPLICATION_NOT_REGISTERED, result);
-}
-
-TEST_F(PerformAudioPassThruRequestTest, Run_HmiLevelNone_Rejected) {
- EXPECT_CALL(*application_sptr_, hmi_level())
- .WillOnce(Return(am::mobile_api::HMILevel::HMI_NONE));
-
- CallRun caller(*command_sptr_);
- MessageSharedPtr result_message = CatchMobileCommandResult(caller);
-
- const am::mobile_api::Result::eType result =
- static_cast<am::mobile_api::Result::eType>(
- (*result_message)[am::strings::msg_params][am::strings::result_code]
- .asInt());
- EXPECT_EQ(am::mobile_api::Result::REJECTED, result);
-}
-
-TEST_F(PerformAudioPassThruRequestTest,
- Run_WhitespaceInInitialPrompt_InvalidData) {
- TestWrongSyntaxInField(am::strings::initial_prompt);
-}
-
-TEST_F(PerformAudioPassThruRequestTest,
- Run_WhitespaceInAudioPassDisplayText1_InvalidData) {
- TestWrongSyntaxInField(am::strings::audio_pass_display_text1);
-}
-
-TEST_F(PerformAudioPassThruRequestTest,
- Run_WhitespaceInAudioPassDisplayText2_InvalidData) {
- TestWrongSyntaxInField(am::strings::audio_pass_display_text2);
-}
-
-TEST_F(PerformAudioPassThruRequestTest,
- Run_InitPromptCorrect_TTSSpeakIsAbsent) {
- // First we need to call SendSpeakRequest()
- // to enable the "is_active_tts_speak" key
-
- EXPECT_CALL(*application_sptr_, hmi_level())
- .WillOnce(Return(am::mobile_api::HMILevel::HMI_FULL));
-
- msg_params_[am::strings::initial_prompt][0][am::strings::text] =
- kCorrectPrompt;
- msg_params_[am::strings::initial_prompt][0][am::strings::type] = kCorrectType;
-
- MessageSharedPtr speak_reqeust_result_msg;
- MessageSharedPtr perform_result_msg;
- {
- InSequence dummy;
- // Send speak request sending
- ON_CALL(app_mngr_, GetNextHMICorrelationID())
- .WillByDefault(Return(kCorrelationId));
- ON_CALL(mock_hmi_interfaces_,
- GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_Speak))
- .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_TTS));
- ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
- .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
- EXPECT_CALL(app_mngr_, ManageHMICommand(_))
- .WillOnce(DoAll(SaveArg<0>(&speak_reqeust_result_msg), Return(true)));
-
- // Perform audio path thru request sending
- ON_CALL(app_mngr_, GetNextHMICorrelationID())
- .WillByDefault(Return(kCorrelationId));
- ON_CALL(
- mock_hmi_interfaces_,
- GetInterfaceFromFunction(hmi_apis::FunctionID::UI_PerformAudioPassThru))
- .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
- ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
- .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
- EXPECT_CALL(app_mngr_, ManageHMICommand(_))
- .WillOnce(DoAll(SaveArg<0>(&perform_result_msg), Return(true)));
- }
- CallRun run_caller(*command_sptr_);
- run_caller();
-
- const ::smart_objects::SmartObject& speak_msg_params =
- (*speak_reqeust_result_msg)[am::strings::msg_params];
-
- const std::string result_initial_prompt =
- speak_msg_params[am::hmi_request::tts_chunks][0][am::strings::text]
- .asString();
- const std::string result_prompt_type =
- speak_msg_params[am::hmi_request::tts_chunks][0][am::strings::type]
- .asString();
-
- EXPECT_EQ(kCorrectPrompt, result_initial_prompt);
- EXPECT_EQ(kCorrectType, result_prompt_type);
-
- // Now we recieve on_event()
-
- am::event_engine::Event event(hmi_apis::FunctionID::UI_PerformAudioPassThru);
- (*message_)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::GENERIC_ERROR;
- event.set_smart_object(*message_);
-
- uint32_t app_id = kConnectionKey;
- EXPECT_CALL(app_mngr_, EndAudioPassThru(app_id)).WillOnce(Return(false));
-
- ON_CALL(app_mngr_, GetNextHMICorrelationID())
- .WillByDefault(Return(kCorrelationId));
- ON_CALL(mock_hmi_interfaces_,
- GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_StopSpeaking))
- .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_TTS));
- ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
- .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
-
- EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0);
-
- CallOnEvent on_event_caller(*command_sptr_, event);
- MessageSharedPtr command_result = CatchHMICommandResult(on_event_caller);
-
- const hmi_apis::FunctionID::eType result_function_id =
- static_cast<hmi_apis::FunctionID::eType>(
- (*command_result)[am::strings::params][am::strings::function_id]
- .asInt());
-
- EXPECT_EQ(hmi_apis::FunctionID::TTS_StopSpeaking, result_function_id);
-}
-
-TEST_F(PerformAudioPassThruRequestTest,
- Run_InitPromptCorrect_SpeakAndPerformAPTRequestsSendMuteTrue) {
- EXPECT_CALL(*application_sptr_, hmi_level())
- .WillOnce(Return(am::mobile_api::HMILevel::HMI_FULL));
-
- msg_params_[am::strings::initial_prompt][0][am::strings::text] =
- kCorrectPrompt;
- msg_params_[am::strings::initial_prompt][0][am::strings::type] = kCorrectType;
- msg_params_[am::strings::audio_pass_display_text1] = kCorrectDisplayText1;
- msg_params_[am::strings::audio_pass_display_text2] = kCorrectDisplayText2;
-
- MessageSharedPtr speak_reqeust_result_msg;
- MessageSharedPtr perform_result_msg;
- {
- InSequence dummy;
- ON_CALL(app_mngr_, GetNextHMICorrelationID())
- .WillByDefault(Return(kCorrelationId));
- ON_CALL(mock_hmi_interfaces_,
- GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_Speak))
- .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_TTS));
- ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
- .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
- EXPECT_CALL(app_mngr_, ManageHMICommand(_))
- .WillOnce(DoAll(SaveArg<0>(&speak_reqeust_result_msg), Return(true)));
-
- // Perform audio path thru request sending
- ON_CALL(app_mngr_, GetNextHMICorrelationID())
- .WillByDefault(Return(kCorrelationId));
- ON_CALL(
- mock_hmi_interfaces_,
- GetInterfaceFromFunction(hmi_apis::FunctionID::UI_PerformAudioPassThru))
- .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
- ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
- .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
- EXPECT_CALL(app_mngr_, ManageHMICommand(_))
- .WillOnce(DoAll(SaveArg<0>(&perform_result_msg), Return(true)));
- }
- CallRun caller(*command_sptr_);
- caller();
-
- const ::smart_objects::SmartObject& speak_msg_params =
- (*speak_reqeust_result_msg)[am::strings::msg_params];
- const ::smart_objects::SmartObject& perform_msg_params =
- (*perform_result_msg)[am::strings::msg_params];
-
- const std::string result_initial_prompt =
- speak_msg_params[am::hmi_request::tts_chunks][0][am::strings::text]
- .asString();
- const std::string result_prompt_type =
- speak_msg_params[am::hmi_request::tts_chunks][0][am::strings::type]
- .asString();
- const std::string result_display_text_1 =
- perform_msg_params[am::hmi_request::audio_pass_display_texts][0]
- [am::hmi_request::field_text].asString();
- const std::string result_display_text_2 =
- perform_msg_params[am::hmi_request::audio_pass_display_texts][1]
- [am::hmi_request::field_text].asString();
-
- EXPECT_EQ(kCorrectPrompt, result_initial_prompt);
- EXPECT_EQ(kCorrectType, result_prompt_type);
- EXPECT_EQ(kCorrectDisplayText1, result_display_text_1);
- EXPECT_EQ(kCorrectDisplayText2, result_display_text_2);
-
- EXPECT_EQ(true, perform_msg_params[am::strings::mute_audio].asBool());
-}
-
-TEST_F(PerformAudioPassThruRequestTest,
- Run_InitPromptCorrect_SpeakAndPerformAPTRequestsSendMuteFalse) {
- EXPECT_CALL(*application_sptr_, hmi_level())
- .WillOnce(Return(am::mobile_api::HMILevel::HMI_FULL));
-
- msg_params_[am::strings::initial_prompt][0][am::strings::text] =
- kCorrectPrompt;
- msg_params_[am::strings::initial_prompt][0][am::strings::type] = kCorrectType;
-
- const bool muted = false;
-
- msg_params_[am::strings::mute_audio] = muted;
-
- MessageSharedPtr speak_reqeust_result_msg;
- MessageSharedPtr perform_result_msg;
- {
- InSequence dummy;
- ON_CALL(app_mngr_, GetNextHMICorrelationID())
- .WillByDefault(Return(kCorrelationId));
- ON_CALL(mock_hmi_interfaces_,
- GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_Speak))
- .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_TTS));
- ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
- .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
- EXPECT_CALL(app_mngr_, ManageHMICommand(_))
- .WillOnce(DoAll(SaveArg<0>(&speak_reqeust_result_msg), Return(true)));
-
- // Perform audio path thru request sending
- ON_CALL(app_mngr_, GetNextHMICorrelationID())
- .WillByDefault(Return(kCorrelationId));
- ON_CALL(
- mock_hmi_interfaces_,
- GetInterfaceFromFunction(hmi_apis::FunctionID::UI_PerformAudioPassThru))
- .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
- ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
- .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
- EXPECT_CALL(app_mngr_, ManageHMICommand(_))
- .WillOnce(DoAll(SaveArg<0>(&perform_result_msg), Return(true)));
- }
- CallRun caller(*command_sptr_);
- caller();
-
- EXPECT_EQ(
- muted,
- (*perform_result_msg)[am::strings::msg_params][am::strings::mute_audio]
- .asBool());
-}
-
-TEST_F(
- PerformAudioPassThruRequestTest,
- Run_InitPromptEmpty_PerformAndRecordStartNotificationsAndStartRecording) {
- EXPECT_CALL(*application_sptr_, hmi_level())
- .WillOnce(Return(am::mobile_api::HMILevel::HMI_FULL));
-
- MessageSharedPtr start_record_result_msg;
- MessageSharedPtr perform_result_msg;
- {
- InSequence dummy;
-
- ON_CALL(app_mngr_, GetNextHMICorrelationID())
- .WillByDefault(Return(kCorrelationId));
- ON_CALL(
- mock_hmi_interfaces_,
- GetInterfaceFromFunction(hmi_apis::FunctionID::UI_PerformAudioPassThru))
- .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_TTS));
- ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
- .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
- // Perform audio path thru request sending
- EXPECT_CALL(app_mngr_, ManageHMICommand(_))
- .WillOnce(DoAll(SaveArg<0>(&perform_result_msg), Return(true)));
-
- // Perform audio path thru request sending
- ON_CALL(app_mngr_, GetNextHMICorrelationID())
- .WillByDefault(Return(kCorrelationId));
- ON_CALL(mock_hmi_interfaces_,
- GetInterfaceFromFunction(hmi_apis::FunctionID::UI_OnRecordStart))
- .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
- ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
- .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
- // Start recording notification sending
- EXPECT_CALL(app_mngr_, ManageHMICommand(_))
- .WillOnce(DoAll(SaveArg<0>(&start_record_result_msg), Return(true)));
- }
-
- // Start microphone recording cals
- uint32_t app_id = kConnectionKey;
- EXPECT_CALL(app_mngr_, BeginAudioPassThru(app_id));
- EXPECT_CALL(app_mngr_, StartAudioPassThruThread(_, _, _, _, _, _));
-
- CallRun caller(*command_sptr_);
- caller();
-
- const hmi_apis::FunctionID::eType start_record_result_function_id =
- static_cast<hmi_apis::FunctionID::eType>(
- (*start_record_result_msg)[am::strings::params]
- [am::strings::function_id].asInt());
- EXPECT_EQ(hmi_apis::FunctionID::UI_OnRecordStart,
- start_record_result_function_id);
-}
-
-TEST_F(PerformAudioPassThruRequestTest, OnEvent_UIPAPT_Rejected) {
- am::event_engine::Event event(hmi_apis::FunctionID::UI_PerformAudioPassThru);
-
- (*message_)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::REJECTED;
- event.set_smart_object(*message_);
-
- CallOnEvent caller(*command_sptr_, event);
-
- MessageSharedPtr result_message = CatchMobileCommandResult(caller);
-
- const am::mobile_api::Result::eType result_code =
- static_cast<am::mobile_api::Result::eType>(
- (*result_message)[am::strings::msg_params][am::strings::result_code]
- .asInt());
-
- EXPECT_EQ(am::mobile_api::Result::REJECTED, result_code);
-}
-
-TEST_F(PerformAudioPassThruRequestTest,
- OnEvent_TTSSpeakSuccess_UpdateRequestTimeout) {
- am::event_engine::Event event(hmi_apis::FunctionID::TTS_Speak);
-
- (*message_)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::SUCCESS;
- event.set_smart_object(*message_);
-
- // Start recording notification sending
- EXPECT_CALL(app_mngr_, ManageHMICommand(_)).WillOnce(Return(true));
-
- // Start microphone recording cals
- uint32_t app_id = kConnectionKey;
- EXPECT_CALL(app_mngr_, BeginAudioPassThru(app_id));
- EXPECT_CALL(app_mngr_, StartAudioPassThruThread(_, _, _, _, _, _));
-
- EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _));
-
- ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
- .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
-
- CallOnEvent caller(*command_sptr_, event);
- caller();
-}
-
-TEST_F(PerformAudioPassThruRequestTest,
- DISABLED_OnEvent_PAPTunsupportedResource_CorrectInfo) {
- const std::string return_info = "Unsupported phoneme type sent in a prompt";
-
- am::event_engine::Event event_speak(hmi_apis::FunctionID::TTS_Speak);
- am::event_engine::Event event_perform(
- hmi_apis::FunctionID::UI_PerformAudioPassThru);
-
- (*message_)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
- event_speak.set_smart_object(*message_);
-
- (*message_)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::SUCCESS;
- event_perform.set_smart_object(*message_);
-
- ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
- .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
- // First call on_event for setting result_tts_speak_ to UNSUPPORTED_RESOURCE
- EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _));
- CallOnEvent caller_speak(*command_sptr_, event_speak);
- caller_speak();
-
- // Second call for test correct behavior of UI_PerformAudioPassThru event
- uint32_t app_id = kConnectionKey;
- EXPECT_CALL(app_mngr_, EndAudioPassThru(app_id)).WillOnce(Return(false));
- EXPECT_CALL(app_mngr_, StopAudioPassThru(_)).Times(0);
- ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
- .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
- CallOnEvent caller_perform(*command_sptr_, event_perform);
-
- MessageSharedPtr perform_event_result =
- CatchMobileCommandResult(caller_perform);
-
- EXPECT_EQ(return_info,
- (*perform_event_result)[am::strings::msg_params][am::strings::info]
- .asString());
-}
-
-TEST_F(PerformAudioPassThruRequestTest,
- DISABLED_OnEvent_TTSSpeak_UpdateTimeout) {
- am::event_engine::Event event(hmi_apis::FunctionID::TTS_Speak);
-
- msg_params_[am::strings::connection_key] = kConnectionKey;
- msg_params_[am::strings::function_id] = kFunctionId;
- msg_params_[am::strings::correlation_id] = kCorrelationId;
-
- EXPECT_CALL(app_mngr_, ManageHMICommand(_)).WillOnce(Return(true));
-
- uint32_t app_id = kConnectionKey;
- EXPECT_CALL(app_mngr_, BeginAudioPassThru(app_id)).WillOnce(Return(true));
-
- EXPECT_CALL(
- app_mngr_,
- StartAudioPassThruThread(kConnectionKey, kCorrelationId, _, _, _, _));
-
- EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _));
- ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
- .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
- CallOnEvent caller(*command_sptr_, event);
- caller();
-
- EXPECT_EQ(kConnectionKey, msg_params_[am::strings::connection_key].asUInt());
- EXPECT_EQ(kFunctionId, msg_params_[am::strings::function_id].asString());
-}
-
-TEST_F(PerformAudioPassThruRequestTest,
- DISABLED_OnEvent_TTSOnResetTimeout_UpdateTimeout) {
- am::event_engine::Event event(hmi_apis::FunctionID::TTS_OnResetTimeout);
-
- msg_params_[am::strings::connection_key] = kConnectionKey;
- msg_params_[am::strings::function_id] = kFunctionId;
-
- uint32_t app_id = kConnectionKey;
- EXPECT_CALL(app_mngr_, ManageHMICommand(_)).WillOnce(Return(true));
- EXPECT_CALL(app_mngr_, BeginAudioPassThru(app_id)).WillOnce(Return(true));
-
- EXPECT_CALL(
- app_mngr_,
- StartAudioPassThruThread(kConnectionKey, kCorrelationId, _, _, _, _));
- EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _));
- ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
- .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
- CallOnEvent caller(*command_sptr_, event);
- caller();
-
- EXPECT_EQ(kConnectionKey, msg_params_[am::strings::connection_key].asUInt());
- EXPECT_EQ(kFunctionId, msg_params_[am::strings::function_id].asString());
-}
-
-TEST_F(PerformAudioPassThruRequestTest, OnEvent_DefaultCase) {
- am::event_engine::Event event(hmi_apis::FunctionID::INVALID_ENUM);
-
- uint32_t app_id = kConnectionKey;
- EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _)).Times(0);
- EXPECT_CALL(app_mngr_, EndAudioPassThru(app_id)).Times(0);
-
- CallOnEvent caller(*command_sptr_, event);
- caller();
-}
-
-TEST_F(PerformAudioPassThruRequestTest, Init_CorrectTimeout) {
- const uint32_t kDefaultTimeout = command_sptr_->default_timeout();
- const uint32_t kMaxDuration = 10000u;
-
- msg_params_[am::strings::max_duration] = kMaxDuration;
-
- command_sptr_->Init();
-
- EXPECT_EQ(kDefaultTimeout + kMaxDuration, command_sptr_->default_timeout());
-}
-
-TEST_F(PerformAudioPassThruRequestTest,
- onTimeOut_ttsSpeakNotActive_DontSendHMIReqeust) {
- uint32_t app_id = kConnectionKey;
- EXPECT_CALL(app_mngr_, EndAudioPassThru(app_id)).WillOnce(Return(true));
- EXPECT_CALL(app_mngr_, StopAudioPassThru(_));
-
- // For setting current_state_ -> kCompleted
- EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _));
- command_sptr_->SendResponse(true, am::mobile_api::Result::SUCCESS);
-
- EXPECT_CALL(app_mngr_, ManageHMICommand(_)).Times(0);
-
- command_sptr_->onTimeOut();
-}
-
-TEST_F(PerformAudioPassThruRequestTest,
- DISABLED_onTimeOut_ttsSpeakActive_SendHMIReqeust) {
- uint32_t app_id = kConnectionKey;
- EXPECT_CALL(app_mngr_, EndAudioPassThru(app_id)).WillOnce(Return(true));
- EXPECT_CALL(app_mngr_, StopAudioPassThru(_));
-
- EXPECT_CALL(*application_sptr_, hmi_level())
- .WillOnce(Return(am::mobile_api::HMILevel::HMI_FULL));
-
- msg_params_[am::strings::initial_prompt][0][am::strings::text] =
- kCorrectPrompt;
- msg_params_[am::strings::initial_prompt][0][am::strings::type] = kCorrectType;
- MessageSharedPtr speak_reqeust_result_msg;
- MessageSharedPtr perform_result_msg;
- ON_CALL(app_mngr_, GetNextHMICorrelationID())
- .WillByDefault(Return(kCorrelationId));
- ON_CALL(mock_hmi_interfaces_,
- GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_Speak))
- .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_TTS));
- ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
- .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
- EXPECT_CALL(app_mngr_, ManageHMICommand(_))
- .WillOnce(DoAll(SaveArg<0>(&speak_reqeust_result_msg), Return(true)));
-
- // Perform audio path thru request sending
- ON_CALL(app_mngr_, GetNextHMICorrelationID())
- .WillByDefault(Return(kCorrelationId));
- ON_CALL(
- mock_hmi_interfaces_,
- GetInterfaceFromFunction(hmi_apis::FunctionID::UI_PerformAudioPassThru))
- .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
- ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
- .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
- EXPECT_CALL(app_mngr_, ManageHMICommand(_))
- .WillOnce(DoAll(SaveArg<0>(&perform_result_msg), Return(true)));
-
- MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
- EXPECT_CALL(
- mock_message_helper_,
- CreateNegativeResponse(_, _, _, am::mobile_api::Result::GENERIC_ERROR))
- .WillOnce(Return(msg));
-
- // For setting is_active_tts_speak -> true
- EXPECT_CALL(app_mngr_, ManageHMICommand(_))
- .Times(2)
- .WillRepeatedly(Return(false));
- CallRun caller(*command_sptr_);
- caller();
-
- // For setting current_state_ -> kCompleted
-
- EXPECT_CALL(app_mngr_,
- ManageMobileCommand(_, am::commands::Command::ORIGIN_SDL));
- command_sptr_->SendResponse(true, am::mobile_api::Result::SUCCESS);
-
- EXPECT_CALL(
- app_mngr_,
- ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_StopSpeaking)))
- .WillOnce(Return(false));
-
- command_sptr_->onTimeOut();
-}
-
-} // namespace perform_audio_pass_thru_request
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace tests
diff --git a/src/components/application_manager/test/commands/mobile/perform_interaction_test.cc b/src/components/application_manager/test/commands/mobile/perform_interaction_test.cc
deleted file mode 100644
index a272234e82..0000000000
--- a/src/components/application_manager/test/commands/mobile/perform_interaction_test.cc
+++ /dev/null
@@ -1,262 +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 <set>
-
-#include "application_manager/commands/mobile/perform_interaction_request.h"
-
-#include "gtest/gtest.h"
-#include "utils/shared_ptr.h"
-#include "utils/helpers.h"
-#include "utils/make_shared.h"
-#include "smart_objects/smart_object.h"
-#include "utils/custom_string.h"
-#include "application_manager/commands/command_request_test.h"
-#include "application_manager/smart_object_keys.h"
-#include "application_manager/mock_application.h"
-#include "application_manager/mock_application_manager.h"
-#include "application_manager/mock_message_helper.h"
-#include "application_manager/event_engine/event.h"
-#include "application_manager/mock_hmi_interface.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace perform_interaction_request {
-
-namespace am = application_manager;
-using am::commands::CommandImpl;
-using am::ApplicationManager;
-using am::commands::MessageSharedPtr;
-using am::ApplicationSharedPtr;
-using am::MockMessageHelper;
-using ::testing::_;
-using ::utils::SharedPtr;
-using ::testing::Return;
-using ::testing::ReturnRef;
-using am::commands::PerformInteractionRequest;
-using ::test::components::application_manager_test::MockApplication;
-
-namespace strings = ::application_manager::strings;
-namespace hmi_response = ::application_manager::hmi_response;
-
-namespace {
-const int32_t kCommandId = 1;
-const uint32_t kCmdId = 1u;
-const uint32_t kConnectionKey = 2u;
-} // namespace
-
-class PerformInteractionRequestTest
- : public CommandRequestTest<CommandsTestMocks::kIsNice> {
- public:
- PerformInteractionRequestTest() : mock_app_(CreateMockApp()) {}
-
- void SetUp() OVERRIDE {
- ON_CALL(app_mngr_, application(kConnectionKey))
- .WillByDefault(Return(mock_app_));
- ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey));
- }
-
- void ResultCommandExpectations(MessageSharedPtr msg,
- const std::string& info) {
- EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::success].asBool(),
- true);
- EXPECT_EQ(
- (*msg)[am::strings::msg_params][am::strings::result_code].asInt(),
- static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE));
- EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::info].asString(),
- info);
- }
-
- sync_primitives::Lock lock_;
- MockAppPtr mock_app_;
-};
-
-TEST_F(PerformInteractionRequestTest, OnTimeout_VR_GENERIC_ERROR) {
- MessageSharedPtr response_msg_vr =
- CreateMessage(smart_objects::SmartType_Map);
- (*response_msg_vr)[strings::params][hmi_response::code] =
- static_cast<uint64_t>(hmi_apis::Common_Result::SUCCESS);
- (*response_msg_vr)[strings::msg_params][strings::info] = "info";
- MessageSharedPtr request_msg = CreateMessage(smart_objects::SmartType_Map);
- (*request_msg)[strings::msg_params][strings::interaction_mode] =
- mobile_apis::InteractionMode::BOTH;
- utils::SharedPtr<PerformInteractionRequest> command =
- CreateCommand<PerformInteractionRequest>(request_msg);
- MockAppPtr mock_app;
-
- ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app));
-
- Event event(hmi_apis::FunctionID::VR_PerformInteraction);
- event.set_smart_object(*response_msg_vr);
-
- command->Init();
- command->on_event(event);
- MessageSharedPtr response_to_mobile =
- CreateMessage(smart_objects::SmartType_Map);
- (*response_to_mobile)[strings::msg_params][strings::result_code] =
- static_cast<uint64_t>(am::mobile_api::Result::GENERIC_ERROR);
- EXPECT_CALL(
- mock_message_helper_,
- CreateNegativeResponse(_, _, _, am::mobile_api::Result::GENERIC_ERROR))
- .WillOnce(Return(response_to_mobile));
-
- MessageSharedPtr vr_command_result;
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
- .WillOnce(DoAll(SaveArg<0>(&vr_command_result), Return(true)));
- command->onTimeOut();
-
- EXPECT_EQ(
- (*vr_command_result)[strings::msg_params][strings::success].asBool(),
- false);
- EXPECT_EQ(
- (*vr_command_result)[strings::msg_params][strings::result_code].asInt(),
- static_cast<int32_t>(am::mobile_api::Result::GENERIC_ERROR));
-}
-
-TEST_F(PerformInteractionRequestTest,
- OnEvent_VRHmiSendSuccess_UNSUPPORTED_RESOURCE) {
- MessageSharedPtr msg_from_mobile =
- CreateMessage(smart_objects::SmartType_Map);
- (*msg_from_mobile)[strings::params][strings::connection_key] = kConnectionKey;
- (*msg_from_mobile)[strings::msg_params][strings::interaction_mode] =
- mobile_apis::InteractionMode::VR_ONLY;
- utils::SharedPtr<PerformInteractionRequest> command =
- CreateCommand<PerformInteractionRequest>(msg_from_mobile);
- command->Init();
-
- MockAppPtr mock_app;
- EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(mock_app));
-
- MessageSharedPtr response_msg_vr =
- CreateMessage(smart_objects::SmartType_Map);
- (*response_msg_vr)[strings::params][hmi_response::code] =
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
- (*response_msg_vr)[strings::msg_params][strings::cmd_id] = kCommandId;
- (*response_msg_vr)[am::strings::msg_params][am::strings::info] =
- "VR is not supported by system";
-
- am::event_engine::Event event_vr(hmi_apis::FunctionID::VR_PerformInteraction);
- event_vr.set_smart_object(*response_msg_vr);
-
- MessageSharedPtr response_msg_ui =
- CreateMessage(smart_objects::SmartType_Map);
- (*response_msg_ui)[strings::params][hmi_response::code] =
- hmi_apis::Common_Result::SUCCESS;
-
- am::event_engine::Event event_ui(hmi_apis::FunctionID::UI_PerformInteraction);
- event_ui.set_smart_object(*response_msg_ui);
-
- EXPECT_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
- .WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE));
- EXPECT_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR))
- .WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE));
-
- MessageSharedPtr response_to_mobile;
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
- .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true)));
-
- command->on_event(event_vr);
- command->on_event(event_ui);
-
- ResultCommandExpectations(response_to_mobile,
- "VR is not supported by system");
-}
-
-TEST_F(PerformInteractionRequestTest,
- OnEvent_UIHmiSendSuccess_UNSUPPORTED_RESOURCE) {
- MessageSharedPtr msg_from_mobile =
- CreateMessage(smart_objects::SmartType_Map);
- (*msg_from_mobile)[strings::params][strings::connection_key] = kConnectionKey;
- (*msg_from_mobile)[strings::msg_params][strings::interaction_mode] =
- mobile_apis::InteractionMode::VR_ONLY;
- utils::SharedPtr<PerformInteractionRequest> command =
- CreateCommand<PerformInteractionRequest>(msg_from_mobile);
-
- ON_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
- .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
- ON_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR))
- .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
-
- MessageSharedPtr response_msg_vr =
- CreateMessage(smart_objects::SmartType_Map);
- (*response_msg_vr)[strings::params][hmi_response::code] =
- hmi_apis::Common_Result::SUCCESS;
- am::event_engine::Event event_vr(hmi_apis::FunctionID::VR_PerformInteraction);
- event_vr.set_smart_object(*response_msg_vr);
-
- MessageSharedPtr response_msg_ui =
- CreateMessage(smart_objects::SmartType_Map);
- (*response_msg_ui)[strings::params][hmi_response::code] =
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
- (*response_msg_ui)[strings::msg_params][strings::cmd_id] = kCommandId;
- (*response_msg_ui)[am::strings::msg_params][am::strings::info] =
- "UI is not supported by system";
-
- am::event_engine::Event event_ui(hmi_apis::FunctionID::UI_PerformInteraction);
- event_ui.set_smart_object(*response_msg_ui);
-
- MessageSharedPtr response_to_mobile;
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
- .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true)));
-
- command->on_event(event_vr);
-
- EXPECT_CALL(*mock_app_, is_perform_interaction_active())
- .WillOnce(Return(false));
- EXPECT_CALL(*mock_app_, DeletePerformInteractionChoiceSet(_));
-
- command->on_event(event_ui);
-
- ResultCommandExpectations(response_to_mobile,
- "UI is not supported by system");
-}
-
-} // namespace perform_interaction_request
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace tests
diff --git a/src/components/application_manager/test/commands/mobile/put_file_test.cc b/src/components/application_manager/test/commands/mobile/put_file_test.cc
deleted file mode 100644
index b48ac67501..0000000000
--- a/src/components/application_manager/test/commands/mobile/put_file_test.cc
+++ /dev/null
@@ -1,351 +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 "commands/commands_test.h"
-#include "commands/command_request_test.h"
-
-#include "mobile/put_file_response.h"
-#include "mobile/put_file_request.h"
-
-#include "utils/make_shared.h"
-#include "utils/file_system.h"
-#include "smart_objects/smart_object.h"
-#include "interfaces/MOBILE_API.h"
-#include "application_manager/application.h"
-#include "application_manager/mock_application.h"
-#include "application_manager/policies/mock_policy_handler_interface.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace put_file {
-
-using ::testing::_;
-using ::testing::Return;
-using ::testing::ReturnRef;
-using ::testing::AtLeast;
-
-namespace am = ::application_manager;
-
-using am::commands::PutFileRequest;
-using am::commands::PutFileResponse;
-using am::commands::MessageSharedPtr;
-using policy_test::MockPolicyHandlerInterface;
-
-typedef SharedPtr<PutFileRequest> PutFileRequestPtr;
-typedef SharedPtr<PutFileResponse> PutFileResponsePtr;
-
-namespace {
-const uint32_t kConnectionKey = 1u;
-const std::string kFileName = "sync_file_name.txt";
-const int64_t kOffset = 10u;
-const int64_t kZeroOffset = 0u;
-const std::string kStorageFolder = "./storage";
-const std::string kAppFolder = "app_folder";
-}
-
-class PutFileRequestTest
- : public CommandRequestTest<CommandsTestMocks::kIsNice> {
- public:
- PutFileRequestTest()
- : msg_(CreateMessage(::smart_objects::SmartType_Map))
- , mock_app_(CreateMockApp()) {}
-
- void SetUp() OVERRIDE {
- binary_data_.push_back(1u);
-
- (*msg_)[am::strings::params][am::strings::connection_key] = kConnectionKey;
- (*msg_)[am::strings::msg_params][am::strings::sync_file_name] = kFileName;
- (*msg_)[am::strings::msg_params][am::strings::persistent_file] = true;
- (*msg_)[am::strings::msg_params][am::strings::file_type] =
- mobile_apis::FileType::JSON;
- (*msg_)[am::strings::params][am::strings::binary_data] = binary_data_;
-
- ON_CALL(app_mngr_, application(kConnectionKey))
- .WillByDefault(Return(mock_app_));
- ON_CALL(app_mngr_, GetPolicyHandler())
- .WillByDefault(ReturnRef(mock_policy_handler_));
- ON_CALL(*mock_app_, hmi_level())
- .WillByDefault(Return(mobile_apis::HMILevel::HMI_FULL));
- }
-
- void ExpectReceiveMessageFromSDK() {
- EXPECT_CALL(mock_policy_handler_,
- ReceiveMessageFromSDK(kFileName, binary_data_))
- .WillOnce(Return(mobile_apis::HMILevel::HMI_FULL));
- }
- void ExpectManageMobileCommandWithResultCode(
- const mobile_apis::Result::eType code) {
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(MobileResultCodeIs(code),
- am::commands::Command::CommandOrigin::ORIGIN_SDL));
- }
-
- MessageSharedPtr msg_;
- MockAppPtr mock_app_;
- MockPolicyHandlerInterface mock_policy_handler_;
- std::vector<uint8_t> binary_data_;
-};
-
-class PutFileResponceTest : public CommandsTest<CommandsTestMocks::kIsNice> {
- public:
- PutFileResponceTest() : message_(CreateMessage()) {}
-
- void SetUp() OVERRIDE {
- command_sptr_ = CreateCommand<PutFileResponse>(message_);
- }
-
- MessageSharedPtr message_;
- SharedPtr<PutFileResponse> command_sptr_;
-};
-
-TEST_F(PutFileResponceTest, Run_InvalidApp_ApplicationNotRegisteredResponce) {
- ::smart_objects::SmartObject& message_ref = *message_;
-
- message_ref[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
-
- utils::SharedPtr<am::Application> null_application_sptr;
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(null_application_sptr));
- EXPECT_CALL(
- app_mngr_,
- SendMessageToMobile(
- MobileResultCodeIs(mobile_apis::Result::APPLICATION_NOT_REGISTERED),
- _));
- command_sptr_->Run();
-}
-
-TEST_F(PutFileResponceTest, Run_ApplicationRegistered_Success) {
- ::smart_objects::SmartObject& message_ref = *message_;
-
- message_ref[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
- message_ref[am::strings::msg_params][am::strings::success] = true;
-
- utils::SharedPtr<am::Application> application_sptr =
- utils::MakeShared<MockApplication>();
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(application_sptr));
- EXPECT_CALL(
- app_mngr_,
- SendMessageToMobile(MobileResultCodeIs(mobile_apis::Result::SUCCESS), _));
- command_sptr_->Run();
-}
-
-TEST_F(PutFileRequestTest, Run_ApplicationIsNotRegistered_UNSUCCESS) {
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(ApplicationSharedPtr()));
- ExpectManageMobileCommandWithResultCode(
- mobile_apis::Result::APPLICATION_NOT_REGISTERED);
-
- PutFileRequestPtr command(CreateCommand<PutFileRequest>(msg_));
- command->Run();
-}
-
-TEST_F(PutFileRequestTest, Run_HmiLevelNone_UNSUCCESS) {
- EXPECT_CALL(*mock_app_, hmi_level())
- .WillOnce(Return(mobile_apis::HMILevel::HMI_NONE));
-
- const uint32_t settings_put_file_in_none = 1u;
- const uint32_t app_put_file_in_none_count = 2u;
- EXPECT_CALL(app_mngr_settings_, put_file_in_none())
- .WillOnce(ReturnRef(settings_put_file_in_none));
- EXPECT_CALL(*mock_app_, put_file_in_none_count())
- .WillOnce(Return(app_put_file_in_none_count));
- ExpectManageMobileCommandWithResultCode(mobile_apis::Result::REJECTED);
-
- PutFileRequestPtr command(CreateCommand<PutFileRequest>(msg_));
- command->Run();
-}
-
-TEST_F(PutFileRequestTest, Run_BinaryDataDoesNotExists_UNSUCCESS) {
- (*msg_)[am::strings::params].erase(am::strings::binary_data);
- ExpectManageMobileCommandWithResultCode(mobile_apis::Result::INVALID_DATA);
-
- PutFileRequestPtr command(CreateCommand<PutFileRequest>(msg_));
- command->Run();
-}
-
-TEST_F(PutFileRequestTest, Run_SyncFileNameDoesNotExists_UNSUCCESS) {
- (*msg_)[am::strings::msg_params].erase(am::strings::sync_file_name);
-
- ExpectManageMobileCommandWithResultCode(mobile_apis::Result::INVALID_DATA);
-
- PutFileRequestPtr command(CreateCommand<PutFileRequest>(msg_));
- command->Run();
-}
-
-TEST_F(PutFileRequestTest, Run_FileTypeDoesNotExists_UNSUCCESS) {
- (*msg_)[am::strings::msg_params].erase(am::strings::file_type);
-
- ExpectManageMobileCommandWithResultCode(mobile_apis::Result::INVALID_DATA);
-
- PutFileRequestPtr command(CreateCommand<PutFileRequest>(msg_));
- command->Run();
-}
-
-TEST_F(PutFileRequestTest, Run_BinaryDataGreaterThanAvaliableSpace_UNSUCCESS) {
- (*msg_)[am::strings::msg_params][am::strings::offset] = kOffset;
- (*msg_)[am::strings::msg_params][am::strings::system_file] = false;
-
- ExpectReceiveMessageFromSDK();
- EXPECT_CALL(app_mngr_settings_, app_storage_folder())
- .WillOnce(ReturnRef(kStorageFolder));
- EXPECT_CALL(*mock_app_, folder_name()).WillOnce(Return(kAppFolder));
-
- const uint32_t avaliable_space = 0u;
- EXPECT_CALL(*mock_app_, GetAvailableDiskSpace())
- .WillOnce(Return(avaliable_space));
- ExpectManageMobileCommandWithResultCode(mobile_apis::Result::OUT_OF_MEMORY);
-
- PutFileRequestPtr command(CreateCommand<PutFileRequest>(msg_));
- command->Run();
-}
-
-TEST_F(PutFileRequestTest, Run_IvalidCreationDirectory_UNSUCCESS) {
- (*msg_)[am::strings::msg_params][am::strings::offset] = kOffset;
- (*msg_)[am::strings::msg_params][am::strings::system_file] = true;
-
- ExpectReceiveMessageFromSDK();
-
- const std::string storage_folder = "/storage";
- EXPECT_CALL(app_mngr_settings_, system_files_path())
- .WillOnce(ReturnRef(storage_folder));
- ExpectManageMobileCommandWithResultCode(mobile_apis::Result::GENERIC_ERROR);
-
- PutFileRequestPtr command(CreateCommand<PutFileRequest>(msg_));
- command->Run();
-}
-
-TEST_F(PutFileRequestTest, Run_IvalidUpdateFile_UNSUCCESS) {
- (*msg_)[am::strings::msg_params][am::strings::offset] = kZeroOffset;
- (*msg_)[am::strings::msg_params][am::strings::system_file] = false;
-
- ExpectReceiveMessageFromSDK();
- EXPECT_CALL(app_mngr_settings_, app_storage_folder())
- .WillOnce(ReturnRef(kStorageFolder));
- EXPECT_CALL(*mock_app_, folder_name()).WillOnce(Return(kAppFolder));
-
- const uint32_t avaliable_space = 2u;
- EXPECT_CALL(*mock_app_, GetAvailableDiskSpace())
- .WillOnce(Return(avaliable_space))
- .WillOnce(Return(avaliable_space));
-
- const std::string file_path = kStorageFolder + "/" + kAppFolder;
- EXPECT_CALL(app_mngr_,
- SaveBinary(binary_data_, file_path, kFileName, kZeroOffset))
- .WillOnce(Return(mobile_apis::Result::SUCCESS));
- EXPECT_CALL(*mock_app_, AddFile(_)).WillOnce(Return(false));
- EXPECT_CALL(*mock_app_, UpdateFile(_)).WillOnce(Return(false));
-
- ExpectManageMobileCommandWithResultCode(mobile_apis::Result::INVALID_DATA);
-
- PutFileRequestPtr command(CreateCommand<PutFileRequest>(msg_));
- command->Run();
-}
-
-TEST_F(PutFileRequestTest, Run_AddFile_SUCCESS) {
- (*msg_)[am::strings::msg_params][am::strings::offset] = kZeroOffset;
- (*msg_)[am::strings::msg_params][am::strings::system_file] = false;
-
- ExpectReceiveMessageFromSDK();
- EXPECT_CALL(app_mngr_settings_, app_storage_folder())
- .WillOnce(ReturnRef(kStorageFolder));
- EXPECT_CALL(*mock_app_, folder_name()).WillOnce(Return(kAppFolder));
-
- const uint32_t avaliable_space = 2u;
- EXPECT_CALL(*mock_app_, GetAvailableDiskSpace())
- .WillOnce(Return(avaliable_space))
- .WillOnce(Return(avaliable_space));
-
- const std::string file_path = kStorageFolder + "/" + kAppFolder;
- EXPECT_CALL(app_mngr_,
- SaveBinary(binary_data_, file_path, kFileName, kZeroOffset))
- .WillOnce(Return(mobile_apis::Result::SUCCESS));
- EXPECT_CALL(*mock_app_, AddFile(_)).WillOnce(Return(true));
- ExpectManageMobileCommandWithResultCode(mobile_apis::Result::SUCCESS);
-
- PutFileRequestPtr command(CreateCommand<PutFileRequest>(msg_));
- command->Run();
-}
-
-TEST_F(PutFileRequestTest, Run_SendOnPutFileNotification_SUCCESS) {
- (*msg_)[am::strings::msg_params][am::strings::offset] = kZeroOffset;
- (*msg_)[am::strings::msg_params][am::strings::system_file] = true;
-
- ExpectReceiveMessageFromSDK();
- EXPECT_CALL(app_mngr_settings_, system_files_path())
- .WillOnce(ReturnRef(kStorageFolder));
- EXPECT_CALL(app_mngr_,
- SaveBinary(binary_data_, kStorageFolder, kFileName, kZeroOffset))
- .WillOnce(Return(mobile_apis::Result::SUCCESS));
- EXPECT_CALL(app_mngr_,
- ManageHMICommand(HMIResultCodeIs(
- hmi_apis::FunctionID::BasicCommunication_OnPutFile)))
- .WillOnce(Return(true));
- ExpectManageMobileCommandWithResultCode(mobile_apis::Result::SUCCESS);
-
- PutFileRequestPtr command(CreateCommand<PutFileRequest>(msg_));
- command->Run();
-}
-
-TEST_F(PutFileRequestTest, Run_InvalidPutFile_UNSUCCESS) {
- (*msg_)[am::strings::msg_params][am::strings::offset] = kZeroOffset;
- (*msg_)[am::strings::msg_params][am::strings::system_file] = true;
-
- ExpectReceiveMessageFromSDK();
- EXPECT_CALL(app_mngr_settings_, system_files_path())
- .WillOnce(ReturnRef(kStorageFolder));
- EXPECT_CALL(app_mngr_,
- SaveBinary(binary_data_, kStorageFolder, kFileName, kZeroOffset))
- .WillOnce(Return(mobile_apis::Result::INVALID_DATA));
- ExpectManageMobileCommandWithResultCode(mobile_apis::Result::INVALID_DATA);
-
- PutFileRequestPtr command(CreateCommand<PutFileRequest>(msg_));
- command->Run();
-}
-
-} // namespace put_file
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/read_did_request_test.cc b/src/components/application_manager/test/commands/mobile/read_did_request_test.cc
deleted file mode 100644
index c88f4626f0..0000000000
--- a/src/components/application_manager/test/commands/mobile/read_did_request_test.cc
+++ /dev/null
@@ -1,166 +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/test/include/application_manager/commands/commands_test.h"
-#include "application_manager/test/include/application_manager/commands/command_request_test.h"
-#include "application_manager/application.h"
-#include "application_manager/mock_application_manager.h"
-#include "application_manager/mock_application.h"
-#include "application_manager/mock_message_helper.h"
-#include "application_manager/commands/mobile/read_did_request.h"
-#include "interfaces/MOBILE_API.h"
-#include "interfaces/HMI_API.h"
-#include "application_manager/smart_object_keys.h"
-#include "application_manager/event_engine/event.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace read_did_request {
-
-using ::testing::_;
-using ::testing::DoAll;
-using ::testing::Return;
-using ::testing::SaveArg;
-namespace am = ::application_manager;
-using am::commands::ReadDIDRequest;
-using am::commands::MessageSharedPtr;
-using am::event_engine::Event;
-using ::utils::SharedPtr;
-
-class ReadDIDRequestTest
- : public CommandRequestTest<CommandsTestMocks::kIsNice> {};
-
-TEST_F(ReadDIDRequestTest, OnEvent_WrongEventId_UNSUCCESS) {
- Event event(Event::EventID::INVALID_ENUM);
- SharedPtr<ReadDIDRequest> command(CreateCommand<ReadDIDRequest>());
-
- EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0);
- command->on_event(event);
-}
-
-TEST_F(ReadDIDRequestTest, OnEvent_SUCCESS) {
- Event event(Event::EventID::VehicleInfo_ReadDID);
-
- SharedPtr<ReadDIDRequest> command(CreateCommand<ReadDIDRequest>());
-
- const hmi_apis::Common_Result::eType hmi_response_code =
- hmi_apis::Common_Result::SUCCESS;
- const mobile_apis::Result::eType mobile_response_code =
- mobile_apis::Result::SUCCESS;
- MessageSharedPtr event_msg(CreateMessage(smart_objects::SmartType_Map));
- (*event_msg)[am::strings::params][am::hmi_response::code] = hmi_response_code;
- (*event_msg)[am::strings::msg_params] = 0;
-
- event.set_smart_object(*event_msg);
-
- EXPECT_CALL(app_mngr_,
- ManageMobileCommand(MobileResultCodeIs(mobile_response_code), _));
-
- MockAppPtr app(CreateMockApp());
- EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(app));
-
- command->on_event(event);
-}
-
-TEST_F(ReadDIDRequestTest, Run_AppNotRegistered_UNSUCCESS) {
- SharedPtr<ReadDIDRequest> command(CreateCommand<ReadDIDRequest>());
-
- ON_CALL(app_mngr_, application(_))
- .WillByDefault(Return(SharedPtr<am::Application>()));
-
- MessageSharedPtr result_msg(CatchMobileCommandResult(CallRun(*command)));
- EXPECT_EQ(mobile_apis::Result::APPLICATION_NOT_REGISTERED,
- static_cast<mobile_apis::Result::eType>(
- (*result_msg)[am::strings::msg_params][am::strings::result_code]
- .asInt()));
-}
-
-TEST_F(ReadDIDRequestTest, Run_CommandLimitsExceeded_UNSUCCESS) {
- SharedPtr<ReadDIDRequest> command(CreateCommand<ReadDIDRequest>());
-
- MockAppPtr app(CreateMockApp());
- ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app));
-
- ON_CALL(*app, AreCommandLimitsExceeded(_, _)).WillByDefault(Return(true));
-
- MessageSharedPtr result_msg(CatchMobileCommandResult(CallRun(*command)));
- EXPECT_EQ(mobile_apis::Result::REJECTED,
- static_cast<mobile_apis::Result::eType>(
- (*result_msg)[am::strings::msg_params][am::strings::result_code]
- .asInt()));
-}
-
-TEST_F(ReadDIDRequestTest, Run_EmptyDidLocation_UNSUCCESS) {
- MockAppPtr app(CreateMockApp());
- SharedPtr<ReadDIDRequest> command(CreateCommand<ReadDIDRequest>());
-
- ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app));
-
- ON_CALL(*app, AreCommandLimitsExceeded(_, _)).WillByDefault(Return(false));
-
- MessageSharedPtr result_msg(CatchMobileCommandResult(CallRun(*command)));
- EXPECT_EQ(mobile_apis::Result::INVALID_DATA,
- static_cast<mobile_apis::Result::eType>(
- (*result_msg)[am::strings::msg_params][am::strings::result_code]
- .asInt()));
-}
-
-TEST_F(ReadDIDRequestTest, Run_SUCCESS) {
- MockAppPtr app(CreateMockApp());
- MessageSharedPtr msg(CreateMessage(smart_objects::SmartType_Map));
- (*msg)[am::strings::msg_params][am::strings::did_location]["SomeData"] = 0;
- SharedPtr<ReadDIDRequest> command(CreateCommand<ReadDIDRequest>(msg));
-
- ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app));
-
- ON_CALL(*app, AreCommandLimitsExceeded(_, _)).WillByDefault(Return(false));
-
- MessageSharedPtr result_msg(CatchHMICommandResult(CallRun(*command)));
- EXPECT_EQ(hmi_apis::FunctionID::VehicleInfo_ReadDID,
- static_cast<hmi_apis::FunctionID::eType>(
- (*result_msg)[am::strings::params][am::strings::function_id]
- .asInt()));
-}
-
-} // namespace read_did_request
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/register_app_interface_request_test.cc b/src/components/application_manager/test/commands/mobile/register_app_interface_request_test.cc
deleted file mode 100644
index b7a004f199..0000000000
--- a/src/components/application_manager/test/commands/mobile/register_app_interface_request_test.cc
+++ /dev/null
@@ -1,522 +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 "mobile/register_app_interface_request.h"
-#include "utils/shared_ptr.h"
-#include "smart_objects/smart_object.h"
-#include "application_manager/commands/commands_test.h"
-#include "application_manager/commands/command_request_test.h"
-#include "application_manager/application.h"
-#include "application_manager/mock_application_manager.h"
-#include "application_manager/mock_application.h"
-#include "application_manager/mock_application_helper.h"
-#include "interfaces/MOBILE_API.h"
-#include "application_manager/smart_object_keys.h"
-#include "application_manager/policies/mock_policy_handler_interface.h"
-#include "protocol_handler/mock_session_observer.h"
-#include "connection_handler/mock_connection_handler.h"
-#include "application_manager/mock_hmi_capabilities.h"
-#include "application_manager/mock_resume_ctrl.h"
-#include "application_manager/mock_hmi_interface.h"
-#include "utils/data_accessor.h"
-#include "utils/custom_string.h"
-#include "utils/lock.h"
-#include "utils/macro.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace register_app_interface_request {
-
-using ::testing::_;
-using ::testing::Return;
-using ::testing::ReturnRef;
-using ::testing::DoAll;
-
-namespace am = ::application_manager;
-
-using ::utils::SharedPtr;
-using am::commands::MessageSharedPtr;
-using am::commands::RegisterAppInterfaceRequest;
-
-namespace {
-const uint32_t kConnectionKey = 1u;
-const hmi_apis::Common_Language::eType kHmiLanguage =
- hmi_apis::Common_Language::EN_US;
-const mobile_apis::Language::eType kMobileLanguage =
- mobile_apis::Language::EN_US;
-const std::string kMacAddress = "test_mac_address";
-const std::string kAppId = "test_app_id";
-const std::string kDummyString = "test_string";
-const std::vector<uint32_t> kDummyDiagModes;
-} // namespace
-
-class RegisterAppInterfaceRequestTest
- : public CommandRequestTest<CommandsTestMocks::kIsNice> {
- public:
- RegisterAppInterfaceRequestTest()
- : msg_(CreateMessage())
- , command_(CreateCommand<RegisterAppInterfaceRequest>(msg_))
- , app_name_("test_app_name_")
- , mock_application_helper_(
- application_manager_test::MockApplicationHelper::
- application_helper_mock()) {
- InitGetters();
- InitLanguage();
- }
-
- void SetUp() OVERRIDE {
- testing::Mock::VerifyAndClearExpectations(&mock_application_helper_);
- }
-
- void TearDown() OVERRIDE {
- testing::Mock::VerifyAndClearExpectations(&mock_application_helper_);
- }
-
- void InitBasicMessage() {
- (*msg_)[am::strings::params][am::strings::connection_key] = kConnectionKey;
- (*msg_)[am::strings::msg_params][am::strings::app_id] = kAppId;
- (*msg_)[am::strings::msg_params][am::strings::app_name] = app_name_;
- (*msg_)[am::strings::msg_params][am::strings::language_desired] =
- kHmiLanguage;
- (*msg_)[am::strings::msg_params]
- [am::strings::hmi_display_language_desired] = kHmiLanguage;
- }
-
- MockAppPtr CreateBasicMockedApp() {
- MockAppPtr mock_app = CreateMockApp();
- ON_CALL(*mock_app, name()).WillByDefault(ReturnRef(app_name_));
- ON_CALL(*mock_app, mac_address()).WillByDefault(ReturnRef(kMacAddress));
- ON_CALL(*mock_app, app_icon_path()).WillByDefault(ReturnRef(kDummyString));
- ON_CALL(*mock_app, language()).WillByDefault(ReturnRef(kMobileLanguage));
- ON_CALL(*mock_app, ui_language()).WillByDefault(ReturnRef(kMobileLanguage));
- ON_CALL(*mock_app, policy_app_id()).WillByDefault(Return(kAppId));
- return mock_app;
- }
-
- void InitLanguage(
- hmi_apis::Common_Language::eType ui_language = kHmiLanguage,
- hmi_apis::Common_Language::eType vr_language = kHmiLanguage,
- hmi_apis::Common_Language::eType tts_language = kHmiLanguage) {
- ON_CALL(mock_hmi_capabilities_, active_vr_language())
- .WillByDefault(Return(vr_language));
- ON_CALL(mock_hmi_capabilities_, active_ui_language())
- .WillByDefault(Return(ui_language));
- ON_CALL(mock_hmi_capabilities_, active_tts_language())
- .WillByDefault(Return(tts_language));
- }
-
- void InitGetters() {
- ON_CALL(app_mngr_, IsHMICooperating()).WillByDefault(Return(true));
- ON_CALL(app_mngr_, GetPolicyHandler())
- .WillByDefault(ReturnRef(mock_policy_handler_));
- ON_CALL(app_mngr_, resume_controller())
- .WillByDefault(ReturnRef(mock_resume_crt_));
- ON_CALL(app_mngr_, connection_handler())
- .WillByDefault(ReturnRef(mock_connection_handler_));
- ON_CALL(mock_connection_handler_, get_session_observer())
- .WillByDefault(ReturnRef(mock_session_observer_));
- ON_CALL(app_mngr_, hmi_capabilities())
- .WillByDefault(ReturnRef(mock_hmi_capabilities_));
- ON_CALL(app_mngr_settings_, sdl_version())
- .WillByDefault(ReturnRef(kDummyString));
- ON_CALL(mock_hmi_capabilities_, ccpu_version())
- .WillByDefault(ReturnRef(kDummyString));
- ON_CALL(app_mngr_settings_, supported_diag_modes())
- .WillByDefault(ReturnRef(kDummyDiagModes));
- ON_CALL(mock_policy_handler_, GetAppRequestTypes(_))
- .WillByDefault(Return(std::vector<std::string>()));
- ON_CALL(mock_policy_handler_, GetUserConsentForDevice(_))
- .WillByDefault(Return(policy::DeviceConsent::kDeviceAllowed));
- ON_CALL(app_mngr_, GetDeviceTransportType(_))
- .WillByDefault(Return(hmi_apis::Common_TransportType::WIFI));
- ON_CALL(app_mngr_, IsAppInReconnectMode(_)).WillByDefault(Return(false));
- ON_CALL(app_mngr_, application_by_policy_id(_))
- .WillByDefault(Return(ApplicationSharedPtr()));
- ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
- .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
- ON_CALL(
- mock_hmi_interfaces_,
- GetInterfaceFromFunction(hmi_apis::FunctionID::VR_ChangeRegistration))
- .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_VR));
- ON_CALL(
- mock_hmi_interfaces_,
- GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_ChangeRegistration))
- .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_TTS));
- ON_CALL(
- mock_hmi_interfaces_,
- GetInterfaceFromFunction(hmi_apis::FunctionID::UI_ChangeRegistration))
- .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
- }
-
- void SetCommonExpectionsOnSwitchedApplication(
- MockAppPtr mock_app, mobile_apis::Result::eType response_result_code) {
- EXPECT_CALL(mock_policy_handler_, AddApplication(_, _)).Times(0);
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(MobileResultCodeIs(response_result_code), _));
-
- EXPECT_CALL(app_mngr_,
- ManageHMICommand(HMIResultCodeIs(
- hmi_apis::FunctionID::BasicCommunication_OnAppRegistered)))
- .Times(0);
-
- EXPECT_CALL(app_mngr_,
- ManageHMICommand(HMIResultCodeIs(
- hmi_apis::FunctionID::Buttons_OnButtonSubscription)))
- .Times(0);
-
- EXPECT_CALL(app_mngr_,
- ManageHMICommand(HMIResultCodeIs(
- hmi_apis::FunctionID::UI_ChangeRegistration))).Times(0);
-
- EXPECT_CALL(app_mngr_,
- ManageHMICommand(HMIResultCodeIs(
- hmi_apis::FunctionID::TTS_ChangeRegistration))).Times(0);
-
- EXPECT_CALL(app_mngr_,
- ManageHMICommand(HMIResultCodeIs(
- hmi_apis::FunctionID::VR_ChangeRegistration))).Times(0);
-
- EXPECT_CALL(
- app_mngr_,
- OnApplicationSwitched(
- MockAppPtr::static_pointer_cast<application_manager::Application>(
- mock_app)));
- }
-
- MessageSharedPtr msg_;
- SharedPtr<RegisterAppInterfaceRequest> command_;
-
- const utils::custom_string::CustomString app_name_;
- sync_primitives::Lock lock_;
- am::ApplicationSet app_set_;
-
- typedef IsNiceMock<policy_test::MockPolicyHandlerInterface,
- kMocksAreNice>::Result MockPolicyHandlerInterface;
-
- typedef IsNiceMock<resumprion_test::MockResumeCtrl, kMocksAreNice>::Result
- MockResumeCtrl;
-
- typedef IsNiceMock<connection_handler_test::MockConnectionHandler,
- kMocksAreNice>::Result MockConnectionHandler;
-
- typedef IsNiceMock<protocol_handler_test::MockSessionObserver,
- kMocksAreNice>::Result MockSessionObserver;
-
- typedef IsNiceMock<application_manager_test::MockHMICapabilities,
- kMocksAreNice>::Result MockHMICapabilities;
-
- MockPolicyHandlerInterface mock_policy_handler_;
- MockResumeCtrl mock_resume_crt_;
- MockConnectionHandler mock_connection_handler_;
- MockSessionObserver mock_session_observer_;
- MockHMICapabilities mock_hmi_capabilities_;
- application_manager_test::MockApplicationHelper& mock_application_helper_;
-};
-
-TEST_F(RegisterAppInterfaceRequestTest, Init_SUCCESS) {
- EXPECT_TRUE(command_->Init());
-}
-
-TEST_F(RegisterAppInterfaceRequestTest, Run_MinimalData_SUCCESS) {
- InitBasicMessage();
- (*msg_)[am::strings::msg_params][am::strings::hash_id] = kAppId;
- EXPECT_CALL(app_mngr_, IsStopping())
- .WillOnce(Return(false))
- .WillOnce(Return(true))
- .WillOnce(Return(false));
- ON_CALL(app_mngr_, IsHMICooperating()).WillByDefault(Return(false));
- EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _));
- EXPECT_CALL(app_mngr_, IsApplicationForbidden(_, _)).WillOnce(Return(false));
-
- MockAppPtr mock_app = CreateBasicMockedApp();
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(ApplicationSharedPtr()))
- .WillRepeatedly(Return(mock_app));
-
- ON_CALL(app_mngr_, applications())
- .WillByDefault(Return(DataAccessor<am::ApplicationSet>(app_set_, lock_)));
- ON_CALL(mock_policy_handler_, PolicyEnabled()).WillByDefault(Return(true));
- ON_CALL(mock_policy_handler_, GetInitialAppData(kAppId, _, _))
- .WillByDefault(Return(true));
- policy::StatusNotifier notify_upd_manager =
- utils::MakeShared<utils::CallNothing>();
- ON_CALL(mock_policy_handler_, AddApplication(_, _))
- .WillByDefault(Return(notify_upd_manager));
-
- EXPECT_CALL(app_mngr_, RegisterApplication(msg_)).WillOnce(Return(mock_app));
- EXPECT_CALL(app_mngr_,
- ManageHMICommand(HMIResultCodeIs(
- hmi_apis::FunctionID::BasicCommunication_OnAppRegistered)))
- .WillOnce(Return(true));
- EXPECT_CALL(app_mngr_,
- ManageHMICommand(HMIResultCodeIs(
- hmi_apis::FunctionID::Buttons_OnButtonSubscription)))
- .WillOnce(Return(true));
- EXPECT_CALL(app_mngr_,
- ManageMobileCommand(_, am::commands::Command::ORIGIN_SDL))
- .Times(2);
- command_->Run();
-}
-
-MATCHER_P(CheckHMIInterfacesRealtedData, expected_data, "") {
- const bool is_result_id_correct =
- mobile_apis::Result::SUCCESS ==
- static_cast<mobile_apis::Result::eType>(
- (*arg)[am::strings::msg_params][am::strings::result_code].asInt());
-
- const bool are_ui_related_data_exist =
- (*arg)[am::strings::msg_params].keyExists(
- am::hmi_response::display_capabilities);
-
- const bool are_vi_related_data_exist =
- (*arg)[am::strings::msg_params][am::hmi_response::vehicle_type] ==
- (*expected_data)[am::hmi_response::vehicle_type];
-
- const bool are_vr_related_data_exist =
- (*arg)[am::strings::msg_params][am::strings::vr_capabilities] ==
- (*expected_data)[am::strings::vr_capabilities];
-
- return is_result_id_correct && are_ui_related_data_exist &&
- are_vi_related_data_exist && are_vr_related_data_exist;
-}
-
-TEST_F(RegisterAppInterfaceRequestTest,
- Run_HmiInterfacesStateAvailable_SUCCESS) {
- InitBasicMessage();
-
- EXPECT_CALL(app_mngr_, IsStopping())
- .WillOnce(Return(false))
- .WillOnce(Return(true))
- .WillOnce(Return(false));
- ON_CALL(app_mngr_, IsHMICooperating()).WillByDefault(Return(false));
- EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _));
- EXPECT_CALL(app_mngr_, IsApplicationForbidden(_, _)).WillOnce(Return(false));
-
- MockAppPtr mock_app = CreateBasicMockedApp();
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(ApplicationSharedPtr()))
- .WillRepeatedly(Return(mock_app));
-
- MessageSharedPtr expected_message =
- CreateMessage(smart_objects::SmartType_Map);
-
- (*expected_message)[am::hmi_response::vehicle_type] = "test_vehicle_type";
- (*expected_message)[am::strings::vr_capabilities] = "test_vr_capabilities";
- (*expected_message)[am::hmi_response::display_capabilities] = 0;
- SmartObject& display_capabilities =
- (*expected_message)[am::hmi_response::display_capabilities];
- display_capabilities[am::hmi_response::display_type] = "test_display_type";
- display_capabilities[am::hmi_response::text_fields] = "test_text_fields";
- display_capabilities[am::hmi_response::image_fields] = "test_image_fields";
- display_capabilities[am::hmi_response::media_clock_formats] =
- "test_media_clock_formats";
- display_capabilities[am::hmi_response::num_custom_presets_available] =
- "test_num_custom_presets_available";
- display_capabilities[am::hmi_response::graphic_supported] =
- "test_graphic_supported";
- display_capabilities[am::hmi_response::templates_available] =
- "test_templates_available";
- display_capabilities[am::hmi_response::screen_params] = "test_screen_params";
-
- ON_CALL(mock_hmi_capabilities_, vehicle_type())
- .WillByDefault(
- Return(&(*expected_message)[am::hmi_response::vehicle_type]));
- ON_CALL(mock_hmi_capabilities_, vr_capabilities())
- .WillByDefault(
- Return(&(*expected_message)[am::strings::vr_capabilities]));
- ON_CALL(mock_hmi_capabilities_, display_capabilities())
- .WillByDefault(
- Return(&(*expected_message)[am::hmi_response::display_capabilities]));
-
- ON_CALL(app_mngr_, applications())
- .WillByDefault(Return(DataAccessor<am::ApplicationSet>(app_set_, lock_)));
- ON_CALL(mock_policy_handler_, PolicyEnabled()).WillByDefault(Return(true));
- ON_CALL(mock_policy_handler_, GetInitialAppData(kAppId, _, _))
- .WillByDefault(Return(true));
- policy::StatusNotifier notify_upd_manager =
- utils::MakeShared<utils::CallNothing>();
- ON_CALL(mock_policy_handler_, AddApplication(_, _))
- .WillByDefault(Return(notify_upd_manager));
-
- EXPECT_CALL(app_mngr_, RegisterApplication(msg_)).WillOnce(Return(mock_app));
-
- EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
- .WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE));
-
- EXPECT_CALL(app_mngr_,
- ManageHMICommand(HMIResultCodeIs(
- hmi_apis::FunctionID::BasicCommunication_OnAppRegistered)))
- .WillOnce(Return(true));
- EXPECT_CALL(app_mngr_,
- ManageHMICommand(HMIResultCodeIs(
- hmi_apis::FunctionID::Buttons_OnButtonSubscription)))
- .WillOnce(Return(true));
- EXPECT_CALL(app_mngr_,
- ManageHMICommand(
- HMIResultCodeIs(hmi_apis::FunctionID::VR_ChangeRegistration)))
- .WillOnce(Return(true));
- EXPECT_CALL(app_mngr_,
- ManageHMICommand(HMIResultCodeIs(
- hmi_apis::FunctionID::TTS_ChangeRegistration)))
- .WillOnce(Return(true));
- EXPECT_CALL(app_mngr_,
- ManageHMICommand(
- HMIResultCodeIs(hmi_apis::FunctionID::UI_ChangeRegistration)))
- .WillOnce(Return(true));
- EXPECT_CALL(app_mngr_,
- ManageMobileCommand(_, am::commands::Command::ORIGIN_SDL))
- .Times(2);
-
- command_->Run();
-}
-
-TEST_F(RegisterAppInterfaceRequestTest,
- SwitchApplication_CorrectHash_ExpectNoCleanupSuccess) {
- InitBasicMessage();
-
- const std::string request_hash_id = "abc123";
- (*msg_)[am::strings::msg_params][am::strings::hash_id] = request_hash_id;
-
- MockAppPtr mock_app = CreateBasicMockedApp();
- EXPECT_CALL(app_mngr_, application_by_policy_id(kAppId))
- .WillRepeatedly(Return(mock_app));
-
- EXPECT_CALL(app_mngr_, IsAppInReconnectMode(kAppId)).WillOnce(Return(true));
-
- EXPECT_CALL(app_mngr_, ProcessReconnection(_, kConnectionKey));
-
- EXPECT_CALL(app_mngr_, RegisterApplication(msg_)).Times(0);
-
- EXPECT_CALL(
- mock_resume_crt_,
- CheckApplicationHash(
- MockAppPtr::static_pointer_cast<application_manager::Application>(
- mock_app),
- request_hash_id)).WillOnce(Return(true));
-
- EXPECT_CALL(mock_resume_crt_, RemoveApplicationFromSaved(_)).Times(0);
-
- EXPECT_CALL(mock_application_helper_, RecallApplicationData(_, _)).Times(0);
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillRepeatedly(Return(mock_app));
-
- SetCommonExpectionsOnSwitchedApplication(mock_app,
- mobile_apis::Result::SUCCESS);
-
- command_->Run();
-}
-
-TEST_F(RegisterAppInterfaceRequestTest,
- SwitchApplication_WrongHash_ExpectCleanupResumeFailed) {
- InitBasicMessage();
-
- const std::string request_hash_id = "abc123";
- (*msg_)[am::strings::msg_params][am::strings::hash_id] = request_hash_id;
-
- MockAppPtr mock_app = CreateBasicMockedApp();
- EXPECT_CALL(app_mngr_, application_by_policy_id(kAppId))
- .WillRepeatedly(Return(mock_app));
-
- EXPECT_CALL(app_mngr_, IsAppInReconnectMode(kAppId)).WillOnce(Return(true));
-
- EXPECT_CALL(app_mngr_, ProcessReconnection(_, kConnectionKey));
-
- EXPECT_CALL(
- mock_resume_crt_,
- CheckApplicationHash(
- MockAppPtr::static_pointer_cast<application_manager::Application>(
- mock_app),
- request_hash_id)).WillOnce(Return(false));
-
- EXPECT_CALL(
- mock_application_helper_,
- RecallApplicationData(
- MockAppPtr::static_pointer_cast<application_manager::Application>(
- mock_app),
- _));
-
- EXPECT_CALL(app_mngr_, RegisterApplication(msg_)).Times(0);
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillRepeatedly(Return(mock_app));
-
- SetCommonExpectionsOnSwitchedApplication(mock_app,
- mobile_apis::Result::RESUME_FAILED);
-
- command_->Run();
-}
-
-TEST_F(RegisterAppInterfaceRequestTest,
- SwitchApplication_NoHash_ExpectCleanupResumeFailed) {
- InitBasicMessage();
-
- MockAppPtr mock_app = CreateBasicMockedApp();
- EXPECT_CALL(app_mngr_, application_by_policy_id(kAppId))
- .WillRepeatedly(Return(mock_app));
-
- EXPECT_CALL(app_mngr_, IsAppInReconnectMode(kAppId)).WillOnce(Return(true));
-
- EXPECT_CALL(app_mngr_, ProcessReconnection(_, kConnectionKey));
-
- EXPECT_CALL(
- mock_application_helper_,
- RecallApplicationData(
- MockAppPtr::static_pointer_cast<application_manager::Application>(
- mock_app),
- _));
-
- EXPECT_CALL(app_mngr_, RegisterApplication(msg_)).Times(0);
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillRepeatedly(Return(mock_app));
-
- SetCommonExpectionsOnSwitchedApplication(mock_app,
- mobile_apis::Result::RESUME_FAILED);
-
- command_->Run();
-}
-
-} // namespace register_app_interface_request
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/reset_global_properties_test.cc b/src/components/application_manager/test/commands/mobile/reset_global_properties_test.cc
deleted file mode 100644
index 69fee02262..0000000000
--- a/src/components/application_manager/test/commands/mobile/reset_global_properties_test.cc
+++ /dev/null
@@ -1,565 +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 "mobile/reset_global_properties_request.h"
-#include "mobile/reset_global_properties_response.h"
-
-#include "gtest/gtest.h"
-#include "utils/shared_ptr.h"
-#include "utils/make_shared.h"
-#include "smart_objects/smart_object.h"
-#include "interfaces/HMI_API.h"
-#include "interfaces/MOBILE_API.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/mock_application_manager.h"
-#include "application_manager/mock_application.h"
-#include "application_manager/mock_message_helper.h"
-#include "application_manager/event_engine/event.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace reset_global_properties {
-
-using ::testing::_;
-using ::testing::Return;
-using ::testing::ReturnRef;
-
-namespace am = ::application_manager;
-
-using am::commands::ResetGlobalPropertiesRequest;
-using am::commands::ResetGlobalPropertiesResponse;
-using am::commands::MessageSharedPtr;
-using am::event_engine::Event;
-using am::MockMessageHelper;
-
-typedef SharedPtr<ResetGlobalPropertiesRequest> ResetGlobalPropertiesRequestPtr;
-typedef SharedPtr<ResetGlobalPropertiesResponse>
- ResetGlobalPropertiesResponsePtr;
-
-namespace {
-const uint32_t kConnectionKey = 2u;
-const uint32_t kCorrelationId = 10u;
-} // namespace
-
-class ResetGlobalPropertiesRequestTest
- : public CommandRequestTest<CommandsTestMocks::kIsNice> {
- protected:
- ResetGlobalPropertiesRequestTest()
- : msg_(CreateMessage()), mock_app_(CreateMockApp()) {}
-
- void SetUp() OVERRIDE {
- (*msg_)[am::strings::params][am::strings::connection_key] = kConnectionKey;
- (*msg_)[am::strings::params][am::strings::correlation_id] = kCorrelationId;
-
- command_ = CreateCommand<ResetGlobalPropertiesRequest>(msg_);
-
- ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey));
- ON_CALL(app_mngr_, application(kConnectionKey))
- .WillByDefault(Return(mock_app_));
- ON_CALL(app_mngr_, GetNextHMICorrelationID())
- .WillByDefault(Return(kCorrelationId));
- }
-
- MessageSharedPtr msg_;
- MockAppPtr mock_app_;
- ResetGlobalPropertiesRequestPtr command_;
-};
-
-class ResetGlobalPropertiesResponseTest
- : public CommandsTest<CommandsTestMocks::kIsNice> {};
-
-TEST_F(ResetGlobalPropertiesRequestTest, Run_InvalidApp_UNSUCCESS) {
- MockAppPtr invalid_app;
- EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(invalid_app));
-
- MessageSharedPtr command_result;
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
- .WillOnce(DoAll(SaveArg<0>(&command_result), Return(true)));
-
- command_->Run();
- EXPECT_EQ(
- (*command_result)[am::strings::msg_params][am::strings::success].asBool(),
- false);
- EXPECT_EQ(
- (*command_result)[am::strings::msg_params][am::strings::result_code]
- .asInt(),
- static_cast<int32_t>(mobile_apis::Result::APPLICATION_NOT_REGISTERED));
-}
-
-TEST_F(ResetGlobalPropertiesRequestTest, Run_InvalidVrHelp_UNSUCCESS) {
- (*msg_)[am::strings::msg_params][am::strings::properties][0] =
- mobile_apis::GlobalProperty::HELPPROMPT;
- (*msg_)[am::strings::msg_params][am::strings::properties][1] =
- mobile_apis::GlobalProperty::TIMEOUTPROMPT;
- (*msg_)[am::strings::msg_params][am::strings::properties][2] =
- mobile_apis::GlobalProperty::VRHELPTITLE;
- (*msg_)[am::strings::msg_params][am::strings::properties][3] =
- mobile_apis::GlobalProperty::MENUNAME;
- (*msg_)[am::strings::msg_params][am::strings::properties][4] =
- mobile_apis::GlobalProperty::MENUICON;
- (*msg_)[am::strings::msg_params][am::strings::properties][5] =
- mobile_apis::GlobalProperty::KEYBOARDPROPERTIES;
-
- EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey));
- smart_objects::SmartObject so_prompt =
- smart_objects::SmartObject(smart_objects::SmartType_Array);
- EXPECT_CALL(*mock_app_, set_help_prompt(so_prompt));
-
- std::vector<std::string> time_out_prompt;
- time_out_prompt.push_back("time_out");
- EXPECT_CALL(app_mngr_settings_, time_out_promt())
- .WillOnce(ReturnRef(time_out_prompt));
-
- smart_objects::SmartObject timeout_prompt =
- smart_objects::SmartObject(smart_objects::SmartType_Map);
- timeout_prompt[am::strings::text] = time_out_prompt[0];
- timeout_prompt[am::strings::type] =
- hmi_apis::Common_SpeechCapabilities::SC_TEXT;
-
- smart_objects::SmartObject so_time_out_prompt =
- smart_objects::SmartObject(smart_objects::SmartType_Array);
-
- so_time_out_prompt[0] = timeout_prompt;
-
- EXPECT_CALL(*mock_app_, set_timeout_prompt(so_time_out_prompt));
-
- EXPECT_CALL(*mock_app_, reset_vr_help_title());
- EXPECT_CALL(*mock_app_, reset_vr_help());
-
- EXPECT_CALL(*mock_app_, set_reset_global_properties_active(true));
-
- smart_objects::SmartObjectSPtr vr_help; // = NULL;
- EXPECT_CALL(mock_message_helper_, CreateAppVrHelp(_))
- .WillOnce(Return(vr_help));
-
- EXPECT_CALL(app_mngr_, ManageHMICommand(_)).Times(0);
-
- command_->Run();
-}
-
-TEST_F(ResetGlobalPropertiesRequestTest, Run_SUCCESS) {
- (*msg_)[am::strings::msg_params][am::strings::properties][0] =
- mobile_apis::GlobalProperty::HELPPROMPT;
- (*msg_)[am::strings::msg_params][am::strings::properties][1] =
- mobile_apis::GlobalProperty::TIMEOUTPROMPT;
- (*msg_)[am::strings::msg_params][am::strings::properties][2] =
- mobile_apis::GlobalProperty::VRHELPTITLE;
- (*msg_)[am::strings::msg_params][am::strings::properties][3] =
- mobile_apis::GlobalProperty::MENUNAME;
- (*msg_)[am::strings::msg_params][am::strings::properties][4] =
- mobile_apis::GlobalProperty::MENUICON;
- (*msg_)[am::strings::msg_params][am::strings::properties][5] =
- mobile_apis::GlobalProperty::KEYBOARDPROPERTIES;
-
- EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey));
- smart_objects::SmartObject so_prompt =
- smart_objects::SmartObject(smart_objects::SmartType_Array);
- EXPECT_CALL(*mock_app_, set_help_prompt(so_prompt));
-
- std::vector<std::string> time_out_prompt;
- time_out_prompt.push_back("time_out");
- EXPECT_CALL(app_mngr_settings_, time_out_promt())
- .WillOnce(ReturnRef(time_out_prompt));
-
- smart_objects::SmartObject timeout_prompt =
- smart_objects::SmartObject(smart_objects::SmartType_Map);
- timeout_prompt[am::strings::text] = time_out_prompt[0];
- timeout_prompt[am::strings::type] =
- hmi_apis::Common_SpeechCapabilities::SC_TEXT;
-
- smart_objects::SmartObject so_time_out_prompt =
- smart_objects::SmartObject(smart_objects::SmartType_Array);
-
- so_time_out_prompt[0] = timeout_prompt;
-
- EXPECT_CALL(*mock_app_, set_timeout_prompt(so_time_out_prompt));
-
- EXPECT_CALL(*mock_app_, reset_vr_help_title());
- EXPECT_CALL(*mock_app_, reset_vr_help());
-
- EXPECT_CALL(*mock_app_, set_reset_global_properties_active(true));
-
- smart_objects::SmartObjectSPtr vr_help =
- ::utils::MakeShared<smart_objects::SmartObject>(
- smart_objects::SmartType_Map);
- EXPECT_CALL(mock_message_helper_, CreateAppVrHelp(_))
- .WillOnce(Return(vr_help));
-
- smart_objects::SmartObject msg_params =
- smart_objects::SmartObject(smart_objects::SmartType_Map);
- msg_params[am::hmi_request::menu_title] = "";
-
- EXPECT_CALL(*mock_app_,
- set_menu_title(msg_params[am::hmi_request::menu_title]));
-
- const smart_objects::SmartObjectSPtr so_help_prompt =
- ::utils::MakeShared<smart_objects::SmartObject>(
- smart_objects::SmartType_Map);
- EXPECT_CALL(*mock_app_, help_prompt()).WillOnce(Return(so_help_prompt.get()));
- EXPECT_CALL(*mock_app_, timeout_prompt())
- .WillOnce(Return(so_help_prompt.get()));
-
- EXPECT_CALL(app_mngr_,
- ManageHMICommand(HMIResultCodeIs(
- hmi_apis::FunctionID::UI_SetGlobalProperties)))
- .WillOnce(Return(true));
- EXPECT_CALL(app_mngr_,
- ManageHMICommand(HMIResultCodeIs(
- hmi_apis::FunctionID::TTS_SetGlobalProperties)))
- .WillOnce(Return(true));
-
- command_->Run();
-}
-
-TEST_F(ResetGlobalPropertiesRequestTest, OnEvent_InvalidEventId_UNSUCCESS) {
- Event event(hmi_apis::FunctionID::INVALID_ENUM);
-
- EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0);
- command_->on_event(event);
-}
-
-TEST_F(ResetGlobalPropertiesRequestTest,
- OnEvent_UI_SetGlobalProperties_SUCCESS) {
- Event event(hmi_apis::FunctionID::UI_SetGlobalProperties);
- const hmi_apis::Common_Result::eType result_code =
- hmi_apis::Common_Result::SUCCESS;
- (*msg_)[am::strings::params][am::hmi_response::code] = result_code;
-
- (*msg_)[am::strings::msg_params][am::strings::properties][0] =
- mobile_apis::GlobalProperty::VRHELPTITLE;
-
- EXPECT_CALL(*mock_app_, reset_vr_help_title());
- EXPECT_CALL(*mock_app_, reset_vr_help());
- EXPECT_CALL(*mock_app_, set_reset_global_properties_active(true));
-
- smart_objects::SmartObjectSPtr vr_help =
- ::utils::MakeShared<smart_objects::SmartObject>(
- smart_objects::SmartType_Map);
- EXPECT_CALL(mock_message_helper_, CreateAppVrHelp(_))
- .WillOnce(Return(vr_help));
-
- command_->Run();
-
- event.set_smart_object(*msg_);
-
- EXPECT_CALL(app_mngr_,
- ManageMobileCommand(
- MobileResultCodeIs(mobile_apis::Result::eType::SUCCESS),
- am::commands::Command::ORIGIN_SDL));
-
- command_->on_event(event);
-}
-
-TEST_F(ResetGlobalPropertiesRequestTest,
- OnEvent_TTS_SetGlobalProperties_SUCCESS) {
- Event event(hmi_apis::FunctionID::TTS_SetGlobalProperties);
- (*msg_)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::eType::UNSUPPORTED_RESOURCE;
-
- (*msg_)[am::strings::msg_params][am::strings::properties][0] =
- mobile_apis::GlobalProperty::TIMEOUTPROMPT;
- (*msg_)[am::strings::msg_params][am::strings::properties][1] =
- mobile_apis::GlobalProperty::MENUICON;
-
- std::vector<std::string> time_out_prompt;
- time_out_prompt.push_back("time_out");
- EXPECT_CALL(app_mngr_settings_, time_out_promt())
- .WillOnce(ReturnRef(time_out_prompt));
-
- EXPECT_CALL(*mock_app_, set_timeout_prompt(_));
-
- smart_objects::SmartObjectSPtr prompt =
- utils::MakeShared<smart_objects::SmartObject>();
- *prompt = "prompt";
-
- EXPECT_CALL(*mock_app_, timeout_prompt()).WillOnce(Return(prompt.get()));
-
- EXPECT_CALL(*mock_app_, set_reset_global_properties_active(true));
-
- MessageSharedPtr ui_msg = CreateMessage();
- (*ui_msg)[am::strings::params][am::strings::correlation_id] = kCorrelationId;
- (*ui_msg)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::eType::SUCCESS;
-
- Event ui_event(hmi_apis::FunctionID::UI_SetGlobalProperties);
- ui_event.set_smart_object(*ui_msg);
-
- command_->Run();
- command_->on_event(ui_event);
- event.set_smart_object(*msg_);
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::WARNINGS),
- am::commands::Command::ORIGIN_SDL));
-
- command_->on_event(event);
-}
-
-TEST_F(ResetGlobalPropertiesResponseTest, Run_Sendmsg_SUCCESS) {
- MessageSharedPtr message(CreateMessage());
- ResetGlobalPropertiesResponsePtr command(
- CreateCommand<ResetGlobalPropertiesResponse>(message));
-
- EXPECT_CALL(app_mngr_, SendMessageToMobile(message, _));
- command->Run();
-}
-
-TEST_F(ResetGlobalPropertiesRequestTest, OnEvent_InvalidApp_NoHashUpdate) {
- (*msg_)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::eType::SUCCESS;
-
- (*msg_)[am::strings::msg_params][am::strings::properties][0] =
- mobile_apis::GlobalProperty::VRHELPTITLE;
-
- EXPECT_CALL(*mock_app_, reset_vr_help_title());
- EXPECT_CALL(*mock_app_, reset_vr_help());
-
- EXPECT_CALL(*mock_app_, set_reset_global_properties_active(true));
-
- smart_objects::SmartObjectSPtr vr_help =
- ::utils::MakeShared<smart_objects::SmartObject>(
- smart_objects::SmartType_Map);
- EXPECT_CALL(mock_message_helper_, CreateAppVrHelp(_))
- .WillOnce(Return(vr_help));
-
- EXPECT_CALL(*mock_app_, UpdateHash()).Times(0);
-
- ResetGlobalPropertiesRequestPtr command =
- CreateCommand<ResetGlobalPropertiesRequest>(msg_);
- command->Run();
-
- EXPECT_CALL(app_mngr_,
- ManageMobileCommand(
- MobileResultCodeIs(mobile_apis::Result::eType::SUCCESS),
- am::commands::Command::ORIGIN_SDL));
-
- Event event(hmi_apis::FunctionID::UI_SetGlobalProperties);
- event.set_smart_object(*msg_);
- command->on_event(event);
-}
-
-TEST_F(ResetGlobalPropertiesRequestTest,
- Run_WaitTTS_Timeout_GENERIC_ERROR_TTSNotRespond) {
- (*msg_)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::eType::UNSUPPORTED_RESOURCE;
-
- (*msg_)[am::strings::msg_params][am::strings::properties][0] =
- mobile_apis::GlobalProperty::TIMEOUTPROMPT;
- (*msg_)[am::strings::msg_params][am::strings::properties][1] =
- mobile_apis::GlobalProperty::MENUICON;
-
- std::vector<std::string> time_out_prompt;
- time_out_prompt.push_back("time_out");
- EXPECT_CALL(app_mngr_settings_, time_out_promt())
- .WillOnce(ReturnRef(time_out_prompt));
-
- EXPECT_CALL(*mock_app_, set_timeout_prompt(_));
-
- smart_objects::SmartObjectSPtr prompt =
- utils::MakeShared<smart_objects::SmartObject>();
- *prompt = "prompt";
-
- EXPECT_CALL(*mock_app_, timeout_prompt()).WillOnce(Return(prompt.get()));
-
- EXPECT_CALL(*mock_app_, set_reset_global_properties_active(true));
-
- EXPECT_CALL(app_mngr_,
- ManageHMICommand(HMIResultCodeIs(
- hmi_apis::FunctionID::UI_SetGlobalProperties)))
- .WillOnce(Return(true));
- EXPECT_CALL(app_mngr_,
- ManageHMICommand(HMIResultCodeIs(
- hmi_apis::FunctionID::TTS_SetGlobalProperties)))
- .WillOnce(Return(true));
-
- ResetGlobalPropertiesRequestPtr command =
- CreateCommand<ResetGlobalPropertiesRequest>(msg_);
- command->Run();
-
- // Received response only from UI
- MessageSharedPtr ui_msg = CreateMessage();
- (*ui_msg)[am::strings::params][am::strings::correlation_id] = kCorrelationId;
- (*ui_msg)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::eType::SUCCESS;
- (*ui_msg)[am::strings::msg_params] =
- SmartObject(smart_objects::SmartType_Map);
- Event ui_event(hmi_apis::FunctionID::UI_SetGlobalProperties);
- ui_event.set_smart_object(*ui_msg);
- command->on_event(ui_event);
-
- // TTS doesn't respond, so timeout should send generic error
- smart_objects::SmartObjectSPtr response =
- utils::MakeShared<smart_objects::SmartObject>();
- (*response)[am::strings::msg_params][am::strings::result_code] =
- mobile_apis::Result::GENERIC_ERROR;
- EXPECT_CALL(mock_message_helper_, CreateNegativeResponse(_, _, _, _))
- .WillOnce(Return(response));
- const std::string info = "TTS component does not respond";
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(
- MobileResponseIs(mobile_apis::Result::GENERIC_ERROR, info, false),
- am::commands::Command::ORIGIN_SDL));
- command->onTimeOut();
-}
-
-TEST_F(ResetGlobalPropertiesRequestTest,
- Run_WaitUI_Timeout_GENERIC_ERROR_UINotRespond) {
- (*msg_)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::eType::UNSUPPORTED_RESOURCE;
-
- (*msg_)[am::strings::msg_params][am::strings::properties][0] =
- mobile_apis::GlobalProperty::TIMEOUTPROMPT;
- (*msg_)[am::strings::msg_params][am::strings::properties][1] =
- mobile_apis::GlobalProperty::MENUICON;
-
- std::vector<std::string> time_out_prompt;
- time_out_prompt.push_back("time_out");
- EXPECT_CALL(app_mngr_settings_, time_out_promt())
- .WillOnce(ReturnRef(time_out_prompt));
-
- EXPECT_CALL(*mock_app_, set_timeout_prompt(_));
-
- smart_objects::SmartObjectSPtr prompt =
- utils::MakeShared<smart_objects::SmartObject>();
- *prompt = "prompt";
-
- EXPECT_CALL(*mock_app_, timeout_prompt()).WillOnce(Return(prompt.get()));
-
- EXPECT_CALL(*mock_app_, set_reset_global_properties_active(true));
-
- EXPECT_CALL(app_mngr_,
- ManageHMICommand(HMIResultCodeIs(
- hmi_apis::FunctionID::UI_SetGlobalProperties)))
- .WillOnce(Return(true));
- EXPECT_CALL(app_mngr_,
- ManageHMICommand(HMIResultCodeIs(
- hmi_apis::FunctionID::TTS_SetGlobalProperties)))
- .WillOnce(Return(true));
-
- command_->Run();
-
- // Received response only from TTS
- MessageSharedPtr tts_msg = CreateMessage();
- (*tts_msg)[am::strings::params][am::strings::correlation_id] = kCorrelationId;
- (*tts_msg)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::eType::SUCCESS;
-
- Event tts_event(hmi_apis::FunctionID::TTS_SetGlobalProperties);
- tts_event.set_smart_object(*tts_msg);
- command_->on_event(tts_event);
-
- // UI doesn't respond, so timeout should send generic error
- smart_objects::SmartObjectSPtr response =
- utils::MakeShared<smart_objects::SmartObject>();
- (*response)[am::strings::msg_params][am::strings::result_code] =
- mobile_apis::Result::GENERIC_ERROR;
- EXPECT_CALL(mock_message_helper_, CreateNegativeResponse(_, _, _, _))
- .WillOnce(Return(response));
-
- const std::string info = "UI component does not respond";
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(
- MobileResponseIs(mobile_apis::Result::GENERIC_ERROR, info, false),
- am::commands::Command::ORIGIN_SDL));
- command_->onTimeOut();
-}
-
-TEST_F(ResetGlobalPropertiesRequestTest,
- Run_WaitUIAndTTS_Timeout_GENERIC_ERROR_TTSAndUINotRespond) {
- Event event(hmi_apis::FunctionID::TTS_SetGlobalProperties);
- (*msg_)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::eType::UNSUPPORTED_RESOURCE;
-
- (*msg_)[am::strings::msg_params][am::strings::properties][0] =
- mobile_apis::GlobalProperty::TIMEOUTPROMPT;
- (*msg_)[am::strings::msg_params][am::strings::properties][1] =
- mobile_apis::GlobalProperty::MENUICON;
-
- std::vector<std::string> time_out_prompt;
- time_out_prompt.push_back("time_out");
- EXPECT_CALL(app_mngr_settings_, time_out_promt())
- .WillOnce(ReturnRef(time_out_prompt));
-
- EXPECT_CALL(*mock_app_, set_timeout_prompt(_));
-
- smart_objects::SmartObjectSPtr prompt =
- utils::MakeShared<smart_objects::SmartObject>();
- *prompt = "prompt";
-
- EXPECT_CALL(*mock_app_, timeout_prompt()).WillOnce(Return(prompt.get()));
-
- EXPECT_CALL(*mock_app_, set_reset_global_properties_active(true));
-
- EXPECT_CALL(app_mngr_,
- ManageHMICommand(HMIResultCodeIs(
- hmi_apis::FunctionID::UI_SetGlobalProperties)))
- .WillOnce(Return(true));
- EXPECT_CALL(app_mngr_,
- ManageHMICommand(HMIResultCodeIs(
- hmi_apis::FunctionID::TTS_SetGlobalProperties)))
- .WillOnce(Return(true));
-
- command_->Run();
- // TTS and UI don't respond, so timeout should send generic error
- std::string info = "TTS, UI component does not respond";
- smart_objects::SmartObjectSPtr response =
- utils::MakeShared<smart_objects::SmartObject>();
- (*response)[am::strings::msg_params][am::strings::result_code] =
- mobile_apis::Result::GENERIC_ERROR;
- EXPECT_CALL(mock_message_helper_, CreateNegativeResponse(_, _, _, _))
- .WillOnce(Return(response));
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(
- MobileResponseIs(mobile_apis::Result::GENERIC_ERROR, info, false),
- am::commands::Command::ORIGIN_SDL));
- command_->onTimeOut();
-}
-
-} // namespace reset_global_properties
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/scrollable_message_test.cc b/src/components/application_manager/test/commands/mobile/scrollable_message_test.cc
deleted file mode 100644
index 4520e1b120..0000000000
--- a/src/components/application_manager/test/commands/mobile/scrollable_message_test.cc
+++ /dev/null
@@ -1,289 +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 <set>
-
-#include "application_manager/commands/mobile/scrollable_message_request.h"
-
-#include "gtest/gtest.h"
-#include "application_manager/commands/command_request_test.h"
-#include "application_manager/mock_application.h"
-#include "application_manager/mock_application_manager.h"
-#include "application_manager/mock_message_helper.h"
-#include "application_manager/event_engine/event.h"
-#include "application_manager/mock_hmi_interface.h"
-#include "application_manager/mock_hmi_capabilities.h"
-#include "application_manager/policies/mock_policy_handler_interface.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace scrollable_message_request {
-
-namespace am = application_manager;
-namespace hmi_response = am::hmi_response;
-namespace mobile_result = mobile_apis::Result;
-namespace am = ::application_manager;
-
-using am::commands::ScrollableMessageRequest;
-using am::commands::CommandImpl;
-using am::commands::MessageSharedPtr;
-using am::MockMessageHelper;
-using ::utils::SharedPtr;
-using ::testing::_;
-using ::testing::Eq;
-using ::testing::Ref;
-using ::testing::Return;
-using ::testing::ReturnRef;
-
-using namespace am::strings;
-using test::components::policy_test::MockPolicyHandlerInterface;
-
-namespace {
-const uint32_t kAppId = 1u;
-const uint32_t kCmdId = 1u;
-const uint32_t kConnectionKey = 2u;
-const uint32_t kTimeOut = 30000u;
-const uint32_t kCorrelationId = 10u;
-const uint32_t kFunctionID = 3u;
-} // namespace
-
-class ScrollableMessageRequestTest
- : public CommandRequestTest<CommandsTestMocks::kIsNice> {
- public:
- typedef TypeIf<kMocksAreNice,
- NiceMock<application_manager_test::MockHMICapabilities>,
- application_manager_test::MockHMICapabilities>::Result
- MockHMICapabilities;
- sync_primitives::Lock lock_;
-
- MessageSharedPtr CreateFullParamsUISO() {
- MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
- (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey;
- smart_objects::SmartObject menu_params =
- smart_objects::SmartObject(smart_objects::SmartType_Map);
- menu_params[am::strings::position] = 10;
- menu_params[am::strings::menu_name] = "LG";
-
- smart_objects::SmartObject msg_params =
- smart_objects::SmartObject(smart_objects::SmartType_Map);
- msg_params[am::strings::cmd_id] = kCmdId;
- msg_params[am::strings::menu_params] = menu_params;
- msg_params[am::strings::app_id] = kAppId;
- msg_params[am::strings::cmd_icon] = 1;
- msg_params[am::strings::cmd_icon][am::strings::value] = "10";
- (*msg)[am::strings::msg_params] = msg_params;
-
- return msg;
- }
-
- void SetUp() OVERRIDE {
- mock_app_ = CreateMockApp();
- ON_CALL(app_mngr_, GetPolicyHandler())
- .WillByDefault(ReturnRef(mock_policy_handler_));
- command_ = CreateCommand<ScrollableMessageRequest>(msg_);
- }
-
- MockPolicyHandlerInterface mock_policy_handler_;
- MockAppPtr mock_app_;
- MessageSharedPtr msg_;
- SharedPtr<ScrollableMessageRequest> command_;
-};
-
-typedef ScrollableMessageRequestTest::MockHMICapabilities MockHMICapabilities;
-
-TEST_F(ScrollableMessageRequestTest, OnEvent_UI_UNSUPPORTED_RESOURCE) {
- MessageSharedPtr msg_ui = CreateFullParamsUISO();
- (*msg_ui)[am::strings::params][am::strings::connection_key] = kConnectionKey;
-
- utils::SharedPtr<ScrollableMessageRequest> command =
- CreateCommand<ScrollableMessageRequest>(msg_ui);
-
- MockAppPtr mock_app = CreateMockApp();
- ON_CALL(app_mngr_, application(kConnectionKey))
- .WillByDefault(Return(mock_app));
-
- ON_CALL(*mock_app, app_id()).WillByDefault(Return(kConnectionKey));
-
- MockHMICapabilities hmi_capabilities;
- ON_CALL(app_mngr_, hmi_capabilities())
- .WillByDefault(ReturnRef(hmi_capabilities));
- ON_CALL(hmi_capabilities, is_ui_cooperating()).WillByDefault(Return(true));
-
- MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
- (*msg)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
- (*msg)[am::strings::msg_params][am::strings::info] = "info1";
-
- Event event(hmi_apis::FunctionID::UI_ScrollableMessage);
- event.set_smart_object(*msg);
-
- MessageSharedPtr ui_command_result;
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
- .WillOnce(DoAll(SaveArg<0>(&ui_command_result), Return(true)));
-
- command->on_event(event);
-
- EXPECT_EQ((*ui_command_result)[am::strings::msg_params][am::strings::success]
- .asBool(),
- true);
- EXPECT_EQ(
- (*ui_command_result)[am::strings::msg_params][am::strings::result_code]
- .asInt(),
- static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE));
- if ((*ui_command_result)[am::strings::msg_params].keyExists(
- am::strings::info)) {
- EXPECT_FALSE(
- (*ui_command_result)[am::strings::msg_params][am::strings::info]
- .asString()
- .empty());
- }
-}
-
-TEST_F(ScrollableMessageRequestTest, Init_CorrectTimeout_SUCCESS) {
- (*msg_)[msg_params][timeout] = kTimeOut;
- (*msg_)[msg_params][interaction_mode] =
- mobile_apis::InteractionMode::MANUAL_ONLY;
- EXPECT_EQ(kDefaultTimeout_, command_->default_timeout());
- command_->Init();
- EXPECT_EQ(kTimeOut, command_->default_timeout());
-}
-
-TEST_F(ScrollableMessageRequestTest, Init_CorrectTimeout_UNSUCCESS) {
- (*msg_)[msg_params][interaction_mode] =
- mobile_apis::InteractionMode::MANUAL_ONLY;
- EXPECT_EQ(kDefaultTimeout_, command_->default_timeout());
- command_->Init();
- EXPECT_EQ(kTimeOut, command_->default_timeout());
-}
-
-TEST_F(ScrollableMessageRequestTest, Run_ApplicationIsNotRegistered_UNSUCCESS) {
- EXPECT_CALL(app_mngr_, application(_))
- .WillOnce(Return(ApplicationSharedPtr()));
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(
- MobileResultCodeIs(mobile_result::APPLICATION_NOT_REGISTERED), _));
- command_->Run();
-}
-
-TEST_F(ScrollableMessageRequestTest,
- Run_SoftButtonProcessingResultWrogParameters_UNSUCCESS) {
- EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(mock_app_));
- const mobile_apis::Result::eType processing_result =
- mobile_apis::Result::ABORTED;
- smart_objects::SmartObject& msg_params = (*msg_)[am::strings::msg_params];
- EXPECT_CALL(
- mock_message_helper_,
- ProcessSoftButtons(
- msg_params, Eq(mock_app_), Ref(mock_policy_handler_), Ref(app_mngr_)))
- .WillOnce(Return(processing_result));
- MessageSharedPtr result_msg(CatchMobileCommandResult(CallRun(*command_)));
- EXPECT_EQ(processing_result,
- static_cast<mobile_apis::Result::eType>(
- (*result_msg)[am::strings::msg_params][result_code].asInt()));
-}
-
-TEST_F(ScrollableMessageRequestTest, Run_SoftButtonProcessingResult_SUCCESS) {
- ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app_));
- smart_objects::SmartObject& msg_params = (*msg_)[am::strings::msg_params];
- (*msg_)[am::strings::params][am::strings::function_id] = kFunctionID;
- (*msg_)[am::strings::msg_params][am::strings::soft_buttons][0]
- [am::strings::soft_button_id] = 0;
- EXPECT_CALL(
- mock_message_helper_,
- ProcessSoftButtons(
- msg_params, Eq(mock_app_), Ref(mock_policy_handler_), Ref(app_mngr_)))
- .WillOnce(Return(mobile_apis::Result::SUCCESS));
- EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId));
- EXPECT_CALL(mock_message_helper_, SubscribeApplicationToSoftButton(_, _, _));
-
- MessageSharedPtr result_msg(CatchHMICommandResult(CallRun(*command_)));
- EXPECT_EQ(hmi_apis::FunctionID::UI_ScrollableMessage,
- static_cast<hmi_apis::FunctionID::eType>(
- (*result_msg)[params][function_id].asInt()));
-}
-
-TEST_F(ScrollableMessageRequestTest, OnEvent_ReceivedUnknownEvent_UNSUCCESS) {
- EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0);
- Event event(hmi_apis::FunctionID::INVALID_ENUM);
- command_->on_event(event);
-}
-
-TEST_F(ScrollableMessageRequestTest,
- OnEvent_ReceivedUIOnResetTimeoutEvent_SUCCESS) {
- (*msg_)[params][connection_key] = kConnectionKey;
- (*msg_)[params][correlation_id] = kCorrelationId;
- EXPECT_CALL(
- app_mngr_,
- updateRequestTimeout(kConnectionKey, kCorrelationId, kDefaultTimeout_));
- Event event(hmi_apis::FunctionID::UI_OnResetTimeout);
- event.set_smart_object(*msg_);
- command_->on_event(event);
-}
-
-TEST_F(ScrollableMessageRequestTest,
- DISABLED_OnEvent_ReceivedUIScrollableMessage_SUCCESS) {
- (*msg_)[params][hmi_response::code] = hmi_apis::Common_Result::SUCCESS;
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS), _));
- Event event(hmi_apis::FunctionID::UI_ScrollableMessage);
- event.set_smart_object(*msg_);
- command_->on_event(event);
-}
-
-TEST_F(ScrollableMessageRequestTest,
- DISABLED_OnEvent_UnsupportedRCAndUICoop_SUCCESS) {
- (*msg_)[params][hmi_response::code] =
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(
- MobileResultCodeIs(mobile_apis::Result::UNSUPPORTED_RESOURCE), _));
- Event event(hmi_apis::FunctionID::UI_ScrollableMessage);
- event.set_smart_object(*msg_);
- command_->on_event(event);
-}
-
-} // namespace scrollable_message_request
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace tests
diff --git a/src/components/application_manager/test/commands/mobile/send_haptic_data_test.cc b/src/components/application_manager/test/commands/mobile/send_haptic_data_test.cc
deleted file mode 100644
index 2a3b5d922a..0000000000
--- a/src/components/application_manager/test/commands/mobile/send_haptic_data_test.cc
+++ /dev/null
@@ -1,163 +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 name of the Xevo Inc. 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 "commands/command_request_test.h"
-
-#include "mobile/send_haptic_data_request.h"
-#include "mobile/send_haptic_data_response.h"
-
-#include "interfaces/MOBILE_API.h"
-#include "application_manager/application.h"
-#include "application_manager/mock_application.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace send_haptic_data {
-
-using ::testing::_;
-using ::testing::Return;
-
-namespace am = ::application_manager;
-
-using am::commands::SendHapticDataRequest;
-using am::commands::SendHapticDataResponse;
-using am::commands::MessageSharedPtr;
-
-typedef SharedPtr<SendHapticDataRequest> SendHapticDataRequestPtr;
-typedef SharedPtr<SendHapticDataResponse> SendHapticDataResponsePtr;
-
-namespace {
-const uint32_t kConnectionKey = 1u;
-}
-
-class SendHapticDataRequestTest
- : public CommandRequestTest<CommandsTestMocks::kIsNice> {
- public:
- SendHapticDataRequestTest()
- : msg_(CreateMessage(::smart_objects::SmartType_Map))
- , mock_app_(CreateMockApp()) {}
-
- void SetUp() OVERRIDE {
- (*msg_)[am::strings::params][am::strings::connection_key] = kConnectionKey;
- ON_CALL(app_mngr_, application(kConnectionKey))
- .WillByDefault(Return(mock_app_));
- }
-
- MessageSharedPtr msg_;
- MockAppPtr mock_app_;
-};
-
-class SendHapticDataResponseTest
- : public CommandsTest<CommandsTestMocks::kIsNice> {
- public:
- SendHapticDataResponseTest() : message_(CreateMessage()) {}
-
- void SetUp() OVERRIDE {
- command_sptr_ = CreateCommand<SendHapticDataResponse>(message_);
- }
-
- MessageSharedPtr message_;
- SharedPtr<SendHapticDataResponse> command_sptr_;
-};
-
-TEST_F(SendHapticDataRequestTest, Run_SUCCESS) {
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
-
- EXPECT_CALL(*mock_app_, is_navi()).WillOnce(Return(true));
-
- EXPECT_CALL(app_mngr_,
- ManageHMICommand(
- HMIResultCodeIs(hmi_apis::FunctionID::UI_SendHapticData)))
- .WillOnce(Return(true));
-
- SendHapticDataRequestPtr command(CreateCommand<SendHapticDataRequest>(msg_));
-
- command->Init();
- command->Run();
-}
-
-TEST_F(SendHapticDataRequestTest, Run_DISALLOWED) {
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
-
- EXPECT_CALL(*mock_app_, is_navi()).WillOnce(Return(false));
-
- EXPECT_CALL(*mock_app_, mobile_projection_enabled()).WillOnce(Return(false));
-
- EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).WillOnce(Return(true));
-
- SendHapticDataRequestPtr command(CreateCommand<SendHapticDataRequest>(msg_));
-
- command->Init();
- command->Run();
-}
-
-TEST_F(SendHapticDataRequestTest, OnEvent_SUCCESS) {
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS),
- am::commands::Command::ORIGIN_SDL));
-
- (*msg_)[am::strings::msg_params] = 0;
- (*msg_)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::eType::SUCCESS;
- Event event(hmi_apis::FunctionID::UI_SendHapticData);
- event.set_smart_object(*msg_);
- SendHapticDataRequestPtr command(CreateCommand<SendHapticDataRequest>(msg_));
-
- command->Init();
- command->on_event(event);
-}
-
-TEST_F(SendHapticDataResponseTest, Run_Success) {
- ::smart_objects::SmartObject& message_ref = *message_;
- message_ref[am::strings::msg_params][am::strings::result_code] =
- mobile_apis::Result::SUCCESS;
-
- EXPECT_CALL(
- app_mngr_,
- SendMessageToMobile(MobileResultCodeIs(mobile_apis::Result::SUCCESS), _));
- command_sptr_->Init();
- command_sptr_->Run();
-}
-
-} // namespace send_haptic_data
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/send_location_request_test.cc b/src/components/application_manager/test/commands/mobile/send_location_request_test.cc
deleted file mode 100644
index c5786675d6..0000000000
--- a/src/components/application_manager/test/commands/mobile/send_location_request_test.cc
+++ /dev/null
@@ -1,396 +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/mobile/send_location_request.h"
-#include "application_manager/mock_hmi_capabilities.h"
-#include "application_manager/mock_message_helper.h"
-#include "utils/shared_ptr.h"
-#include "commands/command_request_test.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace send_location_request {
-
-using application_manager::commands::MessageSharedPtr;
-using application_manager::commands::SendLocationRequest;
-using application_manager::MockMessageHelper;
-using test::components::application_manager_test::MockHMICapabilities;
-using smart_objects::SmartObject;
-using utils::SharedPtr;
-using testing::_;
-using testing::Return;
-using testing::ReturnRef;
-
-namespace strings = application_manager::strings;
-namespace hmi_response = application_manager::hmi_response;
-namespace Common_TextFieldName = hmi_apis::Common_TextFieldName;
-
-namespace {
-const uint32_t kConnectionKey = 1u;
-const uint32_t kFunctionID = 2u;
-const uint32_t kAppID = 3u;
-const double kLongitudeDegrees = 13.4;
-const std::string kLocationDescription = "Location_Description";
-const std::string kNewLine = "\\n";
-const std::string kAddressLine = "Address_Line";
-const std::string kPhoneNumber = "Phone_number";
-const std::string kCorrectAddress = "Correct address";
-const std::string kEmptyAddress = "";
-const std::string kAddressWithWrongSyntax = "Wrong Syntax\\n";
-} // namespace
-
-class SendLocationRequestTest
- : public CommandRequestTest<CommandsTestMocks::kIsNice> {
- public:
- class UnwrappedSendLocationRequest : public SendLocationRequest {
- public:
- UnwrappedSendLocationRequest(
- const MessageSharedPtr& message,
- application_manager::ApplicationManager& application_manager)
- : SendLocationRequest(message, application_manager) {}
-
- ::application_manager::CommandParametersPermissions&
- get_parameters_permissions() {
- return parameters_permissions_;
- }
- };
-
- typedef SharedPtr<UnwrappedSendLocationRequest> CommandSPrt;
-
- SendLocationRequestTest() {
- mock_app_ = CreateMockApp();
- disp_cap_ = utils::MakeShared<SmartObject>(smart_objects::SmartType_Map);
- message_ = CreateMessage();
- command_ = CreateCommand<UnwrappedSendLocationRequest>(message_);
- }
-
- void InitialSetup(MessageSharedPtr message_) {
- (*message_)[strings::params][strings::connection_key] = kConnectionKey;
- (*message_)[strings::params][strings::function_id] = kFunctionID;
- (*message_)[strings::msg_params] =
- SmartObject(smart_objects::SmartType_Map);
- (*message_)[strings::msg_params][strings::address] = kCorrectAddress;
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
-
- AllowMandatoryFields();
- }
-
- void HMICapabilitiesSetupHelper() {
- EXPECT_CALL(app_mngr_, hmi_capabilities())
- .WillOnce(ReturnRef(mock_hmi_capabilities_));
- EXPECT_CALL(mock_hmi_capabilities_, is_ui_cooperating())
- .WillOnce(Return(true));
- }
-
- void HMICapabilitiesSetupWithArguments(
- Common_TextFieldName::eType field_name) {
- HMICapabilitiesSetupHelper();
- (*disp_cap_)[hmi_response::text_fields] =
- SmartObject(smart_objects::SmartType_Array);
- (*disp_cap_)[hmi_response::text_fields][0] =
- SmartObject(smart_objects::SmartType_Map);
- (*disp_cap_)[hmi_response::text_fields][0][strings::name] = field_name;
- EXPECT_CALL(mock_hmi_capabilities_, display_capabilities())
- .Times(2)
- .WillRepeatedly(Return(disp_cap_.get()));
- }
-
- void FinishSetup() {
- EXPECT_CALL(*mock_app_, hmi_app_id()).WillOnce(Return(kAppID));
- EXPECT_CALL(app_mngr_,
- ManageHMICommand(HMIResultCodeIs(
- hmi_apis::FunctionID::Navigation_SendLocation)));
- }
-
- void FinishSetupCancelled(mobile_apis::Result::eType result) {
- EXPECT_CALL(*mock_app_, hmi_app_id()).Times(0);
- EXPECT_CALL(app_mngr_, ManageHMICommand(_)).Times(0);
- EXPECT_CALL(app_mngr_, ManageMobileCommand(MobileResultCodeIs(result), _));
- }
-
- void AllowMandatoryFields() {
- application_manager::CommandParametersPermissions& permissions =
- command_->get_parameters_permissions();
- permissions.allowed_params.insert(strings::longitude_degrees);
- permissions.allowed_params.insert(strings::latitude_degrees);
- }
-
- MockAppPtr mock_app_;
- MockHMICapabilities mock_hmi_capabilities_;
- SharedPtr<SmartObject> disp_cap_;
- MessageSharedPtr message_;
- CommandSPrt command_;
-};
-
-TEST_F(SendLocationRequestTest, Run_InvalidApp_Success) {
- (*message_)[strings::params][strings::connection_key] = kConnectionKey;
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(MockAppPtr()));
- FinishSetupCancelled(mobile_apis::Result::APPLICATION_NOT_REGISTERED);
- command_->Run();
-}
-
-TEST_F(SendLocationRequestTest, Run_DeliveryMode_Success) {
- InitialSetup(message_);
- SmartObject msg_params = (*message_)[strings::msg_params];
- msg_params[strings::delivery_mode] = SmartObject();
- (*message_)[strings::msg_params] = msg_params;
- msg_params.erase(strings::delivery_mode);
- FinishSetup();
- command_->Run();
-}
-
-TEST_F(SendLocationRequestTest, Run_LocationNameIsAllowed_Success) {
- InitialSetup(message_);
- (*message_)[strings::msg_params][strings::location_name] = "Location_Name";
- HMICapabilitiesSetupWithArguments(Common_TextFieldName::locationName);
- FinishSetup();
- command_->Run();
-}
-
-TEST_F(SendLocationRequestTest, Run_LocationNameIsNotAllowed_Cancelled) {
- InitialSetup(message_);
- (*message_)[strings::msg_params][strings::location_name] = "Location_Name";
- HMICapabilitiesSetupWithArguments(Common_TextFieldName::INVALID_ENUM);
- FinishSetupCancelled(mobile_apis::Result::UNSUPPORTED_RESOURCE);
- command_->Run();
-}
-
-TEST_F(SendLocationRequestTest, Run_LocationNameWrongSyntax_Cancelled) {
- InitialSetup(message_);
- (*message_)[strings::msg_params][strings::location_name] = "Location_Name\\n";
- HMICapabilitiesSetupWithArguments(Common_TextFieldName::locationName);
- FinishSetupCancelled(mobile_apis::Result::INVALID_DATA);
- command_->Run();
-}
-
-TEST_F(SendLocationRequestTest, Run_LocationDescriptionIsAllowed_Success) {
- InitialSetup(message_);
- (*message_)[strings::msg_params][strings::location_description] =
- kLocationDescription;
- HMICapabilitiesSetupWithArguments(Common_TextFieldName::locationDescription);
- FinishSetup();
- command_->Run();
-}
-
-TEST_F(SendLocationRequestTest, Run_LocationDescriptionIsNotAllowed_Cancelled) {
- InitialSetup(message_);
- (*message_)[strings::msg_params][strings::location_description] =
- kLocationDescription;
- HMICapabilitiesSetupWithArguments(Common_TextFieldName::INVALID_ENUM);
- FinishSetupCancelled(mobile_apis::Result::UNSUPPORTED_RESOURCE);
- command_->Run();
-}
-
-TEST_F(SendLocationRequestTest, Run_LocationDescriptionWrongSyntax_Cancelled) {
- InitialSetup(message_);
- (*message_)[strings::msg_params][strings::location_description] =
- kLocationDescription + kNewLine;
- HMICapabilitiesSetupWithArguments(Common_TextFieldName::locationDescription);
- FinishSetupCancelled(mobile_apis::Result::INVALID_DATA);
- command_->Run();
-}
-
-TEST_F(SendLocationRequestTest, Run_AddressLinesAreAllowed_Success) {
- InitialSetup(message_);
- (*message_)[strings::msg_params][strings::address_lines] =
- SmartObject(smart_objects::SmartType_Array);
- (*message_)[strings::msg_params][strings::address_lines][0] = kAddressLine;
- HMICapabilitiesSetupWithArguments(Common_TextFieldName::addressLines);
- FinishSetup();
- command_->Run();
-}
-
-TEST_F(SendLocationRequestTest, Run_AddressLinesAreNotAllowed_Cancelled) {
- InitialSetup(message_);
- (*message_)[strings::msg_params][strings::address_lines] =
- SmartObject(smart_objects::SmartType_Array);
- (*message_)[strings::msg_params][strings::address_lines][0] = kAddressLine;
- HMICapabilitiesSetupWithArguments(Common_TextFieldName::INVALID_ENUM);
- FinishSetupCancelled(mobile_apis::Result::UNSUPPORTED_RESOURCE);
- command_->Run();
-}
-
-TEST_F(SendLocationRequestTest, Run_AddressLinesWrongSyntax_Cancelled) {
- InitialSetup(message_);
- (*message_)[strings::msg_params][strings::address_lines] =
- SmartObject(smart_objects::SmartType_Array);
- (*message_)[strings::msg_params][strings::address_lines][0] =
- kAddressLine + kNewLine;
- HMICapabilitiesSetupWithArguments(Common_TextFieldName::addressLines);
- FinishSetupCancelled(mobile_apis::Result::INVALID_DATA);
- command_->Run();
-}
-
-TEST_F(SendLocationRequestTest, Run_PhoneNumberIsAllowed_Success) {
- InitialSetup(message_);
- (*message_)[strings::msg_params][strings::phone_number] = kPhoneNumber;
- HMICapabilitiesSetupWithArguments(Common_TextFieldName::phoneNumber);
- FinishSetup();
- command_->Run();
-}
-
-TEST_F(SendLocationRequestTest, Run_PhoneNumberIsNotAllowed_Cancelled) {
- InitialSetup(message_);
- (*message_)[strings::msg_params][strings::phone_number] = kPhoneNumber;
- HMICapabilitiesSetupWithArguments(Common_TextFieldName::INVALID_ENUM);
- FinishSetupCancelled(mobile_apis::Result::UNSUPPORTED_RESOURCE);
- command_->Run();
-}
-
-TEST_F(SendLocationRequestTest, Run_PhoneNumberWrongSyntax_Cancelled) {
- InitialSetup(message_);
- (*message_)[strings::msg_params][strings::phone_number] =
- kPhoneNumber + kNewLine;
- HMICapabilitiesSetupWithArguments(Common_TextFieldName::phoneNumber);
- FinishSetupCancelled(mobile_apis::Result::INVALID_DATA);
- command_->Run();
-}
-
-TEST_F(SendLocationRequestTest, Run_AddressesContainWrongSyntax_Cancelled) {
- InitialSetup(message_);
- (*message_)[strings::msg_params][strings::address] =
- SmartObject(smart_objects::SmartType_Array);
- (*message_)[strings::msg_params][strings::address]["Address 1"] =
- kCorrectAddress;
- (*message_)[strings::msg_params][strings::address]["Address 2"] =
- kAddressWithWrongSyntax;
- FinishSetupCancelled(mobile_apis::Result::INVALID_DATA);
- command_->Run();
-}
-
-TEST_F(SendLocationRequestTest, Run_LocationImageValid_Success) {
- InitialSetup(message_);
- (*message_)[strings::msg_params][strings::location_image] =
- SmartObject(smart_objects::SmartType_Map);
- (*message_)[strings::msg_params][strings::location_image][strings::value] =
- "1";
- EXPECT_CALL(
- mock_message_helper_,
- VerifyImage(
- (*message_)[strings::msg_params][strings::location_image], _, _))
- .WillOnce(Return(mobile_apis::Result::SUCCESS));
- FinishSetup();
- command_->Run();
-}
-
-TEST_F(SendLocationRequestTest, Run_LocationImageInvalid_Cancelled) {
- InitialSetup(message_);
- (*message_)[strings::msg_params][strings::location_image] =
- SmartObject(smart_objects::SmartType_Map);
- (*message_)[strings::msg_params][strings::location_image][strings::value] =
- "1";
- EXPECT_CALL(
- mock_message_helper_,
- VerifyImage(
- (*message_)[strings::msg_params][strings::location_image], _, _))
- .WillOnce(Return(mobile_apis::Result::ABORTED));
- FinishSetupCancelled(mobile_apis::Result::ABORTED);
- command_->Run();
-}
-
-TEST_F(SendLocationRequestTest, Run_HMIUINotCoop_Cancelled) {
- InitialSetup(message_);
- (*message_)[strings::msg_params][strings::phone_number] = kPhoneNumber;
- (*disp_cap_)[hmi_response::text_fields] =
- SmartObject(smart_objects::SmartType_Array);
- (*disp_cap_)[hmi_response::text_fields][0] =
- SmartObject(smart_objects::SmartType_Map);
- (*disp_cap_)[hmi_response::text_fields][0][strings::name] =
- Common_TextFieldName::phoneNumber;
- EXPECT_CALL(app_mngr_, hmi_capabilities())
- .WillOnce(ReturnRef(mock_hmi_capabilities_));
- EXPECT_CALL(mock_hmi_capabilities_, is_ui_cooperating())
- .WillOnce(Return(false));
- FinishSetupCancelled(mobile_apis::Result::UNSUPPORTED_RESOURCE);
- command_->Run();
-}
-
-TEST_F(SendLocationRequestTest, OnEvent_Success) {
- mobile_apis::Result::eType response_code = mobile_apis::Result::SUCCESS;
- (*message_)[strings::params][hmi_response::code] = response_code;
- (*message_)[strings::params][strings::connection_key] = kConnectionKey;
-
- Event event(hmi_apis::FunctionID::Navigation_SendLocation);
- event.set_smart_object(*message_);
-
- MockAppPtr app(CreateMockApp());
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillRepeatedly(Return(app));
-
- command_->on_event(event);
-}
-
-TEST_F(SendLocationRequestTest, OnEvent_Cancelled) {
- (*message_)[strings::params][hmi_response::code] =
- mobile_apis::Result::SUCCESS;
- Event event(hmi_apis::FunctionID::Navigation_OnWayPointChange);
- event.set_smart_object(*message_);
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS), _))
- .Times(0);
- command_->on_event(event);
-}
-
-TEST_F(SendLocationRequestTest, Run_MandatoryParamsDisallowed_InvalidData) {
- (*message_)[strings::params][strings::connection_key] = kConnectionKey;
- (*message_)[strings::params][strings::function_id] = kFunctionID;
- (*message_)[strings::msg_params] = SmartObject(smart_objects::SmartType_Map);
- (*message_)[strings::msg_params][strings::address] = kCorrectAddress;
- (*message_)[strings::msg_params][strings::longitude_degrees] =
- kLongitudeDegrees;
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
- application_manager::CommandParametersPermissions& permissions =
- command_->get_parameters_permissions();
- // 1st one allowed
- permissions.allowed_params.insert(strings::longitude_degrees);
- // 2nd one disallowed
- permissions.disallowed_params.insert(strings::latitude_degrees);
- EXPECT_CALL(app_mngr_,
- ManageMobileCommand(
- MobileResultCodeIs(mobile_apis::Result::INVALID_DATA), _));
- command_->Run();
-}
-
-} // namespace send_location_request
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/set_app_icon_test.cc b/src/components/application_manager/test/commands/mobile/set_app_icon_test.cc
deleted file mode 100644
index b278479df8..0000000000
--- a/src/components/application_manager/test/commands/mobile/set_app_icon_test.cc
+++ /dev/null
@@ -1,151 +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 <set>
-
-#include "application_manager/commands/mobile/set_app_icon_request.h"
-
-#include "gtest/gtest.h"
-#include "application_manager/commands/command_request_test.h"
-#include "application_manager/mock_application.h"
-#include "application_manager/mock_application_manager.h"
-#include "application_manager/mock_message_helper.h"
-#include "application_manager/event_engine/event.h"
-#include "application_manager/mock_hmi_interface.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace set_app_icon_request {
-
-namespace am = application_manager;
-using am::commands::SetAppIconRequest;
-using am::commands::CommandImpl;
-using am::commands::MessageSharedPtr;
-using am::MockMessageHelper;
-using ::utils::SharedPtr;
-using ::testing::_;
-using ::testing::Return;
-using ::testing::ReturnRef;
-
-namespace {
-const uint32_t kAppId = 1u;
-const uint32_t kCmdId = 1u;
-const uint32_t kConnectionKey = 2u;
-} // namespace
-
-class SetAppIconRequestTest
- : public CommandRequestTest<CommandsTestMocks::kIsNice> {
- public:
- MessageSharedPtr CreateFullParamsUISO() {
- MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
- (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey;
- smart_objects::SmartObject menu_params =
- smart_objects::SmartObject(smart_objects::SmartType_Map);
- menu_params[am::strings::position] = 10;
- menu_params[am::strings::menu_name] = "LG";
-
- smart_objects::SmartObject msg_params =
- smart_objects::SmartObject(smart_objects::SmartType_Map);
- msg_params[am::strings::cmd_id] = kCmdId;
- msg_params[am::strings::menu_params] = menu_params;
- msg_params[am::strings::app_id] = kAppId;
- msg_params[am::strings::cmd_icon] = 1;
- msg_params[am::strings::cmd_icon][am::strings::value] = "10";
- (*msg)[am::strings::msg_params] = msg_params;
-
- return msg;
- }
-};
-
-TEST_F(SetAppIconRequestTest, OnEvent_UI_UNSUPPORTED_RESOURCE) {
- const std::string file_path = "file_path";
- MessageSharedPtr msg_vr = CreateFullParamsUISO();
- (*msg_vr)[am::strings::params][am::strings::connection_key] = kConnectionKey;
- (*msg_vr)[am::strings::msg_params][am::strings::sync_file_name]
- [am::strings::value] = file_path;
-
- const std::string dir_path = "./";
- ON_CALL(app_mngr_settings_, app_icons_folder())
- .WillByDefault(ReturnRef(dir_path));
-
- utils::SharedPtr<SetAppIconRequest> req_vr =
- CreateCommand<SetAppIconRequest>(msg_vr);
-
- MockAppPtr mock_app = CreateMockApp();
- ON_CALL(app_mngr_, application(kConnectionKey))
- .WillByDefault(Return(mock_app));
-
- ON_CALL(*mock_app, app_id()).WillByDefault(Return(kConnectionKey));
- ON_CALL(*mock_app, set_app_icon_path(_)).WillByDefault(Return(true));
- ON_CALL(*mock_app, app_icon_path()).WillByDefault(ReturnRef(file_path));
-
- MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
- (*msg)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
- (*msg)[am::strings::msg_params][am::strings::info] = "info1";
-
- Event event(hmi_apis::FunctionID::UI_SetAppIcon);
- event.set_smart_object(*msg);
-
- MessageSharedPtr ui_command_result;
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
- .WillOnce(DoAll(SaveArg<0>(&ui_command_result), Return(true)));
-
- req_vr->on_event(event);
-
- EXPECT_EQ((*ui_command_result)[am::strings::msg_params][am::strings::success]
- .asBool(),
- true);
- EXPECT_EQ(
- (*ui_command_result)[am::strings::msg_params][am::strings::result_code]
- .asInt(),
- static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE));
- if ((*ui_command_result)[am::strings::msg_params].keyExists(
- am::strings::info)) {
- EXPECT_FALSE(
- (*ui_command_result)[am::strings::msg_params][am::strings::info]
- .asString()
- .empty());
- }
-}
-
-} // namespace set_app_icon_request
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace tests
diff --git a/src/components/application_manager/test/commands/mobile/set_display_layout_test.cc b/src/components/application_manager/test/commands/mobile/set_display_layout_test.cc
deleted file mode 100644
index 8444b88d63..0000000000
--- a/src/components/application_manager/test/commands/mobile/set_display_layout_test.cc
+++ /dev/null
@@ -1,254 +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 <set>
-
-#include "application_manager/commands/mobile/set_display_layout_request.h"
-
-#include "gtest/gtest.h"
-#include "application_manager/commands/command_request_test.h"
-#include "application_manager/mock_application.h"
-#include "application_manager/mock_application_manager.h"
-#include "application_manager/mock_message_helper.h"
-#include "application_manager/event_engine/event.h"
-#include "application_manager/mock_hmi_interface.h"
-#include "application_manager/mock_hmi_capabilities.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace set_display_layout_request {
-
-namespace am = application_manager;
-namespace mobile_result = mobile_apis::Result;
-using am::commands::SetDisplayLayoutRequest;
-using am::commands::CommandImpl;
-using am::commands::MessageSharedPtr;
-using am::MockMessageHelper;
-using ::utils::SharedPtr;
-using ::testing::_;
-using ::testing::Return;
-using ::testing::ReturnRef;
-
-typedef ::utils::SharedPtr<SetDisplayLayoutRequest> CommandPtr;
-
-namespace {
-const uint32_t kAppId = 1u;
-const uint32_t kCmdId = 1u;
-const uint32_t kConnectionKey = 2u;
-const uint32_t kCorrelationKey = 2u;
-} // namespace
-
-MATCHER_P(CheckMshCorrId, corr_id, "") {
- return (*arg)[am::strings::params][am::strings::correlation_id].asUInt() ==
- corr_id;
-}
-
-class SetDisplayLayoutRequestTest
- : public CommandRequestTest<CommandsTestMocks::kIsNice> {
- public:
- SetDisplayLayoutRequestTest() : mock_app_(CreateMockApp()) {
- ON_CALL(app_mngr_, application(kConnectionKey))
- .WillByDefault(Return(mock_app_));
- ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey));
- }
-
- MessageSharedPtr CreateFullParamsUISO() {
- MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
- (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey;
- smart_objects::SmartObject menu_params =
- smart_objects::SmartObject(smart_objects::SmartType_Map);
- menu_params[am::strings::position] = 10;
- menu_params[am::strings::menu_name] = "LG";
-
- smart_objects::SmartObject msg_params =
- smart_objects::SmartObject(smart_objects::SmartType_Map);
- msg_params[am::strings::cmd_id] = kCmdId;
- msg_params[am::strings::menu_params] = menu_params;
- msg_params[am::strings::app_id] = kAppId;
- msg_params[am::strings::cmd_icon] = 1;
- msg_params[am::strings::cmd_icon][am::strings::value] = "10";
- (*msg)[am::strings::msg_params] = msg_params;
-
- return msg;
- }
- typedef TypeIf<kMocksAreNice,
- NiceMock<application_manager_test::MockHMICapabilities>,
- application_manager_test::MockHMICapabilities>::Result
- MockHMICapabilities;
-
- void ResultCommandExpectations(MessageSharedPtr msg,
- const std::string& info) {
- EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::success].asBool(),
- false);
- EXPECT_EQ(
- (*msg)[am::strings::msg_params][am::strings::result_code].asInt(),
- static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE));
- EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::info].asString(),
- info);
- }
-
- sync_primitives::Lock lock_;
- MockAppPtr mock_app_;
-};
-
-typedef SetDisplayLayoutRequestTest::MockHMICapabilities MockHMICapabilities;
-
-TEST_F(SetDisplayLayoutRequestTest,
- OnEvent_UIHmiUnsupportedResource_UNSUPPORTED_RESOURCE) {
- MessageSharedPtr msg_ui = CreateFullParamsUISO();
- (*msg_ui)[am::strings::params][am::strings::connection_key] = kConnectionKey;
-
- utils::SharedPtr<SetDisplayLayoutRequest> command =
- CreateCommand<SetDisplayLayoutRequest>(msg_ui);
-
- MockAppPtr mock_app = CreateMockApp();
- ON_CALL(app_mngr_, application(kConnectionKey))
- .WillByDefault(Return(mock_app));
-
- ON_CALL(*mock_app, app_id()).WillByDefault(Return(kConnectionKey));
-
- MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
- (*msg)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
- (*msg)[am::strings::msg_params][am::strings::app_id] = kConnectionKey;
- (*msg)[am::strings::msg_params][am::strings::info] =
- "UI is not supported by system";
-
- Event event(hmi_apis::FunctionID::UI_SetDisplayLayout);
- event.set_smart_object(*msg);
-
- ON_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
- .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
-
- MessageSharedPtr ui_command_result;
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
- .WillOnce(DoAll(SaveArg<0>(&ui_command_result), Return(true)));
-
- command->on_event(event);
-
- ResultCommandExpectations(ui_command_result, "UI is not supported by system");
-}
-
-TEST_F(SetDisplayLayoutRequestTest, Run_InvalidApp_UNSUCCESS) {
- MessageSharedPtr msg(CreateMessage(smart_objects::SmartType_Map));
- (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey;
- CommandPtr command(CreateCommand<SetDisplayLayoutRequest>(msg));
-
- MockAppPtr invalid_mock_app;
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(invalid_mock_app));
-
- EXPECT_CALL(app_mngr_,
- ManageMobileCommand(
- MobileResultCodeIs(mobile_result::APPLICATION_NOT_REGISTERED),
- am::commands::Command::CommandOrigin::ORIGIN_SDL));
-
- command->Run();
-}
-
-TEST_F(SetDisplayLayoutRequestTest, Run_SUCCESS) {
- MessageSharedPtr msg(CreateMessage(smart_objects::SmartType_Map));
- (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey;
- CommandPtr command(CreateCommand<SetDisplayLayoutRequest>(msg));
- MockAppPtr mock_app(CreateMockApp());
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app));
- EXPECT_CALL(*mock_app, app_id()).WillOnce(Return(kAppId));
-
- EXPECT_CALL(app_mngr_, GetNextHMICorrelationID())
- .WillOnce(Return(kCorrelationKey));
- EXPECT_CALL(
- mock_hmi_interfaces_,
- GetInterfaceFromFunction(hmi_apis::FunctionID::UI_SetDisplayLayout))
- .WillRepeatedly(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
- EXPECT_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
- .WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE));
- EXPECT_CALL(app_mngr_, ManageHMICommand(CheckMshCorrId(kCorrelationKey)))
- .WillOnce(Return(true));
-
- command->Run();
-}
-
-TEST_F(SetDisplayLayoutRequestTest, OnEvent_InvalidEventId_UNSUCCESS) {
- CommandPtr command(CreateCommand<SetDisplayLayoutRequest>());
- am::event_engine::Event event(hmi_apis::FunctionID::INVALID_ENUM);
- SmartObject msg(smart_objects::SmartType_Map);
-
- event.set_smart_object(msg);
-
- EXPECT_CALL(app_mngr_, hmi_capabilities()).Times(0);
- command->on_event(event);
-}
-
-TEST_F(SetDisplayLayoutRequestTest, OnEvent_SUCCESS) {
- am::event_engine::Event event(hmi_apis::FunctionID::UI_SetDisplayLayout);
- MessageSharedPtr msg = CreateMessage();
-
- (*msg)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::SUCCESS;
- (*msg)[am::strings::msg_params][am::hmi_response::display_capabilities] = 0;
- (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey;
- event.set_smart_object(*msg);
-
- MockHMICapabilities hmi_capabilities;
- MessageSharedPtr dispaly_capabilities_msg = CreateMessage();
- (*dispaly_capabilities_msg)[am::hmi_response::templates_available] =
- "templates_available";
-
- EXPECT_CALL(app_mngr_, hmi_capabilities())
- .WillOnce(ReturnRef(hmi_capabilities));
-
- EXPECT_CALL(hmi_capabilities, display_capabilities())
- .WillOnce(Return(dispaly_capabilities_msg.get()));
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(MobileResultCodeIs(mobile_result::SUCCESS),
- am::commands::Command::CommandOrigin::ORIGIN_SDL));
-
- CommandPtr command(CreateCommand<SetDisplayLayoutRequest>(msg));
- command->on_event(event);
-}
-
-} // namespace set_display_layout_request
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace tests
diff --git a/src/components/application_manager/test/commands/mobile/set_global_properties_test.cc b/src/components/application_manager/test/commands/mobile/set_global_properties_test.cc
deleted file mode 100644
index 641e5636a9..0000000000
--- a/src/components/application_manager/test/commands/mobile/set_global_properties_test.cc
+++ /dev/null
@@ -1,1229 +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 <set>
-
-#include "application_manager/commands/mobile/set_global_properties_request.h"
-
-#include "gtest/gtest.h"
-#include "application_manager/commands/command_request_test.h"
-#include "application_manager/mock_application.h"
-#include "application_manager/mock_application_manager.h"
-#include "application_manager/mock_message_helper.h"
-#include "application_manager/event_engine/event.h"
-#include "application_manager/mock_hmi_interface.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace set_global_properties_request {
-
-namespace am = application_manager;
-using am::commands::SetGlobalPropertiesRequest;
-using am::commands::CommandImpl;
-using am::commands::MessageSharedPtr;
-using am::MockMessageHelper;
-using am::CommandsMap;
-using utils::custom_string::CustomString;
-using ::utils::SharedPtr;
-using ::testing::_;
-using ::testing::Return;
-using ::testing::ReturnRef;
-
-namespace {
-const int32_t kCommandId = 1;
-const uint32_t kAppId = 1u;
-const uint32_t kCmdId = 1u;
-const uint32_t kConnectionKey = 1u;
-const std::string kText = "one";
-const uint32_t kPosition = 1u;
-} // namespace
-
-class SetGlobalPropertiesRequestTest
- : public CommandRequestTest<CommandsTestMocks::kIsNice> {
- public:
- SetGlobalPropertiesRequestTest() : mock_app_(CreateMockApp()) {}
-
- MessageSharedPtr CreateFullParamsUISO() {
- MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
- (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey;
- smart_objects::SmartObject menu_params =
- smart_objects::SmartObject(smart_objects::SmartType_Map);
- menu_params[am::strings::position] = 10;
- menu_params[am::strings::menu_name] = "LG";
-
- smart_objects::SmartObject msg_params =
- smart_objects::SmartObject(smart_objects::SmartType_Map);
- msg_params[am::strings::cmd_id] = kCmdId;
- msg_params[am::strings::menu_params] = menu_params;
- msg_params[am::strings::app_id] = kAppId;
- msg_params[am::strings::cmd_icon] = 1;
- msg_params[am::strings::cmd_icon][am::strings::value] = "10";
- msg_params[am::strings::vr_help_title] = "vr_help_title";
- msg_params[am::strings::vr_help][0][am::strings::text] = "vr_help";
- msg_params[am::strings::vr_help][0][am::strings::position] = 1u;
- msg_params[am::strings::help_prompt][0][am::strings::text] = "help_promt";
- (*msg)[am::strings::msg_params] = msg_params;
-
- return msg;
- }
-
- MessageSharedPtr CreateMsgParams() {
- MessageSharedPtr msg = CreateMessage();
- (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey;
- (*msg)[am::strings::msg_params][am::strings::app_id] = kAppId;
- return msg;
- }
-
- void VRArraySetupHelper(MessageSharedPtr msg,
- SmartObject& vr_help_title,
- SmartObject& vr_help_array) {
- (*msg)[am::strings::msg_params][am::strings::vr_help_title] = vr_help_title;
- vr_help_array[0] = SmartObject(smart_objects::SmartType_Map);
- vr_help_array[0][am::strings::text] = kText;
- vr_help_array[0][am::strings::position] = kPosition;
- (*msg)[am::strings::msg_params][am::strings::vr_help] = vr_help_array;
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
- }
-
- void OnEventUISetupHelper(MessageSharedPtr msg,
- SharedPtr<SetGlobalPropertiesRequest> command) {
- SmartObject vr_help_title("yes");
- SmartObject vr_help_array(smart_objects::SmartType_Array);
- VRArraySetupHelper(msg, vr_help_title, vr_help_array);
- EXPECT_CALL(mock_message_helper_,
- VerifyImageVrHelpItems(vr_help_array, _, _))
- .WillOnce((Return(mobile_apis::Result::SUCCESS)));
- EXPECT_CALL(app_mngr_,
- RemoveAppFromTTSGlobalPropertiesList(kConnectionKey));
- EXPECT_CALL(*mock_app_, set_vr_help_title(vr_help_title));
- EXPECT_CALL(*mock_app_, set_vr_help(vr_help_array));
- EXPECT_CALL(*mock_app_, vr_help_title()).WillOnce(Return(&vr_help_title));
- EXPECT_CALL(*mock_app_, vr_help()).WillOnce(Return(&vr_help_array));
- EXPECT_CALL(*mock_app_, set_menu_title(_)).Times(0);
- EXPECT_CALL(*mock_app_, set_menu_icon(_)).Times(0);
- EXPECT_CALL(*mock_app_, set_keyboard_props(_)).Times(0);
- EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId));
-
- command->Run();
- }
-
- void OnEventTTSSetupHelper(MessageSharedPtr msg,
- SharedPtr<SetGlobalPropertiesRequest> command) {
- SmartObject help_prompt(smart_objects::SmartType_Array);
- help_prompt[0][am::strings::text] = "Help_Prompt_One";
- (*msg)[am::strings::msg_params][am::strings::help_prompt] = help_prompt;
- SmartObject timeout_prompt(smart_objects::SmartType_Array);
- timeout_prompt[0][am::strings::text] = "Timeout_Prompt_One";
- (*msg)[am::strings::msg_params][am::strings::timeout_prompt] =
- timeout_prompt;
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
- EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(_, _, _)).Times(0);
- EXPECT_CALL(app_mngr_,
- RemoveAppFromTTSGlobalPropertiesList(kConnectionKey));
- SmartObject vr_help_title("title");
- EXPECT_CALL(*mock_app_, vr_help_title()).WillOnce(Return(&vr_help_title));
- EXPECT_CALL(*mock_app_, set_help_prompt(help_prompt));
- EXPECT_CALL(*mock_app_, help_prompt()).WillOnce(Return(&help_prompt));
- EXPECT_CALL(*mock_app_, set_timeout_prompt(timeout_prompt));
- EXPECT_CALL(*mock_app_, timeout_prompt()).WillOnce(Return(&timeout_prompt));
- EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId));
-
- command->Run();
- }
-
- void EmptyExpectationsSetupHelper() {
- EXPECT_CALL(*mock_app_, set_vr_help_title(_)).Times(0);
- EXPECT_CALL(*mock_app_, set_vr_help(_)).Times(0);
- EXPECT_CALL(*mock_app_, vr_help_title()).Times(0);
- EXPECT_CALL(*mock_app_, vr_help()).Times(0);
- EXPECT_CALL(*mock_app_, set_menu_title(_)).Times(0);
- EXPECT_CALL(*mock_app_, set_menu_icon(_)).Times(0);
- EXPECT_CALL(*mock_app_, set_keyboard_props(_)).Times(0);
- EXPECT_CALL(*mock_app_, app_id()).Times(0);
- }
-
- void ExpectInvalidData() {
- EXPECT_CALL(app_mngr_,
- ManageMobileCommand(
- MobileResultCodeIs(mobile_apis::Result::INVALID_DATA),
- am::commands::Command::ORIGIN_SDL));
- }
-
- void ExpectVerifyImageVrHelpSuccess(SmartObject& smart_obj) {
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
- EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(smart_obj, _, _))
- .WillOnce(Return(mobile_apis::Result::SUCCESS));
- EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(_)).Times(0);
- }
-
- void ExpectVerifyImageVrHelpUnsuccess() {
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
- EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(_, _, _)).Times(0);
- EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(_)).Times(0);
- }
-
- void ExpectVerifyImageSuccess(SmartObject& smart_obj) {
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
- EXPECT_CALL(mock_message_helper_, VerifyImage(smart_obj, _, _))
- .WillOnce(Return(mobile_apis::Result::SUCCESS));
- EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(_)).Times(0);
- }
-
- void SetUp() OVERRIDE {
- ON_CALL(app_mngr_, application(kConnectionKey))
- .WillByDefault(Return(mock_app_));
- ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey));
- ON_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
- .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
- }
-
- void ResultCommandExpectations(MessageSharedPtr msg,
- const std::string& info) {
- EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::success].asBool(),
- true);
- EXPECT_EQ(
- (*msg)[am::strings::msg_params][am::strings::result_code].asInt(),
- static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE));
- EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::info].asString(),
- info);
- }
-
- void ExpectationsHmiInterface_Run() {
- EXPECT_CALL(
- mock_hmi_interfaces_,
- GetInterfaceFromFunction(hmi_apis::FunctionID::UI_SetGlobalProperties))
- .WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
- EXPECT_CALL(
- mock_hmi_interfaces_,
- GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_SetGlobalProperties))
- .WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_TTS));
- ON_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
- .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
- ON_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS))
- .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
- }
- sync_primitives::Lock lock_;
- MockAppPtr mock_app_;
-};
-
-TEST_F(SetGlobalPropertiesRequestTest,
- OnEvent_UIHmiSendSuccess_UNSUPPORTED_RESOURCE) {
- MessageSharedPtr msg_vr = CreateFullParamsUISO();
- (*msg_vr)[am::strings::msg_params][am::strings::vr_commands][0] =
- "vr_command";
-
- utils::SharedPtr<SetGlobalPropertiesRequest> command =
- CreateCommand<SetGlobalPropertiesRequest>(msg_vr);
-
- EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey));
- const smart_objects::SmartObject* vr_help_title =
- &((*msg_vr)[am::strings::msg_params][am::strings::vr_help_title]);
- const smart_objects::SmartObject* vr_help =
- &((*msg_vr)[am::strings::msg_params][am::strings::vr_help]);
- const smart_objects::SmartObject* vr_help_prompt =
- &((*msg_vr)[am::strings::msg_params][am::strings::help_prompt]);
- ON_CALL(*mock_app_, vr_help_title()).WillByDefault(Return(vr_help_title));
- ON_CALL(*mock_app_, vr_help()).WillByDefault(Return(vr_help));
- ON_CALL(*mock_app_, help_prompt()).WillByDefault(Return(vr_help_prompt));
-
- ExpectationsHmiInterface_Run();
-
- MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
- (*msg)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
- (*msg)[am::strings::msg_params][am::strings::cmd_id] = kCommandId;
- (*msg)[am::strings::msg_params][am::strings::info] =
- "UI is not supported by system";
-
- Event event(hmi_apis::FunctionID::UI_SetGlobalProperties);
- event.set_smart_object(*msg);
-
- ON_CALL(mock_message_helper_,
- VerifyImageVrHelpItems(
- (*msg_vr)[am::strings::msg_params][am::strings::vr_help], _, _))
- .WillByDefault(Return(mobile_apis::Result::SUCCESS));
-
- ON_CALL(mock_message_helper_, VerifyImage(_, _, _))
- .WillByDefault(Return(mobile_apis::Result::SUCCESS));
-
- (*msg_vr)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::SUCCESS;
- Event event_vr(hmi_apis::FunctionID::TTS_SetGlobalProperties);
- event_vr.set_smart_object(*msg_vr);
-
- command->Run();
- command->on_event(event_vr);
-
- MessageSharedPtr ui_command_result;
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
- .WillOnce(DoAll(SaveArg<0>(&ui_command_result), Return(true)));
-
- command->on_event(event);
-
- ResultCommandExpectations(ui_command_result, "UI is not supported by system");
-}
-
-TEST_F(SetGlobalPropertiesRequestTest, OnEvent_SUCCESS_Expect_MessageNotSend) {
- MessageSharedPtr response = CreateMessage(smart_objects::SmartType_Map);
- (*response)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::SUCCESS;
- (*response)[am::strings::msg_params][am::strings::info] = "test";
-
- am::event_engine::Event event(hmi_apis::FunctionID::TTS_SetGlobalProperties);
- event.set_smart_object(*response);
-
- utils::SharedPtr<SetGlobalPropertiesRequest> command =
- CreateCommand<SetGlobalPropertiesRequest>(response);
-
- MockAppPtr mock_app(CreateMockApp());
- ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app));
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
- .Times(0);
- command->on_event(event);
-}
-
-TEST_F(SetGlobalPropertiesRequestTest,
- OnEvent_UNSUPPORTED_RESOURCE_Expect_false) {
- MessageSharedPtr response = CreateMessage(smart_objects::SmartType_Map);
- (*response)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::SUCCESS;
- (*response)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
- (*response)[am::strings::msg_params][am::strings::info] = "qwe";
-
- am::event_engine::Event event_tts(
- hmi_apis::FunctionID::TTS_SetGlobalProperties);
- event_tts.set_smart_object(*response);
- am::event_engine::Event event_ui(
- hmi_apis::FunctionID::UI_SetGlobalProperties);
- event_tts.set_smart_object(*response);
- utils::SharedPtr<SetGlobalPropertiesRequest> command =
- CreateCommand<SetGlobalPropertiesRequest>(response);
-
- EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
- .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
-
- MessageSharedPtr response_to_mobile;
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
- .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true)));
-
- command->Run();
- command->on_event(event_ui);
- command->on_event(event_tts);
-
- EXPECT_EQ((*response_to_mobile)[am::strings::msg_params][am::strings::success]
- .asBool(),
- false);
- EXPECT_EQ(
- (*response_to_mobile)[am::strings::msg_params][am::strings::result_code]
- .asInt(),
- static_cast<int32_t>(mobile_apis::Result::INVALID_DATA));
-}
-
-TEST_F(SetGlobalPropertiesRequestTest, Run_VRNoMenuAndKeyboard_SUCCESS) {
- MessageSharedPtr msg = CreateMsgParams();
-
- SharedPtr<SetGlobalPropertiesRequest> command(
- CreateCommand<SetGlobalPropertiesRequest>(msg));
- EXPECT_CALL(
- mock_hmi_interfaces_,
- GetInterfaceFromFunction(hmi_apis::FunctionID::UI_SetGlobalProperties))
- .WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
-
- ON_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
- .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
-
- OnEventUISetupHelper(msg, command);
-}
-
-TEST_F(SetGlobalPropertiesRequestTest, Run_VRWithMenuAndKeyboard_SUCCESS) {
- MessageSharedPtr msg = CreateMsgParams();
- SmartObject vr_help_title("yes");
- SmartObject vr_help_array(smart_objects::SmartType_Array);
- VRArraySetupHelper(msg, vr_help_title, vr_help_array);
- (*msg)[am::strings::msg_params][am::strings::vr_help] = vr_help_array;
- SmartObject menu_title("Menu_Title");
- (*msg)[am::strings::msg_params][am::hmi_request::menu_title] = menu_title;
- SmartObject menu_icon(smart_objects::SmartType_Map);
- menu_icon[am::strings::value] = "1";
- (*msg)[am::strings::msg_params][am::hmi_request::menu_icon] = menu_icon;
- SmartObject keyboard_properties(smart_objects::SmartType_Map);
- (*msg)[am::strings::msg_params][am::hmi_request::keyboard_properties] =
- keyboard_properties;
-
- EXPECT_CALL(mock_message_helper_, VerifyImage(menu_icon, _, _))
- .WillOnce((Return(mobile_apis::Result::SUCCESS)));
- EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(vr_help_array, _, _))
- .WillOnce((Return(mobile_apis::Result::SUCCESS)));
- EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey));
- EXPECT_CALL(*mock_app_, set_vr_help_title(vr_help_title));
- EXPECT_CALL(*mock_app_, set_vr_help(vr_help_array));
- EXPECT_CALL(*mock_app_, vr_help_title()).WillOnce(Return(&vr_help_title));
- EXPECT_CALL(*mock_app_, vr_help()).WillOnce(Return(&vr_help_array));
- EXPECT_CALL(*mock_app_, set_menu_title(menu_title));
- EXPECT_CALL(*mock_app_, set_menu_icon(menu_icon));
- EXPECT_CALL(*mock_app_, set_keyboard_props(keyboard_properties));
- EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId));
-
- EXPECT_CALL(
- mock_hmi_interfaces_,
- GetInterfaceFromFunction(hmi_apis::FunctionID::UI_SetGlobalProperties))
- .WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
-
- ON_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
- .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
-
- SharedPtr<SetGlobalPropertiesRequest> command(
- CreateCommand<SetGlobalPropertiesRequest>(msg));
-
- command->Run();
-}
-
-TEST_F(SetGlobalPropertiesRequestTest, Run_VRBrokenMenuIcon_Canceled) {
- MessageSharedPtr msg = CreateMsgParams();
- SmartObject vr_help_title("yes");
- (*msg)[am::strings::msg_params][am::strings::vr_help_title] = vr_help_title;
- SmartObject menu_icon(smart_objects::SmartType_Map);
- menu_icon[am::strings::value] = "1";
- (*msg)[am::strings::msg_params][am::hmi_request::menu_icon] = menu_icon;
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
- EXPECT_CALL(mock_message_helper_, VerifyImage(menu_icon, _, _))
- .WillOnce((Return(mobile_apis::Result::ABORTED)));
- EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(_, _, _)).Times(0);
- EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(_)).Times(0);
- EmptyExpectationsSetupHelper();
-
- SharedPtr<SetGlobalPropertiesRequest> command(
- CreateCommand<SetGlobalPropertiesRequest>(msg));
-
- command->Run();
-}
-
-TEST_F(SetGlobalPropertiesRequestTest, Run_VRBrokenVRHelp_Canceled) {
- MessageSharedPtr msg = CreateMsgParams();
- SmartObject vr_help_title("yes");
- SmartObject menu_icon(smart_objects::SmartType_Map);
- menu_icon[am::strings::value] = "1";
- (*msg)[am::strings::msg_params][am::hmi_request::menu_icon] = menu_icon;
- SmartObject vr_help_array(smart_objects::SmartType_Array);
- VRArraySetupHelper(msg, vr_help_title, vr_help_array);
-
- EXPECT_CALL(mock_message_helper_, VerifyImage(menu_icon, _, _))
- .WillOnce((Return(mobile_apis::Result::SUCCESS)));
- EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(vr_help_array, _, _))
- .WillOnce((Return(mobile_apis::Result::ABORTED)));
- EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(_)).Times(0);
- EmptyExpectationsSetupHelper();
-
- SharedPtr<SetGlobalPropertiesRequest> command(
- CreateCommand<SetGlobalPropertiesRequest>(msg));
-
- command->Run();
-}
-
-TEST_F(SetGlobalPropertiesRequestTest, Run_VRIncorrectSyntax_Canceled) {
- MessageSharedPtr msg = CreateMsgParams();
- (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey;
- (*msg)[am::strings::msg_params][am::strings::app_id] = kAppId;
- SmartObject vr_help_title("wrong syntax string\\n");
- SmartObject menu_icon(smart_objects::SmartType_Map);
- menu_icon[am::strings::value] = "1";
- (*msg)[am::strings::msg_params][am::hmi_request::menu_icon] = menu_icon;
- SmartObject vr_help_array(smart_objects::SmartType_Array);
- VRArraySetupHelper(msg, vr_help_title, vr_help_array);
-
- EXPECT_CALL(mock_message_helper_, VerifyImage(menu_icon, _, _))
- .WillOnce((Return(mobile_apis::Result::SUCCESS)));
- EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(vr_help_array, _, _))
- .WillOnce((Return(mobile_apis::Result::SUCCESS)));
- EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(_)).Times(0);
- EmptyExpectationsSetupHelper();
-
- SharedPtr<SetGlobalPropertiesRequest> command(
- CreateCommand<SetGlobalPropertiesRequest>(msg));
-
- command->Run();
-}
-
-TEST_F(SetGlobalPropertiesRequestTest, Run_VRMissingTitle_Canceled) {
- MessageSharedPtr msg = CreateMsgParams();
- SmartObject vr_help_array(smart_objects::SmartType_Array);
- vr_help_array[0] = SmartObject(smart_objects::SmartType_Map);
- vr_help_array[0][am::strings::text] = kText;
- vr_help_array[0][am::strings::position] = kPosition;
- (*msg)[am::strings::msg_params][am::strings::vr_help] = vr_help_array;
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
- EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(vr_help_array, _, _))
- .WillOnce((Return(mobile_apis::Result::SUCCESS)));
- EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey));
- EmptyExpectationsSetupHelper();
-
- SharedPtr<SetGlobalPropertiesRequest> command(
- CreateCommand<SetGlobalPropertiesRequest>(msg));
-
- command->Run();
-}
-
-TEST_F(SetGlobalPropertiesRequestTest, Run_VRMissingArray_Canceled) {
- MessageSharedPtr msg = CreateMsgParams();
- SmartObject vr_help_title("yes");
- (*msg)[am::strings::msg_params][am::strings::vr_help_title] = vr_help_title;
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
- EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(_, _, _)).Times(0);
- EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey));
- EmptyExpectationsSetupHelper();
-
- SharedPtr<SetGlobalPropertiesRequest> command(
- CreateCommand<SetGlobalPropertiesRequest>(msg));
-
- command->Run();
-}
-
-TEST_F(SetGlobalPropertiesRequestTest, Run_VRWrongOrder_Canceled) {
- MessageSharedPtr msg = CreateMsgParams();
- SmartObject vr_help_title("yes");
- SmartObject vr_help_array(smart_objects::SmartType_Array);
- VRArraySetupHelper(msg, vr_help_title, vr_help_array);
- vr_help_array[1] = SmartObject(smart_objects::SmartType_Map);
- vr_help_array[1][am::strings::text] = "two";
- vr_help_array[1][am::strings::position] = 3u;
- (*msg)[am::strings::msg_params][am::strings::vr_help] = vr_help_array;
-
- EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(vr_help_array, _, _))
- .WillOnce((Return(mobile_apis::Result::SUCCESS)));
- EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey));
- EmptyExpectationsSetupHelper();
-
- SharedPtr<SetGlobalPropertiesRequest> command(
- CreateCommand<SetGlobalPropertiesRequest>(msg));
-
- command->Run();
-}
-
-TEST_F(SetGlobalPropertiesRequestTest, Run_NoVR_SUCCESS) {
- MessageSharedPtr msg = CreateMsgParams();
- SmartObject keyboard_properties(smart_objects::SmartType_Map);
- (*msg)[am::strings::msg_params][am::hmi_request::keyboard_properties] =
- keyboard_properties;
- SmartObject menu_title("Menu_Title");
- (*msg)[am::strings::msg_params][am::hmi_request::menu_title] = menu_title;
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
- EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(_, _, _)).Times(0);
- EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey));
- SmartObject vr_help_title("Menu_Title");
- EXPECT_CALL(*mock_app_, vr_help_title()).WillOnce(Return(&vr_help_title));
- EXPECT_CALL(*mock_app_, set_menu_title(menu_title));
- EXPECT_CALL(*mock_app_, set_menu_icon(_)).Times(0);
- EXPECT_CALL(*mock_app_, set_keyboard_props(keyboard_properties));
- EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId));
-
- EXPECT_CALL(
- mock_hmi_interfaces_,
- GetInterfaceFromFunction(hmi_apis::FunctionID::UI_SetGlobalProperties))
- .WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
- ON_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
- .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
-
- SharedPtr<SetGlobalPropertiesRequest> command(
- CreateCommand<SetGlobalPropertiesRequest>(msg));
-
- command->Run();
-}
-
-TEST_F(SetGlobalPropertiesRequestTest, Run_VRCouldNotGenerate_INVALID_DATA) {
- MessageSharedPtr msg = CreateMsgParams();
- SmartObject keyboard_properties(smart_objects::SmartType_Map);
- (*msg)[am::strings::msg_params][am::hmi_request::keyboard_properties] =
- keyboard_properties;
- SmartObject menu_title("Menu_Title");
- (*msg)[am::strings::msg_params][am::hmi_request::menu_title] = menu_title;
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
- EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(_, _, _)).Times(0);
- EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey));
- SmartObject* vr_help_title = NULL;
- CommandsMap commands_map;
- SmartObject empty_msg(smart_objects::SmartType_Map);
- commands_map.insert(std::pair<uint32_t, SmartObject*>(1u, &empty_msg));
- DataAccessor<CommandsMap> accessor(commands_map, lock_);
- EXPECT_CALL(*mock_app_, commands_map()).WillOnce(Return(accessor));
- EXPECT_CALL(*mock_app_, vr_help_title()).WillOnce(Return(vr_help_title));
- EXPECT_CALL(*mock_app_, set_menu_title(_)).Times(0);
-
- SharedPtr<SetGlobalPropertiesRequest> command(
- CreateCommand<SetGlobalPropertiesRequest>(msg));
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::INVALID_DATA),
- am::commands::Command::ORIGIN_SDL));
-
- command->Run();
-}
-
-TEST_F(SetGlobalPropertiesRequestTest, Run_NoVRNoDataNoDefault_Canceled) {
- MessageSharedPtr msg = CreateMsgParams();
- SmartObject keyboard_properties(smart_objects::SmartType_Map);
- (*msg)[am::strings::msg_params][am::hmi_request::keyboard_properties] =
- keyboard_properties;
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
- EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(_, _, _)).Times(0);
- EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey));
- SmartObject vr_help_title(smart_objects::SmartType_Null);
- EXPECT_CALL(*mock_app_, vr_help_title())
- .WillOnce(Return(&vr_help_title))
- .WillOnce(Return(&vr_help_title));
-
- CommandsMap commands_map;
- DataAccessor<CommandsMap> accessor(commands_map, lock_);
- EXPECT_CALL(*mock_app_, commands_map()).WillOnce(Return(accessor));
- const CustomString name("name");
- EXPECT_CALL(*mock_app_, name()).WillOnce(ReturnRef(name));
- EXPECT_CALL(*mock_app_, set_vr_help_title(SmartObject(name)));
- EXPECT_CALL(*mock_app_, set_menu_title(_)).Times(0);
- EXPECT_CALL(*mock_app_, set_menu_icon(_)).Times(0);
- EXPECT_CALL(*mock_app_, set_keyboard_props(_));
- EXPECT_CALL(*mock_app_, app_id());
-
- EXPECT_CALL(
- mock_hmi_interfaces_,
- GetInterfaceFromFunction(hmi_apis::FunctionID::UI_SetGlobalProperties))
- .WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
- ON_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
- .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
-
- SharedPtr<SetGlobalPropertiesRequest> command(
- CreateCommand<SetGlobalPropertiesRequest>(msg));
-
- command->Run();
-}
-
-TEST_F(SetGlobalPropertiesRequestTest, Run_NoVRNoDataDefaultCreated_SUCCESS) {
- MessageSharedPtr msg = CreateMsgParams();
- SmartObject keyboard_properties(smart_objects::SmartType_Map);
- (*msg)[am::strings::msg_params][am::hmi_request::keyboard_properties] =
- keyboard_properties;
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
- EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(_, _, _)).Times(0);
- EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey));
- SmartObject vr_help_title(smart_objects::SmartType_Null);
- EXPECT_CALL(*mock_app_, vr_help_title())
- .Times(2)
- .WillRepeatedly(Return(&vr_help_title));
-
- CommandsMap commands_map;
- SmartObject command_text(smart_objects::SmartType_Map);
- commands_map[0] = &command_text;
- (*commands_map[0])[am::strings::vr_commands] = SmartObject("one");
- DataAccessor<CommandsMap> accessor(commands_map, lock_);
- EXPECT_CALL(*mock_app_, commands_map()).WillOnce(Return(accessor));
- EXPECT_CALL(*mock_app_, set_vr_help(_));
- const CustomString name("name");
- EXPECT_CALL(*mock_app_, name()).WillOnce(ReturnRef(name));
- EXPECT_CALL(*mock_app_, set_vr_help_title(SmartObject(name)));
- SmartObject vr_help_array(smart_objects::SmartType_Array);
- EXPECT_CALL(*mock_app_, vr_help()).WillOnce(Return(&vr_help_array));
- EXPECT_CALL(*mock_app_, set_menu_title(_)).Times(0);
- EXPECT_CALL(*mock_app_, set_menu_icon(_)).Times(0);
- EXPECT_CALL(*mock_app_, set_keyboard_props(keyboard_properties));
- EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId));
- EXPECT_CALL(
- mock_hmi_interfaces_,
- GetInterfaceFromFunction(hmi_apis::FunctionID::UI_SetGlobalProperties))
- .WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
- ON_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
- .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
-
- SharedPtr<SetGlobalPropertiesRequest> command(
- CreateCommand<SetGlobalPropertiesRequest>(msg));
-
- command->Run();
-}
-
-TEST_F(SetGlobalPropertiesRequestTest, Run_NoVRNoDataFromSynonyms_SUCCESS) {
- MessageSharedPtr msg = CreateMsgParams();
- SmartObject keyboard_properties(smart_objects::SmartType_Map);
- (*msg)[am::strings::msg_params][am::hmi_request::keyboard_properties] =
- keyboard_properties;
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
- EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(_, _, _)).Times(0);
- EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey));
- SmartObject vr_help_title(smart_objects::SmartType_Null);
- EXPECT_CALL(*mock_app_, vr_help_title())
- .Times(2)
- .WillRepeatedly(Return(&vr_help_title));
-
- CommandsMap commands_map;
- DataAccessor<CommandsMap> accessor(commands_map, lock_);
- EXPECT_CALL(*mock_app_, commands_map()).WillOnce(Return(accessor));
- SmartObject vr_help_array(smart_objects::SmartType_Array);
- vr_help_array[0] = SmartObject(smart_objects::SmartType_Map);
- vr_help_array[0][am::strings::text] = kText;
- vr_help_array[0][am::strings::position] = kPosition;
- SmartObject vr_synonyms(smart_objects::SmartType_Array);
- vr_synonyms[0] = vr_help_array;
- const CustomString name("name");
- EXPECT_CALL(*mock_app_, name()).WillOnce(ReturnRef(name));
- EXPECT_CALL(*mock_app_, set_vr_help_title(SmartObject(name)));
- EXPECT_CALL(*mock_app_, set_menu_title(_)).Times(0);
- EXPECT_CALL(*mock_app_, set_menu_icon(_)).Times(0);
- EXPECT_CALL(*mock_app_, set_keyboard_props(keyboard_properties));
- EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId));
- EXPECT_CALL(
- mock_hmi_interfaces_,
- GetInterfaceFromFunction(hmi_apis::FunctionID::UI_SetGlobalProperties))
- .WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
- ON_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
- .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
- SharedPtr<SetGlobalPropertiesRequest> command(
- CreateCommand<SetGlobalPropertiesRequest>(msg));
-
- command->Run();
-}
-
-TEST_F(SetGlobalPropertiesRequestTest, Run_TTSHelpAndTimeout_SUCCESS) {
- MessageSharedPtr msg = CreateMsgParams();
- SmartObject help_prompt(smart_objects::SmartType_Array);
- help_prompt[0][am::strings::text] = "Help_Prompt_One";
- (*msg)[am::strings::msg_params][am::strings::help_prompt] = help_prompt;
- SmartObject timeout_prompt(smart_objects::SmartType_Array);
- timeout_prompt[0][am::strings::text] = "Timeout_Prompt_One";
- (*msg)[am::strings::msg_params][am::strings::timeout_prompt] = timeout_prompt;
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
- EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(_, _, _)).Times(0);
- EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey));
- SmartObject vr_help_title("title");
- EXPECT_CALL(*mock_app_, vr_help_title()).WillOnce(Return(&vr_help_title));
- EXPECT_CALL(*mock_app_, set_help_prompt(help_prompt));
- EXPECT_CALL(*mock_app_, help_prompt()).WillOnce(Return(&help_prompt));
- EXPECT_CALL(*mock_app_, set_timeout_prompt(timeout_prompt));
- EXPECT_CALL(*mock_app_, timeout_prompt()).WillOnce(Return(&timeout_prompt));
- EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId));
-
- EXPECT_CALL(
- mock_hmi_interfaces_,
- GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_SetGlobalProperties))
- .WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_TTS));
- ON_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS))
- .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
-
- SharedPtr<SetGlobalPropertiesRequest> command(
- CreateCommand<SetGlobalPropertiesRequest>(msg));
-
- command->Run();
-}
-
-TEST_F(SetGlobalPropertiesRequestTest, Run_TTSOnlyHelp_SUCCESS) {
- MessageSharedPtr msg = CreateMsgParams();
- SmartObject help_prompt(smart_objects::SmartType_Array);
- help_prompt[0][am::strings::text] = "Help_Prompt_One";
- (*msg)[am::strings::msg_params][am::strings::help_prompt] = help_prompt;
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
- EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(_, _, _)).Times(0);
- EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey));
- SmartObject vr_help_title("title");
- EXPECT_CALL(*mock_app_, vr_help_title()).WillOnce(Return(&vr_help_title));
- EXPECT_CALL(*mock_app_, set_help_prompt(help_prompt));
- EXPECT_CALL(*mock_app_, help_prompt()).WillOnce(Return(&help_prompt));
- EXPECT_CALL(*mock_app_, set_timeout_prompt(_)).Times(0);
- EXPECT_CALL(*mock_app_, timeout_prompt()).Times(0);
- EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId));
- EXPECT_CALL(
- mock_hmi_interfaces_,
- GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_SetGlobalProperties))
- .WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_TTS));
- ON_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS))
- .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
- SharedPtr<SetGlobalPropertiesRequest> command(
- CreateCommand<SetGlobalPropertiesRequest>(msg));
-
- command->Run();
-}
-
-TEST_F(SetGlobalPropertiesRequestTest, Run_TTSOnlyTimeout_SUCCESS) {
- MessageSharedPtr msg = CreateMsgParams();
- SmartObject timeout_prompt(smart_objects::SmartType_Array);
- timeout_prompt[0][am::strings::text] = "Timeout_Prompt_One";
- (*msg)[am::strings::msg_params][am::strings::timeout_prompt] = timeout_prompt;
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
- EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(_, _, _)).Times(0);
- EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey));
- SmartObject vr_help_title("title");
- EXPECT_CALL(*mock_app_, vr_help_title()).WillOnce(Return(&vr_help_title));
- EXPECT_CALL(*mock_app_, set_help_prompt(_)).Times(0);
- EXPECT_CALL(*mock_app_, help_prompt()).Times(0);
- EXPECT_CALL(*mock_app_, set_timeout_prompt(timeout_prompt));
- EXPECT_CALL(*mock_app_, timeout_prompt()).WillOnce(Return(&timeout_prompt));
- EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId));
- EXPECT_CALL(
- mock_hmi_interfaces_,
- GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_SetGlobalProperties))
- .WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_TTS));
- ON_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS))
- .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
- SharedPtr<SetGlobalPropertiesRequest> command(
- CreateCommand<SetGlobalPropertiesRequest>(msg));
-
- command->Run();
-}
-
-TEST_F(SetGlobalPropertiesRequestTest, Run_TTSIncorrectSyntax_Canceled) {
- MessageSharedPtr msg = CreateMsgParams();
- SmartObject timeout_prompt(smart_objects::SmartType_Array);
- timeout_prompt[0][am::strings::text] = "Timeout_Prompt_One\\n";
- (*msg)[am::strings::msg_params][am::strings::timeout_prompt] = timeout_prompt;
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
- EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(_, _, _)).Times(0);
- EmptyExpectationsSetupHelper();
-
- SharedPtr<SetGlobalPropertiesRequest> command(
- CreateCommand<SetGlobalPropertiesRequest>(msg));
-
- command->Run();
-}
-
-TEST_F(SetGlobalPropertiesRequestTest, Run_InvalidHelpPromptText_INVALID_DATA) {
- MessageSharedPtr msg = CreateMsgParams();
- SmartObject help_prompt(smart_objects::SmartType_Array);
- help_prompt[0][am::strings::text] =
- "invalid help prompt text with empty line in the end\\n";
- (*msg)[am::strings::msg_params][am::strings::help_prompt] = help_prompt;
-
- ExpectVerifyImageVrHelpUnsuccess();
- EmptyExpectationsSetupHelper();
-
- SharedPtr<SetGlobalPropertiesRequest> command(
- CreateCommand<SetGlobalPropertiesRequest>(msg));
-
- ExpectInvalidData();
-
- command->Run();
-}
-
-TEST_F(SetGlobalPropertiesRequestTest, Run_InvalidVrHelpText_INVALID_DATA) {
- MessageSharedPtr msg = CreateMsgParams();
- SmartObject vr_help(smart_objects::SmartType_Array);
- vr_help[0][am::strings::text] =
- "invalid vr_help text with empty line in the end\\n";
- (*msg)[am::strings::msg_params][am::strings::vr_help] = vr_help;
-
- ExpectVerifyImageVrHelpSuccess(vr_help);
- EmptyExpectationsSetupHelper();
-
- SharedPtr<SetGlobalPropertiesRequest> command(
- CreateCommand<SetGlobalPropertiesRequest>(msg));
-
- ExpectInvalidData();
-
- command->Run();
-}
-
-TEST_F(SetGlobalPropertiesRequestTest, Run_InvalidImageValue_INVALID_DATA) {
- MessageSharedPtr msg = CreateMsgParams();
- SmartObject vr_help(smart_objects::SmartType_Array);
- vr_help[0][am::strings::text] = "vr_help";
- vr_help[0][am::strings::image][am::strings::value] =
- "invalid value text with empty line in the end\\n";
- (*msg)[am::strings::msg_params][am::strings::vr_help] = vr_help;
-
- ExpectVerifyImageVrHelpSuccess(vr_help);
- EmptyExpectationsSetupHelper();
-
- SharedPtr<SetGlobalPropertiesRequest> command(
- CreateCommand<SetGlobalPropertiesRequest>(msg));
-
- ExpectInvalidData();
-
- command->Run();
-}
-
-TEST_F(SetGlobalPropertiesRequestTest, Run_InvalidMenuIcon_INVALID_DATA) {
- MessageSharedPtr msg = CreateMsgParams();
- SmartObject menu_icon(smart_objects::SmartType_Array);
- menu_icon[am::strings::value] =
- "invalid menu icon text with empty line in the end\\n";
- (*msg)[am::strings::msg_params][am::strings::menu_icon] = menu_icon;
-
- ExpectVerifyImageSuccess(menu_icon);
- EmptyExpectationsSetupHelper();
-
- SharedPtr<SetGlobalPropertiesRequest> command(
- CreateCommand<SetGlobalPropertiesRequest>(msg));
-
- ExpectInvalidData();
-
- command->Run();
-}
-
-TEST_F(SetGlobalPropertiesRequestTest, Run_InvalidMenuTitle_INVALID_DATA) {
- MessageSharedPtr msg = CreateMsgParams();
- SmartObject menu_title(smart_objects::SmartType_Array);
- menu_title = "invalid menu title text with empty line in the end\\n";
- (*msg)[am::strings::msg_params][am::strings::menu_title] = menu_title;
-
- ExpectVerifyImageVrHelpUnsuccess();
- EmptyExpectationsSetupHelper();
-
- SharedPtr<SetGlobalPropertiesRequest> command(
- CreateCommand<SetGlobalPropertiesRequest>(msg));
-
- ExpectInvalidData();
-
- command->Run();
-}
-
-TEST_F(SetGlobalPropertiesRequestTest,
- Run_InvalidLimitedCharacterList_INVALID_DATA) {
- MessageSharedPtr msg = CreateMsgParams();
- SmartObject limited_character_list(smart_objects::SmartType_Array);
- limited_character_list[0] =
- "invalid limited character list text with empty line in the end\\n";
- (*msg)[am::strings::msg_params][am::strings::keyboard_properties]
- [am::strings::limited_character_list] = limited_character_list;
-
- ExpectVerifyImageVrHelpUnsuccess();
- EmptyExpectationsSetupHelper();
-
- SharedPtr<SetGlobalPropertiesRequest> command(
- CreateCommand<SetGlobalPropertiesRequest>(msg));
-
- ExpectInvalidData();
-
- command->Run();
-}
-
-TEST_F(SetGlobalPropertiesRequestTest,
- Run_InvalidAutoCompleteText_INVALID_DATA) {
- MessageSharedPtr msg = CreateMsgParams();
- SmartObject auto_complete_text(smart_objects::SmartType_Array);
- auto_complete_text =
- "invalid auto completetext with empty line in the end\\n";
- (*msg)[am::strings::msg_params][am::strings::keyboard_properties]
- [am::strings::auto_complete_text] = auto_complete_text;
-
- ExpectVerifyImageVrHelpUnsuccess();
- EmptyExpectationsSetupHelper();
-
- SharedPtr<SetGlobalPropertiesRequest> command(
- CreateCommand<SetGlobalPropertiesRequest>(msg));
-
- ExpectInvalidData();
-
- command->Run();
-}
-
-TEST_F(SetGlobalPropertiesRequestTest, Run_NoData_Canceled) {
- MessageSharedPtr msg = CreateMsgParams();
-
- ExpectVerifyImageVrHelpUnsuccess();
- EmptyExpectationsSetupHelper();
-
- SharedPtr<SetGlobalPropertiesRequest> command(
- CreateCommand<SetGlobalPropertiesRequest>(msg));
-
- command->Run();
-}
-
-TEST_F(SetGlobalPropertiesRequestTest, Run_InvalidApp_Canceled) {
- MessageSharedPtr msg = CreateMessage();
- (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey;
-
- ExpectVerifyImageVrHelpUnsuccess();
-
- EmptyExpectationsSetupHelper();
-
- SharedPtr<SetGlobalPropertiesRequest> command(
- CreateCommand<SetGlobalPropertiesRequest>(msg));
-
- command->Run();
-}
-
-TEST_F(SetGlobalPropertiesRequestTest, OnEvent_PendingRequest_UNSUCCESS) {
- MessageSharedPtr msg = CreateMsgParams();
- hmi_apis::Common_Result::eType response_code =
- hmi_apis::Common_Result::SUCCESS;
- (*msg)[am::strings::params][am::hmi_response::code] = response_code;
-
- SharedPtr<SetGlobalPropertiesRequest> command(
- CreateCommand<SetGlobalPropertiesRequest>(msg));
-
- Event event(hmi_apis::FunctionID::UI_SetGlobalProperties);
- event.set_smart_object(*msg);
-
- command->on_event(event);
-}
-
-TEST_F(SetGlobalPropertiesRequestTest, OnEvent_UIAndSuccessResultCode_SUCCESS) {
- MessageSharedPtr msg = CreateMsgParams();
- hmi_apis::Common_Result::eType response_code =
- hmi_apis::Common_Result::SUCCESS;
- (*msg)[am::strings::params][am::hmi_response::code] = response_code;
-
- ON_CALL(
- mock_hmi_interfaces_,
- GetInterfaceFromFunction(hmi_apis::FunctionID::UI_SetGlobalProperties))
- .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
- ON_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
- .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
-
- SharedPtr<SetGlobalPropertiesRequest> command(
- CreateCommand<SetGlobalPropertiesRequest>(msg));
- OnEventUISetupHelper(msg, command);
-
- Event event(hmi_apis::FunctionID::UI_SetGlobalProperties);
- event.set_smart_object(*msg);
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
-
- EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
- .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
-
- EXPECT_CALL(app_mngr_,
- ManageMobileCommand(_, am::commands::Command::ORIGIN_SDL))
- .WillOnce(Return(true));
-
- command->on_event(event);
-}
-
-TEST_F(SetGlobalPropertiesRequestTest, OnEvent_UIAndWarningResultCode_SUCCESS) {
- MessageSharedPtr msg = CreateMsgParams();
- hmi_apis::Common_Result::eType response_code =
- hmi_apis::Common_Result::WARNINGS;
- (*msg)[am::strings::params][am::hmi_response::code] = response_code;
-
- SharedPtr<SetGlobalPropertiesRequest> command(
- CreateCommand<SetGlobalPropertiesRequest>(msg));
- ON_CALL(
- mock_hmi_interfaces_,
- GetInterfaceFromFunction(hmi_apis::FunctionID::UI_SetGlobalProperties))
- .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
- ON_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
- .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
- OnEventUISetupHelper(msg, command);
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
-
- Event event(hmi_apis::FunctionID::UI_SetGlobalProperties);
- event.set_smart_object(*msg);
-
- EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
- .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
- EXPECT_CALL(app_mngr_,
- ManageMobileCommand(_, am::commands::Command::ORIGIN_SDL))
- .WillOnce(Return(true));
-
- command->on_event(event);
-}
-
-TEST_F(SetGlobalPropertiesRequestTest, OnEvent_InvalidApp_Canceled) {
- MessageSharedPtr msg = CreateMsgParams();
- hmi_apis::Common_Result::eType response_code =
- hmi_apis::Common_Result::WARNINGS;
- (*msg)[am::strings::params][am::hmi_response::code] = response_code;
- ON_CALL(
- mock_hmi_interfaces_,
- GetInterfaceFromFunction(hmi_apis::FunctionID::UI_SetGlobalProperties))
- .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
- ON_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
- .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
- SharedPtr<SetGlobalPropertiesRequest> command(
- CreateCommand<SetGlobalPropertiesRequest>(msg));
-
- OnEventUISetupHelper(msg, command);
- EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
- .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillRepeatedly(Return(MockAppPtr()));
-
- EXPECT_CALL(*mock_app_, UpdateHash()).Times(0);
-
- Event event(hmi_apis::FunctionID::UI_SetGlobalProperties);
- event.set_smart_object(*msg);
-
- command->on_event(event);
-}
-
-TEST_F(SetGlobalPropertiesRequestTest, OnEvent_InvalidEventID_Canceled) {
- MessageSharedPtr msg = CreateMessage();
-
- SharedPtr<SetGlobalPropertiesRequest> command(
- CreateCommand<SetGlobalPropertiesRequest>(msg));
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey)).Times(0);
- EXPECT_CALL(*mock_app_, UpdateHash()).Times(0);
-
- Event event(hmi_apis::FunctionID::TTS_Stopped);
- event.set_smart_object(*msg);
-
- command->on_event(event);
-}
-
-TEST_F(SetGlobalPropertiesRequestTest,
- OnEvent_TTSAndSuccessResultCode_SUCCESS) {
- MessageSharedPtr msg = CreateMsgParams();
- hmi_apis::Common_Result::eType response_code =
- hmi_apis::Common_Result::SUCCESS;
- (*msg)[am::strings::params][am::hmi_response::code] = response_code;
- ON_CALL(
- mock_hmi_interfaces_,
- GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_SetGlobalProperties))
- .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_TTS));
- ON_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS))
- .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
- SharedPtr<SetGlobalPropertiesRequest> command(
- CreateCommand<SetGlobalPropertiesRequest>(msg));
-
- OnEventTTSSetupHelper(msg, command);
- EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
- .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
-
- EXPECT_CALL(app_mngr_,
- ManageMobileCommand(_, am::commands::Command::ORIGIN_SDL))
- .WillOnce(Return(true));
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
-
- Event event(hmi_apis::FunctionID::TTS_SetGlobalProperties);
- event.set_smart_object(*msg);
-
- command->on_event(event);
-}
-
-TEST_F(SetGlobalPropertiesRequestTest,
- OnEvent_TTSAndWarningsResultCode_SUCCESS) {
- MessageSharedPtr msg = CreateMsgParams();
- const hmi_apis::Common_Result::eType response_code =
- hmi_apis::Common_Result::WARNINGS;
- (*msg)[am::strings::params][am::hmi_response::code] = response_code;
- ON_CALL(
- mock_hmi_interfaces_,
- GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_SetGlobalProperties))
- .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_TTS));
- ON_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS))
- .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
- SharedPtr<SetGlobalPropertiesRequest> command(
- CreateCommand<SetGlobalPropertiesRequest>(msg));
-
- OnEventTTSSetupHelper(msg, command);
-
- EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
- .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
-
- MessageSharedPtr ui_command_result;
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
- .WillOnce(DoAll(SaveArg<0>(&ui_command_result), Return(true)));
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
-
- Event event(hmi_apis::FunctionID::TTS_SetGlobalProperties);
- event.set_smart_object(*msg);
-
- command->on_event(event);
-
- EXPECT_EQ((*ui_command_result)[am::strings::msg_params][am::strings::success]
- .asBool(),
- true);
- EXPECT_EQ(
- (*ui_command_result)[am::strings::msg_params][am::strings::result_code]
- .asInt(),
- static_cast<int32_t>(hmi_apis::Common_Result::WARNINGS));
-}
-
-} // namespace set_global_properties_request
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace tests
diff --git a/src/components/application_manager/test/commands/mobile/set_media_clock_timer_test.cc b/src/components/application_manager/test/commands/mobile/set_media_clock_timer_test.cc
deleted file mode 100644
index cf668c8b36..0000000000
--- a/src/components/application_manager/test/commands/mobile/set_media_clock_timer_test.cc
+++ /dev/null
@@ -1,352 +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 "application_manager/commands/mobile/set_media_clock_timer_request.h"
-
-#include "gtest/gtest.h"
-#include "application_manager/commands/command_request_test.h"
-#include "application_manager/mock_application_manager.h"
-#include "application_manager/mock_application.h"
-#include "application_manager/mock_message_helper.h"
-#include "application_manager/event_engine/event.h"
-#include "application_manager/mock_hmi_interface.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace set_media_clock_timer_request {
-
-namespace am = ::application_manager;
-using am::commands::SetMediaClockRequest;
-using am::commands::MessageSharedPtr;
-using am::event_engine::Event;
-using am::MockMessageHelper;
-using ::testing::_;
-using ::testing::Return;
-using ::testing::ReturnRef;
-
-namespace UpdateMode = mobile_apis::UpdateMode;
-
-typedef SharedPtr<SetMediaClockRequest> SetMediaClockRequestPtr;
-
-namespace {
-const uint32_t kConnectionKey = 2u;
-const uint32_t kCorrelationId = 2u;
-const uint32_t kAppID = 2u;
-const uint32_t kHours = 2u;
-const uint32_t kMinutes = 26u;
-const uint32_t kSeconds = 1u;
-} // namespace
-
-class SetMediaClockRequestTest
- : public CommandRequestTest<CommandsTestMocks::kIsNice> {
- public:
- SetMediaClockRequestTest() : mock_app_(CreateMockApp()) {}
-
- void SetUp() OVERRIDE {
- ON_CALL(app_mngr_, application(kConnectionKey))
- .WillByDefault(Return(mock_app_));
- ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey));
- }
-
- void ResultCommandExpectations(MessageSharedPtr msg,
- const std::string& info) {
- EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::success].asBool(),
- true);
- EXPECT_EQ(
- (*msg)[am::strings::msg_params][am::strings::result_code].asInt(),
- static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE));
- EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::info].asString(),
- info);
- }
-
- MessageSharedPtr CreateMsgParams() {
- MessageSharedPtr msg = CreateMessage();
- (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey;
- return msg;
- }
-
- void ExpectationsSetupHelper(bool is_media) {
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
- EXPECT_CALL(*mock_app_, is_media_application()).WillOnce(Return(is_media));
- EXPECT_CALL(*mock_app_, app_id()).Times(0);
- EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _));
- }
-
- MockAppPtr mock_app_;
-};
-
-TEST_F(SetMediaClockRequestTest,
- OnEvent_UIHmiSendUnsupportedResource_UNSUPPORTED_RESOURCE) {
- MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
- (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey;
-
- utils::SharedPtr<SetMediaClockRequest> command =
- CreateCommand<SetMediaClockRequest>(msg);
-
- MessageSharedPtr ev_msg = CreateMessage(smart_objects::SmartType_Map);
- (*ev_msg)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
- (*ev_msg)[am::strings::msg_params][am::strings::app_id] = kConnectionKey;
- (*ev_msg)[am::strings::msg_params][am::strings::info] =
- "UI is not supported by system";
-
- Event event(hmi_apis::FunctionID::UI_SetMediaClockTimer);
- event.set_smart_object(*ev_msg);
-
- EXPECT_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
- .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_RESPONSE));
-
- MessageSharedPtr ui_command_result;
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
- .WillOnce(DoAll(SaveArg<0>(&ui_command_result), Return(true)));
-
- command->on_event(event);
-
- ResultCommandExpectations(ui_command_result, "UI is not supported by system");
-}
-
-TEST_F(SetMediaClockRequestTest, Run_UpdateCountUp_SUCCESS) {
- MessageSharedPtr msg = CreateMsgParams();
- (*msg)[am::strings::msg_params][am::strings::update_mode] =
- UpdateMode::COUNTUP;
- (*msg)[am::strings::msg_params][am::strings::start_time][am::strings::hours] =
- kHours;
- (*msg)[am::strings::msg_params][am::strings::start_time]
- [am::strings::minutes] = kMinutes;
- (*msg)[am::strings::msg_params][am::strings::end_time][am::strings::hours] =
- kHours;
- (*msg)[am::strings::msg_params][am::strings::end_time][am::strings::minutes] =
- kMinutes;
- (*msg)[am::strings::msg_params][am::strings::end_time][am::strings::seconds] =
- kSeconds;
-
- SharedPtr<SetMediaClockRequest> command(
- CreateCommand<SetMediaClockRequest>(msg));
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
- EXPECT_CALL(*mock_app_, is_media_application()).WillOnce(Return(true));
- EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppID));
- EXPECT_CALL(app_mngr_, GetNextHMICorrelationID())
- .WillOnce(Return(kCorrelationId));
- ON_CALL(mock_hmi_interfaces_,
- GetInterfaceFromFunction(hmi_apis::FunctionID::UI_SetMediaClockTimer))
- .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
- ON_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
- .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
- EXPECT_CALL(app_mngr_, ManageHMICommand(_)).WillOnce(Return(true));
-
- command->Run();
-}
-
-TEST_F(SetMediaClockRequestTest, Run_UpdateCountDown_SUCCESS) {
- MessageSharedPtr msg = CreateMsgParams();
- (*msg)[am::strings::msg_params][am::strings::update_mode] =
- UpdateMode::COUNTDOWN;
- (*msg)[am::strings::msg_params][am::strings::start_time][am::strings::hours] =
- kHours;
- (*msg)[am::strings::msg_params][am::strings::start_time]
- [am::strings::minutes] = kMinutes;
- (*msg)[am::strings::msg_params][am::strings::start_time]
- [am::strings::seconds] = kSeconds;
- (*msg)[am::strings::msg_params][am::strings::end_time][am::strings::hours] =
- kHours;
- (*msg)[am::strings::msg_params][am::strings::end_time][am::strings::minutes] =
- kMinutes;
-
- SharedPtr<SetMediaClockRequest> command(
- CreateCommand<SetMediaClockRequest>(msg));
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
- EXPECT_CALL(*mock_app_, is_media_application()).WillOnce(Return(true));
- EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppID));
- EXPECT_CALL(app_mngr_, GetNextHMICorrelationID())
- .WillOnce(Return(kCorrelationId));
- ON_CALL(mock_hmi_interfaces_,
- GetInterfaceFromFunction(hmi_apis::FunctionID::UI_SetMediaClockTimer))
- .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
- ON_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
- .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
- EXPECT_CALL(app_mngr_, ManageHMICommand(_)).WillOnce(Return(true));
-
- command->Run();
-}
-
-TEST_F(SetMediaClockRequestTest, Run_UpdateCountUpWrongTime_Canceled) {
- MessageSharedPtr msg = CreateMsgParams();
- (*msg)[am::strings::msg_params][am::strings::update_mode] =
- UpdateMode::COUNTUP;
- (*msg)[am::strings::msg_params][am::strings::start_time][am::strings::hours] =
- kHours;
- (*msg)[am::strings::msg_params][am::strings::start_time]
- [am::strings::minutes] = kMinutes;
- (*msg)[am::strings::msg_params][am::strings::start_time]
- [am::strings::seconds] = kSeconds;
- (*msg)[am::strings::msg_params][am::strings::end_time][am::strings::hours] =
- kHours;
- (*msg)[am::strings::msg_params][am::strings::end_time][am::strings::minutes] =
- kMinutes;
-
- SharedPtr<SetMediaClockRequest> command(
- CreateCommand<SetMediaClockRequest>(msg));
-
- ExpectationsSetupHelper(true);
-
- command->Run();
-}
-
-TEST_F(SetMediaClockRequestTest, Run_UpdateCountDownWrongTime_Canceled) {
- MessageSharedPtr msg = CreateMsgParams();
- (*msg)[am::strings::msg_params][am::strings::update_mode] =
- UpdateMode::COUNTDOWN;
- (*msg)[am::strings::msg_params][am::strings::start_time][am::strings::hours] =
- kHours;
- (*msg)[am::strings::msg_params][am::strings::start_time]
- [am::strings::minutes] = kMinutes;
- (*msg)[am::strings::msg_params][am::strings::end_time][am::strings::hours] =
- kHours;
- (*msg)[am::strings::msg_params][am::strings::end_time][am::strings::minutes] =
- kMinutes;
- (*msg)[am::strings::msg_params][am::strings::end_time][am::strings::seconds] =
- kSeconds;
-
- SharedPtr<SetMediaClockRequest> command(
- CreateCommand<SetMediaClockRequest>(msg));
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
- EXPECT_CALL(*mock_app_, is_media_application()).WillOnce(Return(true));
- EXPECT_CALL(*mock_app_, app_id()).Times(0);
- EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _));
-
- command->Run();
-}
-
-TEST_F(SetMediaClockRequestTest, Run_NoStartTime_Canceled) {
- MessageSharedPtr msg = CreateMsgParams();
- (*msg)[am::strings::msg_params][am::strings::update_mode] =
- UpdateMode::COUNTDOWN;
-
- SharedPtr<SetMediaClockRequest> command(
- CreateCommand<SetMediaClockRequest>(msg));
-
- ExpectationsSetupHelper(true);
-
- command->Run();
-}
-
-TEST_F(SetMediaClockRequestTest, Run_NoUpdateMode_Canceled) {
- MessageSharedPtr msg = CreateMsgParams();
-
- SharedPtr<SetMediaClockRequest> command(
- CreateCommand<SetMediaClockRequest>(msg));
-
- ExpectationsSetupHelper(true);
-
- command->Run();
-}
-
-TEST_F(SetMediaClockRequestTest, Run_NotMediaApp_Canceled) {
- MessageSharedPtr msg = CreateMsgParams();
-
- SharedPtr<SetMediaClockRequest> command(
- CreateCommand<SetMediaClockRequest>(msg));
-
- ExpectationsSetupHelper(false);
-
- command->Run();
-}
-
-TEST_F(SetMediaClockRequestTest, Run_InvalidApp_Canceled) {
- MessageSharedPtr msg = CreateMsgParams();
-
- SharedPtr<SetMediaClockRequest> command(
- CreateCommand<SetMediaClockRequest>(msg));
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(MockAppPtr()));
- EXPECT_CALL(*mock_app_, is_media_application()).Times(0);
- EXPECT_CALL(*mock_app_, app_id()).Times(0);
- EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _));
-
- command->Run();
-}
-
-TEST_F(SetMediaClockRequestTest, OnEvent_Success) {
- MessageSharedPtr msg = CreateMessage();
- (*msg)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::SUCCESS;
- (*msg)[am::strings::msg_params] = SmartObject(smart_objects::SmartType_Null);
-
- EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _));
-
- MockAppPtr app(CreateMockApp());
- EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(app));
-
- Event event(hmi_apis::FunctionID::UI_SetMediaClockTimer);
- event.set_smart_object(*msg);
- SharedPtr<SetMediaClockRequest> command(
- CreateCommand<SetMediaClockRequest>(msg));
- command->on_event(event);
-}
-
-TEST_F(SetMediaClockRequestTest, OnEvent_Canceled) {
- MessageSharedPtr msg = CreateMessage();
-
- SharedPtr<SetMediaClockRequest> command(
- CreateCommand<SetMediaClockRequest>(msg));
-
- EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0);
-
- Event event(hmi_apis::FunctionID::UI_Slider);
- event.set_smart_object(*msg);
-
- command->on_event(event);
-}
-
-} // namespace set_media_clock_timer_request
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/show_test.cc b/src/components/application_manager/test/commands/mobile/show_test.cc
deleted file mode 100644
index 4752bac0fd..0000000000
--- a/src/components/application_manager/test/commands/mobile/show_test.cc
+++ /dev/null
@@ -1,937 +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 <set>
-
-#include "application_manager/commands/mobile/show_request.h"
-
-#include "gtest/gtest.h"
-#include "application_manager/commands/command_request_test.h"
-#include "application_manager/mock_application.h"
-#include "application_manager/mock_application_manager.h"
-#include "application_manager/mock_message_helper.h"
-#include "application_manager/event_engine/event.h"
-#include "application_manager/mock_hmi_interface.h"
-#include "application_manager/policies/mock_policy_handler_interface.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace show_request {
-
-namespace am = application_manager;
-using am::commands::ShowRequest;
-using am::commands::CommandImpl;
-using am::commands::MessageSharedPtr;
-using am::MockMessageHelper;
-using test::components::policy_test::MockPolicyHandlerInterface;
-using ::utils::SharedPtr;
-using ::testing::_;
-using ::testing::Return;
-using ::testing::ReturnRef;
-
-namespace {
-const int32_t kCommandId = 1;
-const uint32_t kAppId = 1u;
-const uint32_t kCmdId = 1u;
-const uint32_t kConnectionKey = 2u;
-const uint32_t kFunctionID = 3u;
-} // namespace
-
-class ShowRequestTest : public CommandRequestTest<CommandsTestMocks::kIsNice> {
- public:
- ShowRequestTest() {
- mock_app_ = CreateMockApp();
- }
- sync_primitives::Lock lock_;
-
- MessageSharedPtr CreateFullParamsUISO() {
- MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
- (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey;
- smart_objects::SmartObject menu_params =
- smart_objects::SmartObject(smart_objects::SmartType_Map);
- menu_params[am::strings::position] = 10;
- menu_params[am::strings::menu_name] = "LG";
-
- smart_objects::SmartObject msg_params =
- smart_objects::SmartObject(smart_objects::SmartType_Map);
- msg_params[am::strings::cmd_id] = kCmdId;
- msg_params[am::strings::menu_params] = menu_params;
- msg_params[am::strings::app_id] = kAppId;
- msg_params[am::strings::cmd_icon] = 1;
- msg_params[am::strings::cmd_icon][am::strings::value] = "10";
- (*msg)[am::strings::msg_params] = msg_params;
-
- return msg;
- }
-
- MessageSharedPtr CreateMsgParams() {
- MessageSharedPtr msg = CreateMessage();
- (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey;
- (*msg)[am::strings::params][am::strings::function_id] = kFunctionID;
- return msg;
- }
-
- void TestSetupHelper(MessageSharedPtr msg,
- hmi_apis::Common_TextFieldName::eType field_name,
- const char* field) {
- SmartObject msg_params(smart_objects::SmartType_Map);
- (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey;
- (*msg)[am::strings::params][am::strings::function_id] = kFunctionID;
- msg_params[field] = text_field_;
- (*msg)[am::strings::msg_params] = msg_params;
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
- EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId));
-
- msg_params[am::strings::app_id] = kAppId;
- msg_params[am::hmi_request::show_strings] =
- smart_objects::SmartObject(smart_objects::SmartType_Array);
- msg_params.erase(field);
- msg_params[am::hmi_request::show_strings][0][am::hmi_request::field_name] =
- static_cast<int32_t>(field_name);
- msg_params[am::hmi_request::show_strings][0][am::hmi_request::field_text] =
- text_field_;
-
- EXPECT_CALL(app_mngr_, ManageHMICommand(_));
- EXPECT_CALL(*mock_app_, set_show_command(msg_params));
- }
-
- void TestSetupHelperWrongSyntax(
- MessageSharedPtr msg,
- hmi_apis::Common_TextFieldName::eType field_name,
- const char* field) {
- SmartObject msg_params(smart_objects::SmartType_Map);
- (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey;
- msg_params[field] = text_field_;
- (*msg)[am::strings::msg_params] = msg_params;
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
- EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _));
- EXPECT_CALL(*mock_app_, app_id()).Times(0);
-
- EXPECT_CALL(app_mngr_, ManageHMICommand(_)).Times(0);
- EXPECT_CALL(*mock_app_, set_show_command(_)).Times(0);
- }
-
- void TestSetupHelperWithMetadata(
- MessageSharedPtr msg,
- hmi_apis::Common_TextFieldName::eType field_name,
- const char* field,
- size_t num_tags,
- int32_t* field_tags,
- bool set_field_text = true) {
- SmartObject msg_params(smart_objects::SmartType_Map);
- (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey;
- (*msg)[am::strings::params][am::strings::function_id] = kFunctionID;
- if (set_field_text) {
- msg_params[field] = text_field_;
- }
- msg_params[am::strings::metadata_tags][field] =
- smart_objects::SmartObject(smart_objects::SmartType_Array);
- for (size_t i = 0; i < num_tags; ++i) {
- const int32_t current_tag = field_tags[i];
- msg_params[am::strings::metadata_tags][field][i] = current_tag;
- }
- (*msg)[am::strings::msg_params] = msg_params;
-
- EXPECT_EQ((*msg)[am::strings::msg_params], msg_params);
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
- EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId));
-
- msg_params.erase(field);
- msg_params.erase(am::strings::metadata_tags);
-
- msg_params[am::strings::app_id] = kAppId;
- msg_params[am::hmi_request::show_strings] =
- smart_objects::SmartObject(smart_objects::SmartType_Array);
- if (set_field_text) {
- msg_params[am::hmi_request::show_strings][0]
- [am::hmi_request::field_name] =
- static_cast<int32_t>(field_name);
- msg_params[am::hmi_request::show_strings][0]
- [am::hmi_request::field_text] = text_field_;
- msg_params[am::hmi_request::show_strings][0]
- [am::hmi_request::field_types] =
- smart_objects::SmartObject(smart_objects::SmartType_Array);
- for (size_t i = 0; i < num_tags; ++i) {
- const int32_t current_tag = field_tags[i];
- msg_params[am::hmi_request::show_strings][0]
- [am::hmi_request::field_types][i] = current_tag;
- }
- }
-
- EXPECT_CALL(app_mngr_, ManageHMICommand(_));
- EXPECT_CALL(*mock_app_, set_show_command(msg_params));
- }
-
- MockAppPtr mock_app_;
- std::string text_field_;
-};
-
-TEST_F(ShowRequestTest, OnEvent_UI_UNSUPPORTED_RESOURCE) {
- MessageSharedPtr msg_vr = CreateFullParamsUISO();
- (*msg_vr)[am::strings::msg_params][am::strings::menu_params]
- [am::hmi_request::parent_id] = 10u;
- (*msg_vr)[am::strings::msg_params][am::strings::menu_params]
- [am::strings::menu_name] = "menu_name";
-
- utils::SharedPtr<ShowRequest> command = CreateCommand<ShowRequest>(msg_vr);
-
- MockAppPtr mock_app = CreateMockApp();
- ON_CALL(app_mngr_, application(kConnectionKey))
- .WillByDefault(Return(mock_app));
- ON_CALL(*mock_app, app_id()).WillByDefault(Return(kConnectionKey));
-
- MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
- (*msg)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
- (*msg)[am::strings::msg_params][am::strings::cmd_id] = kCommandId;
-
- Event event(hmi_apis::FunctionID::UI_Show);
- event.set_smart_object(*msg);
-
- MessageSharedPtr vr_command_result;
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
- .WillOnce(DoAll(SaveArg<0>(&vr_command_result), Return(true)));
-
- command->on_event(event);
-
- EXPECT_EQ((*vr_command_result)[am::strings::msg_params][am::strings::success]
- .asBool(),
- true);
- EXPECT_EQ(
- (*vr_command_result)[am::strings::msg_params][am::strings::result_code]
- .asInt(),
- static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE));
- if ((*vr_command_result)[am::strings::msg_params].keyExists(
- am::strings::info)) {
- EXPECT_FALSE(
- (*vr_command_result)[am::strings::msg_params][am::strings::info]
- .asString()
- .empty());
- }
-}
-
-TEST_F(ShowRequestTest, Run_SoftButtonExists_SUCCESS) {
- MessageSharedPtr msg = CreateMsgParams();
-
- SmartObject msg_params(smart_objects::SmartType_Map);
- msg_params[am::strings::soft_buttons] = "Soft_Buttons";
- (*msg)[am::strings::msg_params] = msg_params;
- SmartObject creation_msg_params(msg_params);
- SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg));
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
- MockPolicyHandlerInterface mock_policy_handler;
- EXPECT_CALL(app_mngr_, GetPolicyHandler())
- .WillOnce(ReturnRef(mock_policy_handler));
- EXPECT_CALL(mock_message_helper_, ProcessSoftButtons(msg_params, _, _, _))
- .WillOnce(Return(mobile_apis::Result::SUCCESS));
- EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId));
-
- msg_params[am::strings::app_id] = kAppId;
- msg_params[am::hmi_request::show_strings] =
- smart_objects::SmartObject(smart_objects::SmartType_Array);
-
- EXPECT_CALL(
- mock_message_helper_,
- SubscribeApplicationToSoftButton(creation_msg_params, _, kFunctionID));
- EXPECT_CALL(app_mngr_, ManageHMICommand(_));
- EXPECT_CALL(*mock_app_, set_show_command(msg_params));
-
- command->Run();
-}
-
-TEST_F(ShowRequestTest, Run_SoftButtonNotExists_SUCCESS) {
- MessageSharedPtr msg = CreateMsgParams();
-
- SmartObject msg_params(smart_objects::SmartType_Map);
- msg_params[am::strings::soft_buttons] = "";
- (*msg)[am::strings::msg_params] = msg_params;
- SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg));
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
- MockPolicyHandlerInterface mock_policy_handler;
- EXPECT_CALL(app_mngr_, GetPolicyHandler()).Times(0);
- EXPECT_CALL(mock_message_helper_, ProcessSoftButtons(_, _, _, _)).Times(0);
- EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId));
-
- msg_params[am::strings::app_id] = kAppId;
- msg_params[am::hmi_request::show_strings] =
- smart_objects::SmartObject(smart_objects::SmartType_Array);
-
- EXPECT_CALL(*mock_app_, UnsubscribeFromSoftButtons(kFunctionID));
- EXPECT_CALL(app_mngr_, ManageHMICommand(_));
- EXPECT_CALL(*mock_app_, set_show_command(msg_params));
-
- command->Run();
-}
-
-TEST_F(ShowRequestTest, Run_SoftButtonExists_Canceled) {
- MessageSharedPtr msg = CreateMsgParams();
-
- SmartObject msg_params(smart_objects::SmartType_Map);
- msg_params[am::strings::soft_buttons] = "Soft_Buttons";
- (*msg)[am::strings::msg_params] = msg_params;
-
- SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg));
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
- MockPolicyHandlerInterface mock_policy_handler;
- EXPECT_CALL(app_mngr_, GetPolicyHandler())
- .WillOnce(ReturnRef(mock_policy_handler));
- EXPECT_CALL(mock_message_helper_, ProcessSoftButtons(msg_params, _, _, _))
- .WillOnce(Return(mobile_apis::Result::ABORTED));
-
- EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _));
-
- EXPECT_CALL(*mock_app_, app_id()).Times(0);
-
- EXPECT_CALL(mock_message_helper_, SubscribeApplicationToSoftButton(_, _, _))
- .Times(0);
- EXPECT_CALL(app_mngr_, ManageHMICommand(_)).Times(0);
- EXPECT_CALL(*mock_app_, set_show_command(_)).Times(0);
-
- command->Run();
-}
-
-TEST_F(ShowRequestTest, Run_Graphic_SUCCESS) {
- MessageSharedPtr msg = CreateMsgParams();
-
- SmartObject msg_params(smart_objects::SmartType_Map);
- SmartObject graphic(smart_objects::SmartType_Map);
- graphic[am::strings::value] = "1";
- msg_params[am::strings::graphic] = graphic;
- (*msg)[am::strings::msg_params] = msg_params;
-
- SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg));
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
- EXPECT_CALL(mock_message_helper_, VerifyImage(graphic, _, _))
- .WillOnce(Return(mobile_apis::Result::SUCCESS));
- EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId));
-
- msg_params[am::strings::app_id] = kAppId;
- msg_params[am::hmi_request::show_strings] =
- smart_objects::SmartObject(smart_objects::SmartType_Array);
-
- EXPECT_CALL(app_mngr_, ManageHMICommand(_));
- EXPECT_CALL(*mock_app_, set_show_command(msg_params));
-
- command->Run();
-}
-
-TEST_F(ShowRequestTest, Run_Graphic_Canceled) {
- MessageSharedPtr msg = CreateMsgParams();
-
- SmartObject msg_params(smart_objects::SmartType_Map);
- SmartObject graphic(smart_objects::SmartType_Map);
- graphic[am::strings::value] = "1";
- msg_params[am::strings::graphic] = graphic;
- (*msg)[am::strings::msg_params] = msg_params;
-
- SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg));
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
- EXPECT_CALL(mock_message_helper_, VerifyImage(graphic, _, _))
- .WillOnce(Return(mobile_apis::Result::ABORTED));
- EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _));
- EXPECT_CALL(*mock_app_, app_id()).Times(0);
-
- EXPECT_CALL(app_mngr_, ManageHMICommand(_)).Times(0);
- EXPECT_CALL(*mock_app_, set_show_command(msg_params)).Times(0);
-
- command->Run();
-}
-
-TEST_F(ShowRequestTest, Run_Graphic_WrongSyntax) {
- MessageSharedPtr msg = CreateMsgParams();
-
- SmartObject msg_params(smart_objects::SmartType_Map);
- SmartObject graphic(smart_objects::SmartType_Map);
- graphic[am::strings::value] = "\\n";
- msg_params[am::strings::graphic] = graphic;
- (*msg)[am::strings::msg_params] = msg_params;
-
- SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg));
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
- EXPECT_CALL(mock_message_helper_, VerifyImage(_, _, _)).Times(0);
- EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _));
- EXPECT_CALL(*mock_app_, app_id()).Times(0);
-
- EXPECT_CALL(app_mngr_, ManageHMICommand(_)).Times(0);
- EXPECT_CALL(*mock_app_, set_show_command(msg_params)).Times(0);
-
- command->Run();
-}
-
-TEST_F(ShowRequestTest, Run_SecondaryGraphic_SUCCESS) {
- MessageSharedPtr msg = CreateMsgParams();
-
- SmartObject msg_params(smart_objects::SmartType_Map);
- SmartObject graphic(smart_objects::SmartType_Map);
- graphic[am::strings::value] = "1";
- msg_params[am::strings::secondary_graphic] = graphic;
- (*msg)[am::strings::msg_params] = msg_params;
-
- SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg));
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
- EXPECT_CALL(mock_message_helper_, VerifyImage(graphic, _, _))
- .WillOnce(Return(mobile_apis::Result::SUCCESS));
- EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId));
-
- msg_params[am::strings::app_id] = kAppId;
- msg_params[am::hmi_request::show_strings] =
- smart_objects::SmartObject(smart_objects::SmartType_Array);
-
- EXPECT_CALL(app_mngr_, ManageHMICommand(_));
- EXPECT_CALL(*mock_app_, set_show_command(msg_params));
-
- command->Run();
-}
-
-TEST_F(ShowRequestTest, Run_SecondaryGraphic_Canceled) {
- MessageSharedPtr msg = CreateMsgParams();
-
- SmartObject msg_params(smart_objects::SmartType_Map);
- SmartObject graphic(smart_objects::SmartType_Map);
- graphic[am::strings::value] = "1";
- msg_params[am::strings::secondary_graphic] = graphic;
- (*msg)[am::strings::msg_params] = msg_params;
-
- SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg));
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
- EXPECT_CALL(mock_message_helper_, VerifyImage(graphic, _, _))
- .WillOnce(Return(mobile_apis::Result::ABORTED));
- EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _));
- EXPECT_CALL(*mock_app_, app_id()).Times(0);
-
- EXPECT_CALL(app_mngr_, ManageHMICommand(_)).Times(0);
- EXPECT_CALL(*mock_app_, set_show_command(msg_params)).Times(0);
-
- command->Run();
-}
-
-TEST_F(ShowRequestTest, Run_SecondaryGraphic_WrongSyntax) {
- MessageSharedPtr msg = CreateMsgParams();
-
- SmartObject msg_params(smart_objects::SmartType_Map);
- SmartObject graphic(smart_objects::SmartType_Map);
- graphic[am::strings::value] = "";
- msg_params[am::strings::secondary_graphic] = graphic;
- (*msg)[am::strings::msg_params] = msg_params;
-
- SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg));
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
- EXPECT_CALL(mock_message_helper_, VerifyImage(graphic, _, _)).Times(0);
- EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _));
- EXPECT_CALL(*mock_app_, app_id()).Times(0);
-
- EXPECT_CALL(app_mngr_, ManageHMICommand(_)).Times(0);
- EXPECT_CALL(*mock_app_, set_show_command(msg_params)).Times(0);
-
- command->Run();
-}
-
-TEST_F(ShowRequestTest, Run_MainField1_SUCCESS) {
- MessageSharedPtr msg = CreateMsgParams();
-
- SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg));
-
- text_field_ = "Main_Field_1";
- TestSetupHelper(msg,
- hmi_apis::Common_TextFieldName::mainField1,
- am::strings::main_field_1);
-
- command->Run();
-}
-
-TEST_F(ShowRequestTest, Run_MainField1_WrongSyntax) {
- MessageSharedPtr msg = CreateMessage();
-
- SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg));
-
- text_field_ = "Main_Field_1\\n";
- TestSetupHelperWrongSyntax(msg,
- hmi_apis::Common_TextFieldName::mainField1,
- am::strings::main_field_1);
-
- command->Run();
-}
-
-TEST_F(ShowRequestTest, Run_MainField2_SUCCESS) {
- MessageSharedPtr msg = CreateMsgParams();
-
- SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg));
-
- text_field_ = "Main_Field_2";
- TestSetupHelper(msg,
- hmi_apis::Common_TextFieldName::mainField2,
- am::strings::main_field_2);
- command->Run();
-}
-
-TEST_F(ShowRequestTest, Run_MainField2_WrongSyntax) {
- MessageSharedPtr msg = CreateMessage();
-
- SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg));
-
- text_field_ = "Main_Field_2\\n";
- TestSetupHelperWrongSyntax(msg,
- hmi_apis::Common_TextFieldName::mainField2,
- am::strings::main_field_2);
- command->Run();
-}
-
-TEST_F(ShowRequestTest, Run_MainField3_SUCCESS) {
- MessageSharedPtr msg = CreateMsgParams();
-
- SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg));
-
- text_field_ = "Main_Field_3";
- TestSetupHelper(msg,
- hmi_apis::Common_TextFieldName::mainField3,
- am::strings::main_field_3);
- command->Run();
-}
-
-TEST_F(ShowRequestTest, Run_MainField3_WrongSyntax) {
- MessageSharedPtr msg = CreateMessage();
-
- SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg));
-
- text_field_ = "Main_Field_3\\n";
- TestSetupHelperWrongSyntax(msg,
- hmi_apis::Common_TextFieldName::mainField3,
- am::strings::main_field_3);
- command->Run();
-}
-
-TEST_F(ShowRequestTest, Run_MainField4_SUCCESS) {
- MessageSharedPtr msg = CreateMsgParams();
-
- SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg));
-
- text_field_ = "Main_Field_4";
- TestSetupHelper(msg,
- hmi_apis::Common_TextFieldName::mainField4,
- am::strings::main_field_4);
- command->Run();
-}
-
-TEST_F(ShowRequestTest, Run_MainField4_WrongSyntax) {
- MessageSharedPtr msg = CreateMessage();
-
- SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg));
-
- text_field_ = "Main_Field_4\\n";
- TestSetupHelperWrongSyntax(msg,
- hmi_apis::Common_TextFieldName::mainField4,
- am::strings::main_field_4);
- command->Run();
-}
-
-TEST_F(ShowRequestTest, Run_MainField1_MetadataTag) {
- MessageSharedPtr msg = CreateMsgParams();
-
- SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg));
-
- text_field_ = "Main_Field_1";
- const size_t num_tags = 1;
- int32_t tags[num_tags] = {hmi_apis::Common_MetadataType::mediaArtist};
- TestSetupHelperWithMetadata(msg,
- hmi_apis::Common_TextFieldName::mainField1,
- am::strings::main_field_1,
- num_tags,
- tags);
- command->Run();
-}
-
-TEST_F(ShowRequestTest, Run_MainField1_MultipleMetadataTags) {
- MessageSharedPtr msg = CreateMsgParams();
-
- SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg));
-
- text_field_ = "Main_Field_1";
- const size_t num_tags = 5;
- int32_t tags[num_tags] = {hmi_apis::Common_MetadataType::mediaTitle,
- hmi_apis::Common_MetadataType::mediaArtist,
- hmi_apis::Common_MetadataType::rating,
- hmi_apis::Common_MetadataType::humidity,
- hmi_apis::Common_MetadataType::currentTemperature};
- TestSetupHelperWithMetadata(msg,
- hmi_apis::Common_TextFieldName::mainField1,
- am::strings::main_field_1,
- num_tags,
- tags);
- command->Run();
-}
-
-TEST_F(ShowRequestTest, Run_MainField2_MetadataTag) {
- MessageSharedPtr msg = CreateMsgParams();
-
- SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg));
-
- text_field_ = "Main_Field_2";
- const size_t num_tags = 1;
- int32_t tags[num_tags] = {hmi_apis::Common_MetadataType::mediaArtist};
- TestSetupHelperWithMetadata(msg,
- hmi_apis::Common_TextFieldName::mainField2,
- am::strings::main_field_2,
- num_tags,
- tags);
- command->Run();
-}
-
-TEST_F(ShowRequestTest, Run_MainField3_MetadataTag) {
- MessageSharedPtr msg = CreateMsgParams();
-
- SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg));
-
- text_field_ = "Main_Field_3";
- const size_t num_tags = 1;
- int32_t tags[num_tags] = {hmi_apis::Common_MetadataType::mediaArtist};
- TestSetupHelperWithMetadata(msg,
- hmi_apis::Common_TextFieldName::mainField3,
- am::strings::main_field_3,
- num_tags,
- tags);
- command->Run();
-}
-
-TEST_F(ShowRequestTest, Run_MainField4_MetadataTag) {
- MessageSharedPtr msg = CreateMsgParams();
-
- SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg));
-
- text_field_ = "Main_Field_4";
- const size_t num_tags = 1;
- int32_t tags[num_tags] = {hmi_apis::Common_MetadataType::mediaArtist};
- TestSetupHelperWithMetadata(msg,
- hmi_apis::Common_TextFieldName::mainField4,
- am::strings::main_field_4,
- num_tags,
- tags);
- command->Run();
-}
-
-TEST_F(ShowRequestTest, Run_MainField1_MetadataTagWithNoFieldData) {
- MessageSharedPtr msg = CreateMsgParams();
-
- SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg));
-
- text_field_ = "Main_Field_1";
- const size_t num_tags = 1;
- int32_t tags[num_tags] = {hmi_apis::Common_MetadataType::mediaArtist};
- TestSetupHelperWithMetadata(msg,
- hmi_apis::Common_TextFieldName::mainField1,
- am::strings::main_field_1,
- num_tags,
- tags,
- false);
- command->Run();
-
- MessageSharedPtr ev_msg = CreateMessage(smart_objects::SmartType_Map);
- (*ev_msg)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::SUCCESS;
- (*ev_msg)[am::strings::msg_params][am::strings::app_id] = kConnectionKey;
- (*ev_msg)[am::strings::msg_params][am::strings::info] = "";
-
- Event event(hmi_apis::FunctionID::UI_Show);
- event.set_smart_object(*ev_msg);
-
- MessageSharedPtr ui_command_result;
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
- .WillOnce(DoAll(SaveArg<0>(&ui_command_result), Return(true)));
-
- command->on_event(event);
-
- EXPECT_EQ((*ui_command_result)[am::strings::msg_params][am::strings::success]
- .asBool(),
- true);
- EXPECT_EQ(
- (*ui_command_result)[am::strings::msg_params][am::strings::result_code]
- .asInt(),
- static_cast<int32_t>(mobile_apis::Result::WARNINGS));
-}
-
-TEST_F(ShowRequestTest, Run_MediaClock_SUCCESS) {
- MessageSharedPtr msg = CreateMsgParams();
-
- SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg));
-
- text_field_ = "Media_Clock";
- TestSetupHelper(msg,
- hmi_apis::Common_TextFieldName::mediaClock,
- am::strings::media_clock);
- command->Run();
-}
-
-TEST_F(ShowRequestTest, Run_MediaClock_WrongSyntax) {
- MessageSharedPtr msg = CreateMessage();
-
- SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg));
-
- text_field_ = "Media_Clock\\n";
- TestSetupHelperWrongSyntax(msg,
- hmi_apis::Common_TextFieldName::mediaClock,
- am::strings::media_clock);
- command->Run();
-}
-
-TEST_F(ShowRequestTest, Run_MediaTrack_SUCCESS) {
- MessageSharedPtr msg = CreateMsgParams();
-
- SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg));
-
- text_field_ = "Media_Track";
- TestSetupHelper(msg,
- hmi_apis::Common_TextFieldName::mediaTrack,
- am::strings::media_track);
- command->Run();
-}
-
-TEST_F(ShowRequestTest, Run_MediaTrack_WrongSyntax) {
- MessageSharedPtr msg = CreateMessage();
-
- SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg));
-
- text_field_ = "Media_Track\\n";
- TestSetupHelperWrongSyntax(msg,
- hmi_apis::Common_TextFieldName::mediaTrack,
- am::strings::media_track);
- command->Run();
-}
-
-TEST_F(ShowRequestTest, Run_StatusBar_SUCCESS) {
- MessageSharedPtr msg = CreateMsgParams();
-
- SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg));
-
- text_field_ = "Status_Bar";
- TestSetupHelper(
- msg, hmi_apis::Common_TextFieldName::statusBar, am::strings::status_bar);
- command->Run();
-}
-
-TEST_F(ShowRequestTest, Run_StatusBar_WrongSyntax) {
- MessageSharedPtr msg = CreateMessage();
-
- SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg));
-
- text_field_ = "Status_Bar\\n";
- TestSetupHelperWrongSyntax(
- msg, hmi_apis::Common_TextFieldName::statusBar, am::strings::status_bar);
- command->Run();
-}
-
-TEST_F(ShowRequestTest, Run_Alignment_SUCCESS) {
- MessageSharedPtr msg = CreateMsgParams();
- SmartObject msg_params(smart_objects::SmartType_Map);
- msg_params[am::strings::alignment] = "Alignment";
- (*msg)[am::strings::msg_params] = msg_params;
-
- SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg));
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
- EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId));
-
- msg_params[am::strings::app_id] = kAppId;
- msg_params[am::hmi_request::show_strings] =
- smart_objects::SmartObject(smart_objects::SmartType_Array);
-
- EXPECT_CALL(app_mngr_, ManageHMICommand(_));
- EXPECT_CALL(*mock_app_, set_show_command(msg_params));
-
- command->Run();
-}
-
-TEST_F(ShowRequestTest, Run_CustomPresets_SUCCESS) {
- MessageSharedPtr msg = CreateMsgParams();
- SmartObject msg_params(smart_objects::SmartType_Map);
- SmartObject custom_presets(smart_objects::SmartType_Array);
- custom_presets[0] = "Custom_Presets";
- msg_params[am::strings::custom_presets] = custom_presets;
- (*msg)[am::strings::msg_params] = msg_params;
-
- SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg));
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
- EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId));
-
- msg_params[am::strings::app_id] = kAppId;
- msg_params[am::hmi_request::show_strings] =
- smart_objects::SmartObject(smart_objects::SmartType_Array);
-
- EXPECT_CALL(app_mngr_, ManageHMICommand(_));
- EXPECT_CALL(*mock_app_, set_show_command(msg_params));
-
- command->Run();
-}
-
-TEST_F(ShowRequestTest, Run_CustomPresets_WrongSyntax) {
- MessageSharedPtr msg = CreateMsgParams();
- SmartObject msg_params(smart_objects::SmartType_Map);
- SmartObject custom_presets(smart_objects::SmartType_Array);
- custom_presets[0] = "Custom_Presets\\t";
- msg_params[am::strings::custom_presets] = custom_presets;
- (*msg)[am::strings::msg_params] = msg_params;
-
- SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg));
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
- EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _));
- EXPECT_CALL(*mock_app_, app_id()).Times(0);
-
- EXPECT_CALL(app_mngr_, ManageHMICommand(_)).Times(0);
- EXPECT_CALL(*mock_app_, set_show_command(_)).Times(0);
-
- command->Run();
-}
-
-TEST_F(ShowRequestTest, Run_InvalidApp_Canceled) {
- MessageSharedPtr msg = CreateMsgParams();
-
- SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg));
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(MockAppPtr()));
- EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _));
- EXPECT_CALL(*mock_app_, app_id()).Times(0);
- EXPECT_CALL(app_mngr_, ManageHMICommand(_)).Times(0);
- EXPECT_CALL(*mock_app_, set_show_command(_)).Times(0);
-
- command->Run();
-}
-
-TEST_F(ShowRequestTest, Run_EmptyParams_Canceled) {
- MessageSharedPtr msg = CreateMsgParams();
-
- SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg));
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
- EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _));
- EXPECT_CALL(*mock_app_, app_id()).Times(0);
- EXPECT_CALL(app_mngr_, ManageHMICommand(_)).Times(0);
- EXPECT_CALL(*mock_app_, set_show_command(_)).Times(0);
-
- command->Run();
-}
-
-TEST_F(ShowRequestTest, OnEvent_SuccessResultCode_SUCCESS) {
- MessageSharedPtr msg = CreateMessage();
- (*msg)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::eType::SUCCESS;
- (*msg)[am::strings::msg_params] = SmartObject(smart_objects::SmartType_Map);
-
- SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg));
-
- EXPECT_CALL(app_mngr_,
- ManageMobileCommand(
- MobileResultCodeIs(mobile_apis::Result::eType::SUCCESS), _));
-
- Event event(hmi_apis::FunctionID::UI_Show);
- event.set_smart_object(*msg);
-
- EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(mock_app_));
-
- command->on_event(event);
-}
-
-TEST_F(ShowRequestTest, OnEvent_WarningsResultCode_SUCCESS) {
- MessageSharedPtr msg = CreateMessage();
- (*msg)[am::strings::params][am::hmi_response::code] =
- mobile_apis::Result::WARNINGS;
- (*msg)[am::strings::params][am::hmi_response::message] = "Response Info";
- (*msg)[am::strings::msg_params] = SmartObject(smart_objects::SmartType_Map);
-
- SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg));
-
- EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _));
-
- Event event(hmi_apis::FunctionID::UI_Show);
- event.set_smart_object(*msg);
-
- EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(mock_app_));
-
- command->on_event(event);
-}
-
-TEST_F(ShowRequestTest, OnEvent_WrongFunctionID_Canceled) {
- MessageSharedPtr msg = CreateMessage();
- (*msg)[am::strings::params][am::hmi_response::code] =
- mobile_apis::Result::SUCCESS;
-
- SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg));
-
- EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0);
-
- Event event(hmi_apis::FunctionID::UI_Alert);
- event.set_smart_object(*msg);
-
- command->on_event(event);
-}
-
-} // namespace show_request
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace tests
diff --git a/src/components/application_manager/test/commands/mobile/simple_notification_commands_test.cc b/src/components/application_manager/test/commands/mobile/simple_notification_commands_test.cc
deleted file mode 100644
index 7ded373d29..0000000000
--- a/src/components/application_manager/test/commands/mobile/simple_notification_commands_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 "application_manager/mock_message_helper.h"
-#include "command_impl.h"
-#include "commands/commands_test.h"
-#include "mobile/on_app_interface_unregistered_notification.h"
-#include "mobile/on_audio_pass_thru_notification.h"
-#include "mobile/on_driver_distraction_notification.h"
-#include "mobile/on_language_change_notification.h"
-#include "mobile/on_permissions_change_notification.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace simple_notification_commands_test {
-
-namespace am = ::application_manager;
-namespace commands = am::commands;
-
-using ::testing::_;
-using ::testing::Types;
-using ::testing::Return;
-
-template <class Command>
-class MobileNotificationCommandsTest
- : public CommandsTest<CommandsTestMocks::kIsNice> {
- public:
- typedef Command CommandType;
-};
-
-typedef Types<commands::OnAppInterfaceUnregisteredNotification,
- commands::OnAudioPassThruNotification,
- commands::OnLanguageChangeNotification,
- commands::OnPermissionsChangeNotification,
- commands::mobile::OnDriverDistractionNotification>
- NotificationCommandsList;
-
-MATCHER(CheckNotificationMessage, "") {
- return (*arg)[am::strings::params][am::strings::protocol_type].asInt() ==
- commands::CommandImpl::mobile_protocol_type_ &&
- (*arg)[am::strings::params][am::strings::protocol_version].asInt() ==
- commands::CommandImpl::protocol_version_ &&
- (*arg)[am::strings::params][am::strings::message_type].asInt() ==
- application_manager::MessageType::kNotification;
-}
-
-TYPED_TEST_CASE(MobileNotificationCommandsTest, NotificationCommandsList);
-
-TYPED_TEST(MobileNotificationCommandsTest, Run_SendMessageToMobile_SUCCESS) {
- ::utils::SharedPtr<typename TestFixture::CommandType> command =
- this->template CreateCommand<typename TestFixture::CommandType>();
- EXPECT_CALL(this->app_mngr_,
- SendMessageToMobile(CheckNotificationMessage(), _));
- command->Run();
-}
-
-} // namespace simple_notification_commands_test
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/simple_response_commands_test.cc b/src/components/application_manager/test/commands/mobile/simple_response_commands_test.cc
deleted file mode 100644
index d80a7e0551..0000000000
--- a/src/components/application_manager/test/commands/mobile/simple_response_commands_test.cc
+++ /dev/null
@@ -1,199 +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/helpers.h"
-#include "utils/shared_ptr.h"
-#include "commands/commands_test.h"
-#include "application_manager/mock_application_manager.h"
-#include "mobile/read_did_response.h"
-#include "mobile/delete_command_response.h"
-#include "mobile/alert_maneuver_response.h"
-#include "mobile/alert_response.h"
-#include "mobile/list_files_response.h"
-#include "mobile/subscribe_button_response.h"
-#include "mobile/add_sub_menu_response.h"
-#include "mobile/diagnostic_message_response.h"
-#include "mobile/dial_number_response.h"
-#include "mobile/end_audio_pass_thru_response.h"
-#include "mobile/get_dtcs_response.h"
-#include "mobile/get_vehicle_data_response.h"
-#include "mobile/unregister_app_interface_response.h"
-#include "mobile/unsubscribe_button_response.h"
-#include "mobile/unsubscribe_way_points_response.h"
-#include "mobile/update_turn_list_response.h"
-#include "mobile/slider_response.h"
-#include "mobile/speak_response.h"
-#include "mobile/subscribe_vehicle_data_response.h"
-#include "mobile/subscribe_way_points_response.h"
-#include "mobile/system_response.h"
-#include "mobile/get_way_points_response.h"
-#include "mobile/perform_interaction_response.h"
-#include "mobile/perform_audio_pass_thru_response.h"
-#include "mobile/set_global_properties_response.h"
-#include "mobile/set_media_clock_timer_response.h"
-#include "mobile/show_constant_tbt_response.h"
-#include "mobile/show_response.h"
-#include "mobile/add_command_response.h"
-#include "mobile/send_location_response.h"
-#include "mobile/set_app_icon_response.h"
-#include "mobile/set_display_layout_response.h"
-#include "mobile/generic_response.h"
-#include "mobile/set_app_icon_response.h"
-#include "mobile/scrollable_message_response.h"
-#include "mobile/change_registration_response.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace simple_response_commands_test {
-
-namespace commands = ::application_manager::commands;
-namespace am = ::application_manager;
-
-using ::testing::_;
-using ::testing::NotNull;
-using ::testing::Types;
-
-using commands::MessageSharedPtr;
-
-template <class Command>
-class MobileResponseCommandsTest
- : public CommandsTest<CommandsTestMocks::kIsNice> {
- public:
- typedef Command CommandType;
-};
-
-typedef Types<commands::ListFilesResponse,
- commands::ReadDIDResponse,
- commands::DeleteCommandResponse,
- commands::AlertManeuverResponse,
- commands::AlertResponse,
- commands::SubscribeButtonResponse,
- commands::AddSubMenuResponse,
- commands::DiagnosticMessageResponse,
- commands::DialNumberResponse,
- commands::EndAudioPassThruResponse,
- commands::GetDTCsResponse,
- commands::GetVehicleDataResponse,
- commands::UnregisterAppInterfaceResponse,
- commands::UnsubscribeWayPointsResponse,
- commands::UpdateTurnListResponse,
- commands::UnsubscribeButtonResponse,
- commands::SliderResponse,
- commands::SpeakResponse,
- commands::SubscribeVehicleDataResponse,
- commands::SubscribeWayPointsResponse,
- commands::SystemResponse,
- commands::GetWayPointsResponse,
- commands::PerformInteractionResponse,
- commands::PerformAudioPassThruResponse,
- commands::SetGlobalPropertiesResponse,
- commands::SetMediaClockTimerResponse,
- commands::ShowConstantTBTResponse,
- commands::ShowResponse,
- commands::SystemResponse,
- commands::AddCommandResponse,
- commands::SendLocationResponse,
- commands::SetAppIconResponse,
- commands::SetDisplayLayoutResponse,
- commands::ChangeRegistrationResponse> ResponseCommandsList;
-
-TYPED_TEST_CASE(MobileResponseCommandsTest, ResponseCommandsList);
-
-TYPED_TEST(MobileResponseCommandsTest, Run_SendResponseToMobile_SUCCESS) {
- ::utils::SharedPtr<typename TestFixture::CommandType> command =
- this->template CreateCommand<typename TestFixture::CommandType>();
- EXPECT_CALL(this->app_mngr_, SendMessageToMobile(NotNull(), _));
- command->Run();
-}
-
-class GenericResponseFromHMICommandsTest
- : public CommandsTest<CommandsTestMocks::kIsNice> {};
-
-MATCHER_P2(CheckMessageParams, success, result, "") {
- const bool is_msg_type_correct =
- (am::MessageType::kResponse) ==
- static_cast<int32_t>(
- (*arg)[am::strings::params][am::strings::message_type].asInt());
- const bool is_success_correct =
- success == (*arg)[am::strings::msg_params][am::strings::success].asBool();
- const bool is_result_code_correct =
- result ==
- static_cast<int32_t>(
- (*arg)[am::strings::msg_params][am::strings::result_code].asInt());
-
- using namespace helpers;
- return Compare<bool, EQ, ALL>(
- true, is_msg_type_correct, is_success_correct, is_result_code_correct);
-}
-
-TEST_F(GenericResponseFromHMICommandsTest, Run_SUCCESS) {
- MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
-
- SharedPtr<commands::GenericResponse> command(
- CreateCommand<commands::GenericResponse>(command_msg));
-
- EXPECT_CALL(
- app_mngr_,
- SendMessageToMobile(
- CheckMessageParams(false, mobile_apis::Result::INVALID_DATA), false));
-
- command->Run();
-}
-
-class ScrollableMessageResponseTest
- : public CommandsTest<CommandsTestMocks::kIsNice> {};
-
-TEST_F(ScrollableMessageResponseTest, Run_SUCCESS) {
- MessageSharedPtr message = CreateMessage();
- (*message)[am::strings::msg_params][am::strings::result_code] =
- mobile_apis::Result::SUCCESS;
-
- MockAppPtr app(CreateMockApp());
-
- SharedPtr<am::commands::ScrollableMessageResponse> command(
- CreateCommand<am::commands::ScrollableMessageResponse>(message));
- EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(app));
- EXPECT_CALL(*app, UnsubscribeFromSoftButtons(_));
- command->Run();
-}
-
-} // namespace simple_response_commands_test
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/slider_test.cc b/src/components/application_manager/test/commands/mobile/slider_test.cc
deleted file mode 100644
index 54ac3cccc0..0000000000
--- a/src/components/application_manager/test/commands/mobile/slider_test.cc
+++ /dev/null
@@ -1,341 +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 <set>
-
-#include "application_manager/commands/mobile/slider_request.h"
-
-#include "gtest/gtest.h"
-#include "application_manager/commands/command_request_test.h"
-#include "application_manager/mock_application.h"
-#include "application_manager/mock_application_manager.h"
-#include "application_manager/mock_message_helper.h"
-#include "application_manager/event_engine/event.h"
-#include "application_manager/mock_hmi_interface.h"
-#include "application_manager/policies/mock_policy_handler_interface.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace slider_request {
-
-namespace am = application_manager;
-using am::commands::SliderRequest;
-using am::commands::CommandImpl;
-using am::commands::MessageSharedPtr;
-using am::MockMessageHelper;
-using policy_test::MockPolicyHandlerInterface;
-using ::utils::SharedPtr;
-using ::testing::_;
-using ::testing::Return;
-using ::testing::ReturnRef;
-
-typedef SharedPtr<SliderRequest> CommandPtr;
-
-namespace {
-const int32_t kCommandId = 1;
-const uint32_t kAppId = 1u;
-const uint32_t kCmdId = 1u;
-const uint32_t kConnectionKey = 2u;
-const uint32_t kDefaultTimeout = 1000u;
-const uint32_t kCorrelationId = 2u;
-const uint32_t kFunctionId = 3u;
-const uint32_t kNumTicks = 2u;
-const uint32_t kPositionGreaterTicks = 3u;
-const uint32_t kPositionLessTicks = 1u;
-} // namespace
-
-class SliderRequestTest
- : public CommandRequestTest<CommandsTestMocks::kIsNice> {
- public:
- SliderRequestTest()
- : mock_app_(CreateMockApp())
- , msg_(CreateMessage(smart_objects::SmartType_Map)) {}
-
- MessageSharedPtr CreateFullParamsUISO() {
- MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
- (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey;
- smart_objects::SmartObject menu_params =
- smart_objects::SmartObject(smart_objects::SmartType_Map);
- menu_params[am::strings::position] = 10;
- menu_params[am::strings::menu_name] = "LG";
-
- smart_objects::SmartObject msg_params =
- smart_objects::SmartObject(smart_objects::SmartType_Map);
- msg_params[am::strings::cmd_id] = kCmdId;
- msg_params[am::strings::menu_params] = menu_params;
- msg_params[am::strings::app_id] = kAppId;
- msg_params[am::strings::cmd_icon] = 1;
- msg_params[am::strings::cmd_icon][am::strings::value] = "10";
- (*msg)[am::strings::msg_params] = msg_params;
-
- return msg;
- }
-
- void PreConditions() {
- (*msg_)[am::strings::params][am::strings::connection_key] = kConnectionKey;
- (*msg_)[am::strings::msg_params][am::strings::num_ticks] = kNumTicks;
- (*msg_)[am::strings::msg_params][am::strings::position] =
- kPositionLessTicks;
- (*msg_)[am::strings::msg_params][am::strings::slider_footer][0] =
- "slider_footer1";
- (*msg_)[am::strings::msg_params][am::strings::slider_footer][1] =
- "slider_footer2";
- (*msg_)[am::strings::msg_params][am::strings::slider_header] =
- "slider_header";
-
- ON_CALL(app_mngr_, application(kConnectionKey))
- .WillByDefault(Return(mock_app_));
- ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey));
- }
-
- void ExpectManageMobileCommandWithResultCode(
- const mobile_apis::Result::eType code) {
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(MobileResultCodeIs(code),
- am::commands::Command::CommandOrigin::ORIGIN_SDL));
- }
-
- sync_primitives::Lock lock_;
-
- MockAppPtr mock_app_;
- MessageSharedPtr msg_;
- MockPolicyHandlerInterface mock_policy_handler_;
-};
-
-TEST_F(SliderRequestTest, OnEvent_UI_UNSUPPORTED_RESOURCE) {
- MessageSharedPtr msg_ui = CreateFullParamsUISO();
- (*msg_ui)[am::strings::params][am::strings::connection_key] = kConnectionKey;
-
- utils::SharedPtr<SliderRequest> command =
- CreateCommand<SliderRequest>(msg_ui);
-
- MockAppPtr mock_app = CreateMockApp();
- ON_CALL(app_mngr_, application(kConnectionKey))
- .WillByDefault(Return(mock_app));
-
- ON_CALL(*mock_app, app_id()).WillByDefault(Return(kConnectionKey));
-
- MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
- (*msg)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
- (*msg)[am::strings::msg_params][am::strings::info] = "info";
-
- Event event(hmi_apis::FunctionID::UI_Slider);
- event.set_smart_object(*msg);
-
- MessageSharedPtr ui_command_result;
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
- .WillOnce(DoAll(SaveArg<0>(&ui_command_result), Return(true)));
-
- command->on_event(event);
-
- EXPECT_EQ((*ui_command_result)[am::strings::msg_params][am::strings::success]
- .asBool(),
- true);
- EXPECT_EQ(
- (*ui_command_result)[am::strings::msg_params][am::strings::result_code]
- .asInt(),
- static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE));
- if ((*ui_command_result)[am::strings::msg_params].keyExists(
- am::strings::info)) {
- EXPECT_FALSE(
- (*ui_command_result)[am::strings::msg_params][am::strings::info]
- .asString()
- .empty());
- }
-}
-
-class CallOnTimeOut {
- public:
- CallOnTimeOut(CommandRequestImpl& command) : command_(command) {}
-
- void operator()() {
- command_.onTimeOut();
- }
-
- CommandRequestImpl& command_;
-};
-
-TEST_F(SliderRequestTest, Init_SUCCESS) {
- PreConditions();
- (*msg_)[am::strings::msg_params][am::strings::timeout] = kDefaultTimeout;
-
- CommandPtr command(CreateCommand<SliderRequest>(msg_));
- EXPECT_TRUE(command->Init());
-}
-
-TEST_F(SliderRequestTest, Run_ApplicationIsNotRegistered_UNSUCCESS) {
- PreConditions();
- ON_CALL(app_mngr_, application(kConnectionKey))
- .WillByDefault(Return(ApplicationSharedPtr()));
- ExpectManageMobileCommandWithResultCode(
- mobile_apis::Result::APPLICATION_NOT_REGISTERED);
-
- CommandPtr command(CreateCommand<SliderRequest>(msg_));
- command->Run();
-}
-
-TEST_F(SliderRequestTest, Run_PositionGreaterTicks_UNSUCCESS) {
- PreConditions();
- (*msg_)[am::strings::msg_params][am::strings::position] =
- kPositionGreaterTicks;
-
- CommandPtr command(CreateCommand<SliderRequest>(msg_));
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
-
- ExpectManageMobileCommandWithResultCode(mobile_apis::Result::INVALID_DATA);
- command->Run();
-}
-
-TEST_F(SliderRequestTest, Run_SliderFooterNotEqToNumticks_UNSUCCESS) {
- PreConditions();
- (*msg_)[am::strings::msg_params][am::strings::slider_footer][2] =
- "slider_footer3";
- CommandPtr command(CreateCommand<SliderRequest>(msg_));
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
-
- ExpectManageMobileCommandWithResultCode(mobile_apis::Result::INVALID_DATA);
- command->Run();
-}
-
-TEST_F(SliderRequestTest, Run_InvalidSliderHeader_UNSUCCESS) {
- PreConditions();
- (*msg_)[am::strings::msg_params][am::strings::slider_header] =
- "invalid_test_with_empty_str\\n";
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
- ExpectManageMobileCommandWithResultCode(mobile_apis::Result::INVALID_DATA);
-
- CommandPtr command(CreateCommand<SliderRequest>(msg_));
- command->Run();
-}
-
-TEST_F(SliderRequestTest, Run_InvalidSliderFooter_UNSUCCESS) {
- PreConditions();
- (*msg_)[am::strings::msg_params][am::strings::slider_footer][0] =
- "invalid_test_with_empty_str\\n";
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
- ExpectManageMobileCommandWithResultCode(mobile_apis::Result::INVALID_DATA);
-
- CommandPtr command(CreateCommand<SliderRequest>(msg_));
- command->Run();
-}
-
-TEST_F(SliderRequestTest, Run_SUCCESS) {
- PreConditions();
- EXPECT_CALL(
- app_mngr_,
- ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_Slider)));
-
- CommandPtr command(CreateCommand<SliderRequest>(msg_));
- command->Run();
-}
-
-TEST_F(SliderRequestTest, OnEvent_UI_OnResetTimeout_UNSUCCESS) {
- PreConditions();
- (*msg_)[am::strings::msg_params][am::strings::timeout] = kDefaultTimeout;
- (*msg_)[am::strings::params][am::strings::correlation_id] = kCorrelationId;
-
- CommandPtr command(CreateCommand<SliderRequest>(msg_));
- EXPECT_TRUE(command->Init());
-
- EXPECT_CALL(
- app_mngr_,
- updateRequestTimeout(kConnectionKey, kCorrelationId, kDefaultTimeout));
-
- Event event(hmi_apis::FunctionID::UI_OnResetTimeout);
- event.set_smart_object(*msg_);
- command->on_event(event);
-}
-
-TEST_F(SliderRequestTest, OnEvent_UI_UnknownEventId_UNSUCCESS) {
- PreConditions();
- EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0);
-
- Event event(hmi_apis::FunctionID::INVALID_ENUM);
- event.set_smart_object(*msg_);
-
- CommandPtr command(CreateCommand<SliderRequest>(msg_));
- command->on_event(event);
-}
-
-TEST_F(SliderRequestTest, OnEvent_UISliderPositionExists_SUCCESS) {
- PreConditions();
- (*msg_)[am::strings::msg_params][am::strings::timeout] = kDefaultTimeout;
- (*msg_)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::TIMED_OUT;
- (*msg_)[am::strings::params][am::strings::data]
- [am::strings::slider_position] = "position";
-
- ExpectManageMobileCommandWithResultCode(mobile_apis::Result::TIMED_OUT);
-
- Event event(hmi_apis::FunctionID::UI_Slider);
- event.set_smart_object(*msg_);
-
- CommandPtr command(CreateCommand<SliderRequest>(msg_));
- command->on_event(event);
-}
-
-TEST_F(SliderRequestTest, OnEvent_UISliderAborted_SUCCESS) {
- PreConditions();
- (*msg_)[am::strings::msg_params][am::strings::timeout] = kDefaultTimeout;
- (*msg_)[am::strings::params][am::hmi_response::code] =
- hmi_apis::Common_Result::ABORTED;
-
- ExpectManageMobileCommandWithResultCode(mobile_apis::Result::ABORTED);
-
- Event event(hmi_apis::FunctionID::UI_Slider);
- event.set_smart_object(*msg_);
-
- CommandPtr command(CreateCommand<SliderRequest>(msg_));
- command->on_event(event);
-}
-
-} // namespace slider_request
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace tests
diff --git a/src/components/application_manager/test/commands/mobile/speak_request_test.cc b/src/components/application_manager/test/commands/mobile/speak_request_test.cc
deleted file mode 100644
index f07012d315..0000000000
--- a/src/components/application_manager/test/commands/mobile/speak_request_test.cc
+++ /dev/null
@@ -1,398 +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 "mobile/speak_request.h"
-#include "utils/shared_ptr.h"
-#include "commands/commands_test.h"
-#include "commands/command_request_test.h"
-#include "interfaces/HMI_API.h"
-#include "interfaces/MOBILE_API.h"
-#include "utils/shared_ptr.h"
-#include "utils/helpers.h"
-#include "utils/make_shared.h"
-#include "smart_objects/smart_object.h"
-#include "utils/custom_string.h"
-#include "application_manager/application.h"
-#include "application_manager/smart_object_keys.h"
-#include "application_manager/mock_application.h"
-#include "application_manager/mock_application_manager.h"
-#include "application_manager/mock_message_helper.h"
-#include "application_manager/event_engine/event.h"
-#include "application_manager/mock_hmi_interface.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace speak_request {
-
-namespace am = application_manager;
-namespace mobile_result = mobile_apis::Result;
-namespace hmi_response = ::application_manager::hmi_response;
-namespace strings = ::application_manager::strings;
-using am::commands::CommandImpl;
-using am::ApplicationManager;
-using am::commands::MessageSharedPtr;
-using am::ApplicationSharedPtr;
-using am::MockMessageHelper;
-using ::testing::_;
-using ::utils::SharedPtr;
-using ::testing::Return;
-using ::testing::ReturnRef;
-using am::commands::SpeakRequest;
-using ::test::components::application_manager_test::MockApplication;
-
-typedef SharedPtr<SpeakRequest> CommandPtr;
-
-namespace {
-const uint32_t kAppId = 10u;
-const uint32_t kConnectionKey = 5u;
-}
-
-class SpeakRequestTest : public CommandRequestTest<CommandsTestMocks::kIsNice> {
- public:
- SpeakRequestTest()
- : request_(CreateMessage(smart_objects::SmartType_Map))
- , response_(CreateMessage(smart_objects::SmartType_Map))
- , app_(CreateMockApp()) {}
-
- void CheckExpectations(const hmi_apis::Common_Result::eType hmi_response,
- const mobile_apis::Result::eType mobile_response,
- const am::HmiInterfaces::InterfaceState state,
- const bool success) {
- utils::SharedPtr<SpeakRequest> command =
- CreateCommand<SpeakRequest>(request_);
-
- (*response_)[strings::params][hmi_response::code] = hmi_response;
- (*response_)[strings::msg_params] = 0;
-
- am::event_engine::Event event_tts(hmi_apis::FunctionID::TTS_Speak);
- event_tts.set_smart_object(*response_);
-
- MockAppPtr mock_app(CreateMockApp());
- ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app));
-
- MessageSharedPtr response_to_mobile;
- EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
- .WillRepeatedly(Return(state));
-
- EXPECT_CALL(app_mngr_,
- ManageMobileCommand(
- _, am::commands::Command::CommandOrigin::ORIGIN_SDL))
- .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true)));
-
- command->on_event(event_tts);
-
- EXPECT_EQ(
- (*response_to_mobile)[strings::msg_params][strings::success].asBool(),
- success);
- EXPECT_EQ((*response_to_mobile)[strings::msg_params][strings::result_code]
- .asInt(),
- static_cast<int32_t>(mobile_response));
- }
-
- MessageSharedPtr request_;
- MessageSharedPtr response_;
- MockAppPtr app_;
-};
-
-TEST_F(SpeakRequestTest, OnEvent_SUCCESS_Expect_true) {
- utils::SharedPtr<SpeakRequest> command =
- CreateCommand<SpeakRequest>(request_);
-
- (*response_)[strings::params][hmi_response::code] =
- hmi_apis::Common_Result::SUCCESS;
- (*response_)[strings::msg_params] = 0;
-
- am::event_engine::Event event_tts(hmi_apis::FunctionID::TTS_Speak);
- event_tts.set_smart_object(*response_);
-
- MockAppPtr mock_app(CreateMockApp());
- ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app));
-
- MessageSharedPtr response_to_mobile;
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
- .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true)));
-
- command->on_event(event_tts);
-
- EXPECT_EQ(
- (*response_to_mobile)[strings::msg_params][strings::success].asBool(),
- true);
- EXPECT_EQ(
- (*response_to_mobile)[strings::msg_params][strings::result_code].asInt(),
- static_cast<int32_t>(mobile_apis::Result::SUCCESS));
-}
-
-TEST_F(SpeakRequestTest,
- OnEvent_UNSUPPORTED_RESOURCE_STATE_AVAILABLE_Expect_true) {
- CheckExpectations(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE,
- mobile_apis::Result::UNSUPPORTED_RESOURCE,
- am::HmiInterfaces::STATE_AVAILABLE,
- true);
-}
-
-TEST_F(SpeakRequestTest,
- OnEvent_UNSUPPORTED_RESOURCE_STATE_NOT_AVAILABLE_Expect_false) {
- CheckExpectations(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE,
- mobile_apis::Result::UNSUPPORTED_RESOURCE,
- am::HmiInterfaces::STATE_NOT_AVAILABLE,
- false);
-}
-
-TEST_F(SpeakRequestTest,
- OnEvent_UNSUPPORTED_RESOURCE_STATE_NOT_RESPONSE_Expect_true) {
- CheckExpectations(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE,
- mobile_apis::Result::UNSUPPORTED_RESOURCE,
- am::HmiInterfaces::STATE_NOT_RESPONSE,
- true);
-}
-
-TEST_F(SpeakRequestTest, Run_ApplicationIsNotRegistered) {
- CommandPtr command(CreateCommand<SpeakRequest>(request_));
-
- ON_CALL(app_mngr_, application(_))
- .WillByDefault(Return(ApplicationSharedPtr()));
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(
- MobileResultCodeIs(mobile_result::APPLICATION_NOT_REGISTERED), _));
-
- command->Run();
-}
-
-TEST_F(SpeakRequestTest, Run_MsgWithWhiteSpace_InvalidData) {
- (*request_)[am::strings::msg_params][am::strings::tts_chunks][0]
- [am::strings::text] = " ";
- CommandPtr command(CreateCommand<SpeakRequest>(request_));
-
- ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app_));
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(MobileResultCodeIs(mobile_result::INVALID_DATA), _));
-
- command->Run();
-}
-
-TEST_F(SpeakRequestTest, Run_MsgWithIncorrectChar1_InvalidData) {
- (*request_)[am::strings::msg_params][am::strings::tts_chunks][0]
- [am::strings::text] = "sd\\t";
- CommandPtr command(CreateCommand<SpeakRequest>(request_));
-
- ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app_));
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(MobileResultCodeIs(mobile_result::INVALID_DATA), _));
-
- command->Run();
-}
-
-TEST_F(SpeakRequestTest, Run_MsgWithIncorrectChar2_InvalidData) {
- (*request_)[am::strings::msg_params][am::strings::tts_chunks][0]
- [am::strings::text] = "sd\\n";
- CommandPtr command(CreateCommand<SpeakRequest>(request_));
-
- ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app_));
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(MobileResultCodeIs(mobile_result::INVALID_DATA), _));
-
- command->Run();
-}
-
-TEST_F(SpeakRequestTest, Run_MsgWithIncorrectChar3_InvalidData) {
- (*request_)[am::strings::msg_params][am::strings::tts_chunks][0]
- [am::strings::text] = "sd\tdf";
- CommandPtr command(CreateCommand<SpeakRequest>(request_));
-
- ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app_));
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(MobileResultCodeIs(mobile_result::INVALID_DATA), _));
-
- command->Run();
-}
-
-TEST_F(SpeakRequestTest, Run_MsgWithIncorrectChar4_InvalidData) {
- (*request_)[am::strings::msg_params][am::strings::tts_chunks][0]
- [am::strings::text] = "sd\n rer";
- CommandPtr command(CreateCommand<SpeakRequest>(request_));
-
- ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app_));
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(MobileResultCodeIs(mobile_result::INVALID_DATA), _));
-
- command->Run();
-}
-
-TEST_F(SpeakRequestTest, Run_MsgWithIncorrectCharInfirstPlace_InvalidData) {
- (*request_)[am::strings::msg_params][am::strings::tts_chunks][0]
- [am::strings::text] = "\n";
- CommandPtr command(CreateCommand<SpeakRequest>(request_));
-
- ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app_));
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(MobileResultCodeIs(mobile_result::INVALID_DATA), _));
-
- command->Run();
-}
-
-TEST_F(SpeakRequestTest, Run_MsgWithEmptyString_Success) {
- (*request_)[am::strings::msg_params][am::strings::tts_chunks][0]
- [am::strings::text] = "";
- CommandPtr command(CreateCommand<SpeakRequest>(request_));
-
- ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app_));
- ON_CALL(*app_, app_id()).WillByDefault(Return(kAppId));
-
- EXPECT_CALL(
- app_mngr_,
- ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak)));
-
- command->Run();
-}
-
-TEST_F(SpeakRequestTest, Run_MsgCorrect_Success) {
- (*request_)[am::strings::msg_params][am::strings::tts_chunks][0]
- [am::strings::text] = "asda";
- CommandPtr command(CreateCommand<SpeakRequest>(request_));
-
- ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app_));
- ON_CALL(*app_, app_id()).WillByDefault(Return(kAppId));
-
- EXPECT_CALL(
- app_mngr_,
- ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak)));
-
- command->Run();
-}
-
-TEST_F(SpeakRequestTest, OnEvent_WrongEventId_UNSUCCESS) {
- Event event(Event::EventID::INVALID_ENUM);
- CommandPtr command(CreateCommand<SpeakRequest>());
-
- EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0);
- command->on_event(event);
-}
-
-TEST_F(SpeakRequestTest, OnEvent_TTS_Speak_SUCCESS) {
- Event event(Event::EventID::TTS_Speak);
- MessageSharedPtr event_msg(CreateMessage(smart_objects::SmartType_Map));
- hmi_apis::Common_Result::eType hmi_result = hmi_apis::Common_Result::SUCCESS;
- (*event_msg)[am::strings::msg_params][am::strings::tts_chunks][0]
- [am::strings::text] = "1234";
- (*event_msg)[am::strings::params][am::hmi_response::code] = hmi_result;
- (*event_msg)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
-
- event.set_smart_object(*event_msg);
- CommandPtr command(CreateCommand<SpeakRequest>(request_));
-
- ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app_));
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(MobileResultCodeIs(mobile_result::SUCCESS), _));
- command->on_event(event);
-}
-
-TEST_F(SpeakRequestTest, OnEvent_TTS_SpeakWithWarning_WarningWithSuccess) {
- Event event(Event::EventID::TTS_Speak);
- MessageSharedPtr event_msg(CreateMessage(smart_objects::SmartType_Map));
- hmi_apis::Common_Result::eType hmi_result = hmi_apis::Common_Result::WARNINGS;
- (*event_msg)[am::strings::params][am::hmi_response::code] = hmi_result;
- (*event_msg)[am::strings::msg_params][am::strings::tts_chunks][0]
- [am::strings::text] = "asda";
- event.set_smart_object(*event_msg);
- CommandPtr command(CreateCommand<SpeakRequest>());
-
- ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app_));
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(MobileResultCodeIs(mobile_result::WARNINGS), _));
- command->on_event(event);
-}
-
-TEST_F(SpeakRequestTest, OnEvent_TTS_OnResetTimeout_UpdateTimeout) {
- Event event(Event::EventID::TTS_OnResetTimeout);
- (*request_)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
- (*request_)[am::strings::params][am::strings::correlation_id] = kAppId;
- CommandPtr command(CreateCommand<SpeakRequest>(request_));
-
- EXPECT_CALL(app_mngr_, updateRequestTimeout(kConnectionKey, kAppId, _));
-
- command->on_event(event);
-}
-
-TEST_F(SpeakRequestTest, OnEvent_ApplicationIsNotRegistered_UNSUCCESS) {
- const hmi_apis::Common_Result::eType hmi_result =
- hmi_apis::Common_Result::SUCCESS;
-
- Event event(Event::EventID::TTS_Speak);
- MessageSharedPtr event_msg(CreateMessage(smart_objects::SmartType_Map));
- (*event_msg)[am::strings::msg_params][am::strings::tts_chunks][0]
- [am::strings::text] = "text";
- (*event_msg)[am::strings::params][am::hmi_response::code] = hmi_result;
- (*event_msg)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
-
- event.set_smart_object(*event_msg);
- CommandPtr command(CreateCommand<SpeakRequest>(request_));
-
- EXPECT_CALL(app_mngr_, application(_))
- .WillOnce(Return(ApplicationSharedPtr()));
-
- command->on_event(event);
-}
-
-} // namespace speak_request
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace component
-} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/subscribe_button_request_test.cc b/src/components/application_manager/test/commands/mobile/subscribe_button_request_test.cc
deleted file mode 100644
index 8d31b67a53..0000000000
--- a/src/components/application_manager/test/commands/mobile/subscribe_button_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 <stdint.h>
-#include <string>
-
-#include "gtest/gtest.h"
-#include "utils/shared_ptr.h"
-#include "smart_objects/smart_object.h"
-#include "application_manager/commands/commands_test.h"
-#include "application_manager/commands/command_request_test.h"
-#include "application_manager/application.h"
-#include "application_manager/mock_application_manager.h"
-#include "application_manager/mock_application.h"
-#include "application_manager/mock_hmi_capabilities.h"
-#include "application_manager/include/application_manager/commands/mobile/subscribe_button_request.h"
-#include "interfaces/MOBILE_API.h"
-#include "application_manager/smart_object_keys.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace subscribe_button_request {
-
-using ::testing::_;
-using ::testing::Return;
-using ::testing::ReturnRef;
-using ::testing::DoAll;
-using ::testing::SaveArg;
-namespace am = ::application_manager;
-using am::commands::SubscribeButtonRequest;
-using am::commands::MessageSharedPtr;
-
-typedef SharedPtr<SubscribeButtonRequest> CommandPtr;
-
-class SubscribeButtonRequestTest
- : public CommandRequestTest<CommandsTestMocks::kIsNice> {
- public:
- typedef TypeIf<kMocksAreNice,
- NiceMock<application_manager_test::MockHMICapabilities>,
- application_manager_test::MockHMICapabilities>::Result
- MockHMICapabilities;
-};
-
-typedef SubscribeButtonRequestTest::MockHMICapabilities MockHMICapabilities;
-
-TEST_F(SubscribeButtonRequestTest, Run_AppNotRegistered_UNSUCCESS) {
- CommandPtr command(CreateCommand<SubscribeButtonRequest>());
-
- ON_CALL(app_mngr_, application(_))
- .WillByDefault(Return(SharedPtr<am::Application>()));
-
- MessageSharedPtr result_msg(CatchMobileCommandResult(CallRun(*command)));
- EXPECT_EQ(mobile_apis::Result::APPLICATION_NOT_REGISTERED,
- static_cast<mobile_apis::Result::eType>(
- (*result_msg)[am::strings::msg_params][am::strings::result_code]
- .asInt()));
-}
-
-TEST_F(SubscribeButtonRequestTest, Run_SubscriptionNotAllowed_UNSUCCESS) {
- MessageSharedPtr msg(CreateMessage());
- (*msg)[am::strings::msg_params][am::strings::button_name] =
- mobile_apis::ButtonName::SEEKLEFT;
- CommandPtr command(CreateCommand<SubscribeButtonRequest>(msg));
-
- MockAppPtr app(CreateMockApp());
- ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app));
- ON_CALL(*app, is_media_application()).WillByDefault(Return(false));
-
- MessageSharedPtr result_msg(CatchMobileCommandResult(CallRun(*command)));
- EXPECT_EQ(mobile_apis::Result::REJECTED,
- static_cast<mobile_apis::Result::eType>(
- (*result_msg)[am::strings::msg_params][am::strings::result_code]
- .asInt()));
-}
-
-TEST_F(SubscribeButtonRequestTest, Run_UiIsNotSupported_UNSUCCESS) {
- CommandPtr command(CreateCommand<SubscribeButtonRequest>());
-
- MockAppPtr app(CreateMockApp());
- ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app));
-
- MockHMICapabilities hmi_capabilities;
- ON_CALL(app_mngr_, hmi_capabilities())
- .WillByDefault(ReturnRef(hmi_capabilities));
- ON_CALL(hmi_capabilities, is_ui_cooperating()).WillByDefault(Return(false));
-
- MessageSharedPtr result_msg(CatchMobileCommandResult(CallRun(*command)));
- EXPECT_EQ(mobile_apis::Result::UNSUPPORTED_RESOURCE,
- static_cast<mobile_apis::Result::eType>(
- (*result_msg)[am::strings::msg_params][am::strings::result_code]
- .asInt()));
-}
-
-TEST_F(SubscribeButtonRequestTest, Run_IsSubscribedToButton_UNSUCCESS) {
- const mobile_apis::ButtonName::eType kButtonName =
- mobile_apis::ButtonName::SEEKLEFT;
-
- MessageSharedPtr msg(CreateMessage());
- (*msg)[am::strings::msg_params][am::strings::button_name] = kButtonName;
- CommandPtr command(CreateCommand<SubscribeButtonRequest>(msg));
-
- MockAppPtr app(CreateMockApp());
- ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app));
- ON_CALL(*app, is_media_application()).WillByDefault(Return(true));
-
- MockHMICapabilities hmi_capabilities;
- ON_CALL(app_mngr_, hmi_capabilities())
- .WillByDefault(ReturnRef(hmi_capabilities));
- ON_CALL(hmi_capabilities, is_ui_cooperating()).WillByDefault(Return(true));
-
- MessageSharedPtr button_caps_ptr(CreateMessage(smart_objects::SmartType_Map));
- (*button_caps_ptr)[0][am::hmi_response::button_name] = kButtonName;
-
- ON_CALL(hmi_capabilities, button_capabilities())
- .WillByDefault(Return(button_caps_ptr.get()));
-
- ON_CALL(*app, IsSubscribedToButton(_)).WillByDefault(Return(true));
-
- MessageSharedPtr result_msg(CatchMobileCommandResult(CallRun(*command)));
- EXPECT_EQ(mobile_apis::Result::IGNORED,
- static_cast<mobile_apis::Result::eType>(
- (*result_msg)[am::strings::msg_params][am::strings::result_code]
- .asInt()));
-}
-
-TEST_F(SubscribeButtonRequestTest, Run_SUCCESS) {
- const mobile_apis::ButtonName::eType kButtonName =
- mobile_apis::ButtonName::SEEKLEFT;
-
- MessageSharedPtr msg(CreateMessage());
- (*msg)[am::strings::msg_params][am::strings::button_name] = kButtonName;
- CommandPtr command(CreateCommand<SubscribeButtonRequest>(msg));
-
- MockAppPtr app(CreateMockApp());
- ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app));
- ON_CALL(*app, is_media_application()).WillByDefault(Return(true));
-
- MockHMICapabilities hmi_capabilities;
- ON_CALL(app_mngr_, hmi_capabilities())
- .WillByDefault(ReturnRef(hmi_capabilities));
- ON_CALL(hmi_capabilities, is_ui_cooperating()).WillByDefault(Return(true));
-
- MessageSharedPtr button_caps_ptr(CreateMessage(smart_objects::SmartType_Map));
- (*button_caps_ptr)[0][am::hmi_response::button_name] = kButtonName;
-
- ON_CALL(hmi_capabilities, button_capabilities())
- .WillByDefault(Return(button_caps_ptr.get()));
-
- ON_CALL(*app, IsSubscribedToButton(_)).WillByDefault(Return(false));
-
- MessageSharedPtr hmi_result_msg;
- EXPECT_CALL(app_mngr_, ManageHMICommand(_))
- .WillOnce(DoAll(SaveArg<0>(&hmi_result_msg), Return(true)));
-
- MessageSharedPtr mobile_result_msg(
- CatchMobileCommandResult(CallRun(*command)));
-
- EXPECT_EQ(hmi_apis::FunctionID::Buttons_OnButtonSubscription,
- static_cast<hmi_apis::FunctionID::eType>(
- (*hmi_result_msg)[am::strings::params][am::strings::function_id]
- .asInt()));
-
- EXPECT_EQ(mobile_apis::Result::SUCCESS,
- static_cast<mobile_apis::Result::eType>(
- (*mobile_result_msg)[am::strings::msg_params]
- [am::strings::result_code].asInt()));
-}
-
-} // namespace subscribe_button_request
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/subscribe_way_points_request_test.cc b/src/components/application_manager/test/commands/mobile/subscribe_way_points_request_test.cc
deleted file mode 100644
index 87127231be..0000000000
--- a/src/components/application_manager/test/commands/mobile/subscribe_way_points_request_test.cc
+++ /dev/null
@@ -1,129 +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/test/include/application_manager/commands/commands_test.h"
-#include "application_manager/test/include/application_manager/commands/command_request_test.h"
-#include "application_manager/application.h"
-#include "application_manager/mock_application_manager.h"
-#include "application_manager/mock_application.h"
-#include "application_manager/mock_hmi_capabilities.h"
-#include "application_manager/mock_message_helper.h"
-#include "application_manager/include/application_manager/commands/mobile/subscribe_way_points_request.h"
-#include "interfaces/MOBILE_API.h"
-#include "application_manager/smart_object_keys.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace subscribe_way_points_request {
-
-using ::testing::_;
-using ::testing::A;
-using ::testing::Return;
-using ::testing::ReturnRef;
-using ::testing::DoAll;
-using ::testing::SaveArg;
-using ::testing::InSequence;
-namespace am = ::application_manager;
-using am::commands::SubscribeWayPointsRequest;
-using am::commands::MessageSharedPtr;
-
-typedef SharedPtr<SubscribeWayPointsRequest> CommandPtr;
-
-class SubscribeWayPointsRequestTest
- : public CommandRequestTest<CommandsTestMocks::kIsNice> {};
-
-TEST_F(SubscribeWayPointsRequestTest, Run_SUCCESS) {
- CommandPtr command(CreateCommand<SubscribeWayPointsRequest>());
- MockAppPtr app(CreateMockApp());
-
- ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app));
- ON_CALL(app_mngr_, IsAppSubscribedForWayPoints(A<am::ApplicationSharedPtr>()))
- .WillByDefault(Return(false));
- ON_CALL(app_mngr_, IsAnyAppSubscribedForWayPoints())
- .WillByDefault(Return(true));
-
- {
- InSequence dummy;
- EXPECT_CALL(app_mngr_,
- SubscribeAppForWayPoints(A<am::ApplicationSharedPtr>()));
- EXPECT_CALL(*app, UpdateHash());
- }
-
- command->Init();
- MessageSharedPtr mobile_result_msg(
- CatchMobileCommandResult(CallRun(*command)));
-
- EXPECT_EQ(mobile_apis::Result::SUCCESS,
- static_cast<mobile_apis::Result::eType>(
- (*mobile_result_msg)[am::strings::msg_params]
- [am::strings::result_code].asInt()));
-}
-
-TEST_F(SubscribeWayPointsRequestTest, OnEvent_SUCCESS) {
- CommandPtr command(CreateCommand<SubscribeWayPointsRequest>());
- MockAppPtr app(CreateMockApp());
- Event event(hmi_apis::FunctionID::Navigation_SubscribeWayPoints);
-
- MessageSharedPtr event_msg(CreateMessage(smart_objects::SmartType_Map));
- const hmi_apis::Common_Result::eType result_code =
- hmi_apis::Common_Result::SUCCESS;
- (*event_msg)[am::strings::params][am::hmi_response::code] = result_code;
- (*event_msg)[am::strings::msg_params] = 0;
-
- event.set_smart_object(*event_msg);
-
- ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app));
-
- {
- InSequence dummy;
- EXPECT_CALL(app_mngr_,
- SubscribeAppForWayPoints(A<am::ApplicationSharedPtr>()));
- EXPECT_CALL(mock_message_helper_, HMIToMobileResult(result_code))
- .WillOnce(Return(mobile_apis::Result::SUCCESS));
- EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _));
- EXPECT_CALL(*app, UpdateHash());
- }
-
- command->Init();
- command->on_event(event);
-}
-
-} // namespace subscribe_way_points_request
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/system_request_test.cc b/src/components/application_manager/test/commands/mobile/system_request_test.cc
deleted file mode 100644
index 0e07889b4b..0000000000
--- a/src/components/application_manager/test/commands/mobile/system_request_test.cc
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright (c) 2017, 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 <set>
-
-#include "gtest/gtest.h"
-
-#include "application_manager/commands/mobile/system_request.h"
-#include "application_manager/commands/command_request_test.h"
-#include "application_manager/mock_application.h"
-#include "application_manager/mock_application_manager.h"
-#include "application_manager/event_engine/event.h"
-#include "application_manager/mock_hmi_interface.h"
-#include "application_manager/policies/mock_policy_handler_interface.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace system_request {
-
-namespace am = application_manager;
-using am::commands::SystemRequest;
-using am::commands::CommandImpl;
-using am::commands::MessageSharedPtr;
-using am::MockHmiInterfaces;
-using am::event_engine::Event;
-using policy_test::MockPolicyHandlerInterface;
-using ::utils::SharedPtr;
-using ::testing::_;
-using ::testing::Return;
-using ::testing::ReturnRef;
-
-namespace {
-const uint32_t kConnectionKey = 2u;
-const std::string kAppPolicyId = "fake-app-id";
-const uint32_t kDefaultTimeout = 1000u;
-const std::string kAppFolderName = "fake-app-name";
-const std::string kAppStorageFolder = "fake-storage";
-const std::string kSystemFilesPath = "/fake/system/files";
-const std::string kFileName = "Filename";
-} // namespace
-
-class SystemRequestTest
- : public CommandRequestTest<CommandsTestMocks::kIsNice> {
- public:
- SystemRequestTest() : mock_app_(CreateMockApp()) {}
-
- protected:
- MessageSharedPtr CreateIVSUMessage() {
- MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
- (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey;
- (*msg)[am::strings::msg_params][am::strings::request_type] =
- mobile_apis::RequestType::HTTP;
- (*msg)[am::strings::msg_params][am::strings::file_name] = kFileName;
- return msg;
- }
-
- void PreConditions() {
- ON_CALL(app_mngr_, application(kConnectionKey))
- .WillByDefault(Return(mock_app_));
- ON_CALL(app_mngr_, GetPolicyHandler())
- .WillByDefault(ReturnRef(mock_policy_handler_));
-
- ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey));
- ON_CALL(*mock_app_, policy_app_id()).WillByDefault(Return(kAppPolicyId));
- ON_CALL(*mock_app_, folder_name()).WillByDefault(Return(kAppFolderName));
-
- ON_CALL(app_mngr_settings_, system_files_path())
- .WillByDefault(ReturnRef(kSystemFilesPath));
- ON_CALL(app_mngr_settings_, app_storage_folder())
- .WillByDefault(ReturnRef(kAppStorageFolder));
-
- ON_CALL(mock_policy_handler_, IsRequestTypeAllowed(kAppPolicyId, _))
- .WillByDefault(Return(true));
- }
-
- void ExpectManageMobileCommandWithResultCode(
- const mobile_apis::Result::eType code) {
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(MobileResultCodeIs(code),
- am::commands::Command::CommandOrigin::ORIGIN_SDL));
- }
-
- MockAppPtr mock_app_;
- MockPolicyHandlerInterface mock_policy_handler_;
-};
-
-TEST_F(SystemRequestTest, Run_HTTP_FileName_no_binary_data_REJECTED) {
- PreConditions();
- MessageSharedPtr msg = CreateIVSUMessage();
-
- ExpectManageMobileCommandWithResultCode(mobile_apis::Result::REJECTED);
-
- SharedPtr<SystemRequest> command(CreateCommand<SystemRequest>(msg));
- command->Run();
-}
-
-} // namespace system_request
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/unregister_app_interface_request_test.cc b/src/components/application_manager/test/commands/mobile/unregister_app_interface_request_test.cc
deleted file mode 100644
index 3d083f5c45..0000000000
--- a/src/components/application_manager/test/commands/mobile/unregister_app_interface_request_test.cc
+++ /dev/null
@@ -1,118 +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/commands/command_request_test.h"
-#include "application_manager/mock_application_manager.h"
-#include "application_manager/mock_message_helper.h"
-#include "application_manager/commands/mobile/unregister_app_interface_request.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace unregister_app_interface_request {
-
-namespace am = ::application_manager;
-namespace mobile_result = mobile_apis::Result;
-
-using ::testing::_;
-
-using am::commands::UnregisterAppInterfaceRequest;
-using am::commands::MessageSharedPtr;
-
-typedef ::utils::SharedPtr<UnregisterAppInterfaceRequest> CommandPtr;
-
-class UnregisterAppInterfaceRequestTest
- : public CommandRequestTest<CommandsTestMocks::kIsNice> {};
-
-TEST_F(UnregisterAppInterfaceRequestTest, Run_AppNotRegistered_UNSUCCESS) {
- CommandPtr command(CreateCommand<UnregisterAppInterfaceRequest>());
-
- EXPECT_CALL(app_mngr_, application(_))
- .WillOnce(Return(ApplicationSharedPtr()));
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(
- MobileResultCodeIs(mobile_result::APPLICATION_NOT_REGISTERED), _));
-
- command->Run();
-}
-
-TEST_F(UnregisterAppInterfaceRequestTest, Run_SUCCESS) {
- const uint32_t kConnectionKey = 1u;
-
- MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
- (*command_msg)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
-
- CommandPtr command(CreateCommand<UnregisterAppInterfaceRequest>(command_msg));
-
- MockAppPtr mock_app(CreateMockApp());
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillRepeatedly(Return(mock_app));
-
- const mobile_apis::AppInterfaceUnregisteredReason::eType kUnregisterReason =
- mobile_apis::AppInterfaceUnregisteredReason::INVALID_ENUM;
-
- MessageSharedPtr dummy_msg(CreateMessage());
- EXPECT_CALL(mock_message_helper_,
- GetOnAppInterfaceUnregisteredNotificationToMobile(
- kConnectionKey, kUnregisterReason))
- .WillOnce(Return(dummy_msg));
- {
- ::testing::InSequence sequence;
-
- EXPECT_CALL(app_mngr_, ManageMobileCommand(dummy_msg, _));
-
- EXPECT_CALL(app_mngr_,
- UnregisterApplication(
- kConnectionKey, mobile_apis::Result::SUCCESS, _, _));
-
- EXPECT_CALL(app_mngr_,
- ManageMobileCommand(
- MobileResultCodeIs(mobile_apis::Result::SUCCESS), _));
- }
-
- command->Run();
-}
-
-} // namespace unregister_app_interface_request
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/unsubscribe_button_request_test.cc b/src/components/application_manager/test/commands/mobile/unsubscribe_button_request_test.cc
deleted file mode 100644
index 46a1ce02eb..0000000000
--- a/src/components/application_manager/test/commands/mobile/unsubscribe_button_request_test.cc
+++ /dev/null
@@ -1,156 +0,0 @@
-#include <stdint.h>
-#include <string>
-
-#include "gtest/gtest.h"
-#include "utils/shared_ptr.h"
-#include "application_manager/commands/command_request_test.h"
-#include "application_manager/mock_application_manager.h"
-#include "application_manager/mock_message_helper.h"
-#include "application_manager/mock_hmi_capabilities.h"
-#include "application_manager/commands/mobile/unsubscribe_button_request.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace unsubscribe_button_request {
-
-namespace am = ::application_manager;
-namespace mobile_result = mobile_apis::Result;
-
-using ::testing::_;
-
-using am::commands::UnsubscribeButtonRequest;
-using am::commands::MessageSharedPtr;
-
-typedef ::utils::SharedPtr<UnsubscribeButtonRequest> CommandPtr;
-
-namespace {
-const uint32_t kConnectionKey = 1u;
-const mobile_apis::ButtonName::eType kButtonId = mobile_apis::ButtonName::OK;
-} // namespace
-
-class UnsubscribeButtonRequestTest
- : public CommandRequestTest<CommandsTestMocks::kIsNice> {
- public:
- typedef TypeIf<kMocksAreNice,
- NiceMock<application_manager_test::MockHMICapabilities>,
- application_manager_test::MockHMICapabilities>::Result
- MockHMICapabilities;
-};
-
-TEST_F(UnsubscribeButtonRequestTest, Run_AppNotRegistered_UNSUCCESS) {
- CommandPtr command(CreateCommand<UnsubscribeButtonRequest>());
-
- EXPECT_CALL(app_mngr_, application(_))
- .WillOnce(Return(ApplicationSharedPtr()));
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(
- MobileResultCodeIs(mobile_result::APPLICATION_NOT_REGISTERED), _));
-
- command->Run();
-}
-
-TEST_F(UnsubscribeButtonRequestTest,
- Run_UnsubscribeNotSubscribedButton_UNSUCCESS) {
- MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
- (*command_msg)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
- (*command_msg)[am::strings::msg_params][am::strings::button_name] = kButtonId;
-
- CommandPtr command(CreateCommand<UnsubscribeButtonRequest>(command_msg));
-
- UnsubscribeButtonRequestTest::MockHMICapabilities hmi_capabilities;
- EXPECT_CALL(app_mngr_, hmi_capabilities())
- .WillOnce(ReturnRef(hmi_capabilities));
- EXPECT_CALL(hmi_capabilities, is_ui_cooperating()).WillOnce(Return(true));
-
- MessageSharedPtr button_caps_ptr(CreateMessage(smart_objects::SmartType_Map));
- (*button_caps_ptr)[0][am::hmi_response::button_name] = kButtonId;
- EXPECT_CALL(hmi_capabilities, button_capabilities())
- .WillOnce(Return(button_caps_ptr.get()));
-
- MockAppPtr mock_app(CreateMockApp());
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app));
- EXPECT_CALL(*mock_app, UnsubscribeFromButton(kButtonId))
- .WillOnce(Return(false));
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(MobileResultCodeIs(mobile_result::IGNORED), _));
-
- command->Run();
-}
-
-TEST_F(UnsubscribeButtonRequestTest,
- Run_UnsubscribeNotAllowedByHmiCapabilities_UNSUCCESS) {
- MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
- (*command_msg)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
- (*command_msg)[am::strings::msg_params][am::strings::button_name] = kButtonId;
- CommandPtr command(CreateCommand<UnsubscribeButtonRequest>(command_msg));
-
- MockAppPtr mock_app(CreateMockApp());
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app));
-
- UnsubscribeButtonRequestTest::MockHMICapabilities hmi_capabilities;
- EXPECT_CALL(app_mngr_, hmi_capabilities())
- .WillOnce(ReturnRef(hmi_capabilities));
- EXPECT_CALL(hmi_capabilities, is_ui_cooperating()).WillOnce(Return(true));
-
- MessageSharedPtr button_caps_ptr(CreateMessage(smart_objects::SmartType_Map));
- EXPECT_CALL(hmi_capabilities, button_capabilities())
- .WillOnce(Return(button_caps_ptr.get()));
-
- EXPECT_CALL(app_mngr_,
- ManageMobileCommand(
- MobileResultCodeIs(mobile_result::UNSUPPORTED_RESOURCE), _));
-
- command->Run();
-}
-
-TEST_F(UnsubscribeButtonRequestTest, Run_SUCCESS) {
- MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
- (*command_msg)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
- (*command_msg)[am::strings::msg_params][am::strings::button_name] = kButtonId;
-
- CommandPtr command(CreateCommand<UnsubscribeButtonRequest>(command_msg));
-
- UnsubscribeButtonRequestTest::MockHMICapabilities hmi_capabilities;
- EXPECT_CALL(app_mngr_, hmi_capabilities())
- .WillOnce(ReturnRef(hmi_capabilities));
- EXPECT_CALL(hmi_capabilities, is_ui_cooperating()).WillOnce(Return(true));
-
- MessageSharedPtr button_caps_ptr(CreateMessage(smart_objects::SmartType_Map));
- (*button_caps_ptr)[0][am::hmi_response::button_name] = kButtonId;
- EXPECT_CALL(hmi_capabilities, button_capabilities())
- .WillOnce(Return(button_caps_ptr.get()));
-
- MockAppPtr mock_app(CreateMockApp());
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillRepeatedly(Return(mock_app));
-
- EXPECT_CALL(*mock_app, UnsubscribeFromButton(kButtonId))
- .WillOnce(Return(true));
-
- EXPECT_CALL(app_mngr_,
- ManageHMICommand(HMIResultCodeIs(
- hmi_apis::FunctionID::Buttons_OnButtonSubscription)));
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(MobileResultCodeIs(mobile_result::SUCCESS), _));
-
- EXPECT_CALL(*mock_app, UpdateHash());
- command->Init();
- command->Run();
-}
-
-} // namespace unsubscribe_button_request
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/unsubscribe_vehicle_request_test.cc b/src/components/application_manager/test/commands/mobile/unsubscribe_vehicle_request_test.cc
deleted file mode 100644
index bb4824e8f7..0000000000
--- a/src/components/application_manager/test/commands/mobile/unsubscribe_vehicle_request_test.cc
+++ /dev/null
@@ -1,287 +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/commands/command_request_test.h"
-#include "application_manager/mock_application_manager.h"
-#include "application_manager/mock_message_helper.h"
-#include "application_manager/commands/mobile/unsubscribe_vehicle_data_request.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace unsubscribe_vehicle_data_request {
-
-namespace am = ::application_manager;
-namespace mobile_result = mobile_apis::Result;
-
-using ::testing::_;
-
-using am::commands::UnsubscribeVehicleDataRequest;
-using am::commands::MessageSharedPtr;
-
-typedef ::utils::SharedPtr<UnsubscribeVehicleDataRequest> CommandPtr;
-
-namespace {
-const uint32_t kConnectionKey = 1u;
-const std::string kMsgParamKey = "test_key";
-const mobile_apis::VehicleDataType::eType kVehicleType =
- mobile_apis::VehicleDataType::VEHICLEDATA_SPEED;
-} // namespace
-
-class UnsubscribeVehicleRequestTest
- : public CommandRequestTest<CommandsTestMocks::kIsNice> {
- protected:
- void UnsubscribeSuccessfully();
- sync_primitives::Lock app_set_lock_;
-};
-
-TEST_F(UnsubscribeVehicleRequestTest, Run_AppNotRegistered_UNSUCCESS) {
- CommandPtr command(CreateCommand<UnsubscribeVehicleDataRequest>());
- EXPECT_CALL(app_mngr_, application(_))
- .WillOnce(Return(ApplicationSharedPtr()));
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(
- MobileResultCodeIs(mobile_result::APPLICATION_NOT_REGISTERED), _));
-
- command->Run();
-}
-
-TEST_F(UnsubscribeVehicleRequestTest,
- Run_DataToUnsubscribeIsNotExisted_UNSUCCESS) {
- MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
- (*command_msg)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
- (*command_msg)[am::strings::msg_params][am::strings::button_name] =
- kVehicleType;
-
- am::VehicleData data;
- EXPECT_CALL(mock_message_helper_, vehicle_data()).WillOnce(ReturnRef(data));
- CommandPtr command(CreateCommand<UnsubscribeVehicleDataRequest>(command_msg));
-
- MockAppPtr mock_app(CreateMockApp());
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app));
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(MobileResultCodeIs(mobile_result::INVALID_DATA), _));
-
- command->Run();
-}
-
-TEST_F(UnsubscribeVehicleRequestTest,
- Run_UnsubscribeNotSubscribedBeforeData_IGNORED) {
- MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
- (*command_msg)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
- (*command_msg)[am::strings::msg_params][kMsgParamKey] = kVehicleType;
-
- am::VehicleData vehicle_data;
- vehicle_data.insert(am::VehicleData::value_type(kMsgParamKey, kVehicleType));
- EXPECT_CALL(mock_message_helper_, vehicle_data())
- .WillOnce(ReturnRef(vehicle_data));
- CommandPtr command(CreateCommand<UnsubscribeVehicleDataRequest>(command_msg));
-
- MockAppPtr mock_app(CreateMockApp());
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app));
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(MobileResultCodeIs(mobile_result::IGNORED), _));
-
- command->Run();
-}
-
-TEST_F(UnsubscribeVehicleRequestTest,
- Run_UnsubscribeNotSubscribedBeforeData_UNSUCCESS) {
- MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
- (*command_msg)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
- (*command_msg)[am::strings::msg_params][kMsgParamKey] = true;
-
- am::VehicleData vehicle_data;
- vehicle_data.insert(am::VehicleData::value_type(kMsgParamKey, kVehicleType));
- EXPECT_CALL(mock_message_helper_, vehicle_data())
- .WillOnce(ReturnRef(vehicle_data));
- CommandPtr command(CreateCommand<UnsubscribeVehicleDataRequest>(command_msg));
-
- MockAppPtr mock_app(CreateMockApp());
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app));
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(MobileResultCodeIs(mobile_result::IGNORED), _));
-
- command->Run();
-}
-
-TEST_F(UnsubscribeVehicleRequestTest, Run_UnsubscribeDataDisabled_UNSUCCESS) {
- MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
- (*command_msg)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
-
- am::VehicleData vehicle_data;
- vehicle_data.insert(am::VehicleData::value_type(kMsgParamKey, kVehicleType));
- EXPECT_CALL(mock_message_helper_, vehicle_data())
- .WillOnce(ReturnRef(vehicle_data));
- CommandPtr command(CreateCommand<UnsubscribeVehicleDataRequest>(command_msg));
-
- MockAppPtr mock_app(CreateMockApp());
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app));
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(MobileResultCodeIs(mobile_result::INVALID_DATA), _));
-
- command->Run();
-}
-
-void UnsubscribeVehicleRequestTest::UnsubscribeSuccessfully() {
- MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
- (*command_msg)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
- (*command_msg)[am::strings::msg_params][kMsgParamKey] = true;
-
- am::VehicleData vehicle_data;
- vehicle_data.insert(am::VehicleData::value_type(kMsgParamKey, kVehicleType));
-
- EXPECT_CALL(mock_message_helper_, vehicle_data())
- .WillOnce(ReturnRef(vehicle_data));
-
- am::ApplicationSet application_set_;
- MockAppPtr mock_app(CreateMockApp());
- application_set_.insert(mock_app);
- DataAccessor<am::ApplicationSet> accessor(application_set_, app_set_lock_);
-
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillRepeatedly(Return(mock_app));
-
- EXPECT_CALL(app_mngr_, applications()).WillRepeatedly(Return(accessor));
-
- EXPECT_CALL(*mock_app, IsSubscribedToIVI(kVehicleType))
- .WillRepeatedly(Return(true));
-
- EXPECT_CALL(*mock_app, UnsubscribeFromIVI(kVehicleType))
- .WillRepeatedly(Return(true));
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(MobileResultCodeIs(mobile_result::SUCCESS), _));
-
- CommandPtr command(CreateCommand<UnsubscribeVehicleDataRequest>(command_msg));
- command->Run();
-}
-
-TEST_F(UnsubscribeVehicleRequestTest, Run_UnsubscribeData_SUCCESS) {
- UnsubscribeSuccessfully();
-}
-
-TEST_F(UnsubscribeVehicleRequestTest, OnEvent_DataNotSubscribed_IGNORED) {
- MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
- (*command_msg)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
- (*command_msg)[am::strings::msg_params][kMsgParamKey] = true;
- CommandPtr command(CreateCommand<UnsubscribeVehicleDataRequest>(command_msg));
-
- am::VehicleData vehicle_data;
- MockAppPtr mock_app(CreateMockApp());
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillRepeatedly(Return(mock_app));
- vehicle_data.insert(am::VehicleData::value_type(kMsgParamKey, kVehicleType));
- EXPECT_CALL(mock_message_helper_, vehicle_data())
- .WillOnce(ReturnRef(vehicle_data));
- EXPECT_CALL(*mock_app, IsSubscribedToIVI(kVehicleType))
- .WillRepeatedly(Return(false));
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(MobileResultCodeIs(mobile_result::IGNORED), _));
- command->Init();
- command->Run();
-
- am::event_engine::Event test_event(
- hmi_apis::FunctionID::VehicleInfo_UnsubscribeVehicleData);
- SmartObject message(smart_objects::SmartType_Map);
- const hmi_apis::Common_Result::eType hmi_result =
- hmi_apis::Common_Result::SUCCESS;
- message[am::strings::params][am::hmi_response::code] = hmi_result;
- message[am::strings::msg_params][kMsgParamKey] = true;
- test_event.set_smart_object(message);
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(MobileResultCodeIs(mobile_result::IGNORED), _));
- EXPECT_CALL(*mock_app, UpdateHash());
-
- command->on_event(test_event);
-}
-
-TEST_F(UnsubscribeVehicleRequestTest, OnEvent_DataUnsubscribed_SUCCESS) {
- UnsubscribeSuccessfully();
- MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
- (*command_msg)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
- (*command_msg)[am::strings::msg_params][kMsgParamKey] = true;
- CommandPtr command(CreateCommand<UnsubscribeVehicleDataRequest>(command_msg));
- MockAppPtr mock_app(CreateMockApp());
-
- am::event_engine::Event test_event(
- hmi_apis::FunctionID::VehicleInfo_UnsubscribeVehicleData);
- SmartObject message(smart_objects::SmartType_Map);
- const hmi_apis::Common_Result::eType hmi_result =
- hmi_apis::Common_Result::SUCCESS;
- message[am::strings::params][am::hmi_response::code] = hmi_result;
- message[am::strings::msg_params][kMsgParamKey] = true;
- test_event.set_smart_object(message);
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(MobileResultCodeIs(mobile_result::SUCCESS), _));
-
- command->on_event(test_event);
-}
-
-} // namespace unsubscribe_vehicle_data_request
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/unsubscribe_vehicle_response_test.cc b/src/components/application_manager/test/commands/mobile/unsubscribe_vehicle_response_test.cc
deleted file mode 100644
index 532948e5db..0000000000
--- a/src/components/application_manager/test/commands/mobile/unsubscribe_vehicle_response_test.cc
+++ /dev/null
@@ -1,111 +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/mobile/unsubscribe_vehicle_data_response.h"
-#include <stdint.h>
-#include <string>
-#include "gtest/gtest.h"
-#include "utils/shared_ptr.h"
-#include "application_manager/commands/commands_test.h"
-#include "application_manager/mock_application_manager.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace unsubscribe_vehicle_data_response {
-
-namespace commands = ::application_manager::commands;
-
-using ::testing::_;
-using ::testing::NotNull;
-using ::testing::Types;
-
-using commands::MessageSharedPtr;
-namespace am = ::application_manager;
-
-class UnsubscribeVehicleResponseTest
- : public CommandsTest<CommandsTestMocks::kIsNice> {};
-
-MATCHER_P(ResultCodeIs, result_code, "") {
- return result_code ==
- static_cast<mobile_apis::Result::eType>(
- (*arg)[am::strings::msg_params][am::strings::result_code].asInt());
-}
-
-TEST_F(UnsubscribeVehicleResponseTest,
- Run_SendFalseResponseToMobile_SendInvalidEnum) {
- MessageSharedPtr command_msg =
- ::utils::MakeShared<SmartObject>(smart_objects::SmartType_Map);
- (*command_msg)[am::strings::msg_params][am::strings::success] = false;
-
- ::utils::SharedPtr<commands::UnsubscribeVehicleDataResponse> command =
- CreateCommand<commands::UnsubscribeVehicleDataResponse>(command_msg);
- EXPECT_CALL(
- app_mngr_,
- SendMessageToMobile(ResultCodeIs(mobile_apis::Result::INVALID_ENUM), _));
- command->Run();
-}
-
-TEST_F(UnsubscribeVehicleResponseTest,
- Run_SendSuccessfulResponseToMobile_SUCCESS) {
- MessageSharedPtr command_msg =
- ::utils::MakeShared<SmartObject>(smart_objects::SmartType_Map);
- (*command_msg)[am::strings::msg_params][am::strings::success] = true;
- ::utils::SharedPtr<commands::UnsubscribeVehicleDataResponse> command =
- CreateCommand<commands::UnsubscribeVehicleDataResponse>(command_msg);
- EXPECT_CALL(
- app_mngr_,
- SendMessageToMobile(ResultCodeIs(mobile_apis::Result::SUCCESS), _));
- command->Run();
-}
-
-TEST_F(UnsubscribeVehicleResponseTest,
- Run_SendResponseToMobile_SendCodeToMobile) {
- MessageSharedPtr command_msg =
- ::utils::MakeShared<SmartObject>(smart_objects::SmartType_Map);
- (*command_msg)[am::strings::msg_params][am::strings::success] = true;
-
- mobile_apis::Result::eType result_type = mobile_apis::Result::WARNINGS;
- (*command_msg)[am::strings::msg_params][am::strings::result_code] =
- result_type;
- ::utils::SharedPtr<commands::UnsubscribeVehicleDataResponse> command =
- CreateCommand<commands::UnsubscribeVehicleDataResponse>(command_msg);
- EXPECT_CALL(app_mngr_, SendMessageToMobile(ResultCodeIs(result_type), _));
- command->Run();
-}
-
-} // namespace unsubscribe_vehicle_data_response
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/unsubscribe_way_points_request_test.cc b/src/components/application_manager/test/commands/mobile/unsubscribe_way_points_request_test.cc
deleted file mode 100644
index 5615b0cabd..0000000000
--- a/src/components/application_manager/test/commands/mobile/unsubscribe_way_points_request_test.cc
+++ /dev/null
@@ -1,172 +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 "mobile/unsubscribe_way_points_request.h"
-#include "interfaces/MOBILE_API.h"
-#include "utils/shared_ptr.h"
-#include "smart_objects/smart_object.h"
-#include "commands/commands_test.h"
-#include "commands/command_request_test.h"
-#include "application_manager/application.h"
-#include "application_manager/mock_application_manager.h"
-#include "application_manager/mock_application.h"
-#include "application_manager/mock_message_helper.h"
-#include "application_manager/smart_object_keys.h"
-#include "application_manager/event_engine/event.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace unsubscribe_way_points_request {
-
-namespace am = ::application_manager;
-namespace mobile_result = mobile_apis::Result;
-
-using ::testing::_;
-using ::testing::Return;
-
-using am::commands::UnSubscribeWayPointsRequest;
-using am::commands::MessageSharedPtr;
-
-namespace {
-const uint32_t kConnectionKey = 3u;
-const uint32_t kAppId = 5u;
-} // namespace
-
-class UnSubscribeWayPointsRequestTest
- : public CommandRequestTest<CommandsTestMocks::kIsNice> {
- public:
- UnSubscribeWayPointsRequestTest()
- : command_msg_(CreateMessage(smart_objects::SmartType_Map))
- , command_(CreateCommand<UnSubscribeWayPointsRequest>(command_msg_)) {
- (*command_msg_)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
- }
-
- MessageSharedPtr command_msg_;
- ::utils::SharedPtr<UnSubscribeWayPointsRequest> command_;
-};
-
-TEST_F(UnSubscribeWayPointsRequestTest,
- Run_ApplicationIsNotRegistered_UNSUCCESS) {
- EXPECT_CALL(app_mngr_, application(_))
- .WillOnce(Return(ApplicationSharedPtr()));
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(
- MobileResultCodeIs(mobile_result::APPLICATION_NOT_REGISTERED), _));
-
- command_->Run();
-}
-
-TEST_F(UnSubscribeWayPointsRequestTest,
- Run_AppIsNotSubscribedForWayPoints_UNSUCCESS) {
- MockAppPtr mock_app(CreateMockApp());
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app));
-
- EXPECT_CALL(app_mngr_,
- IsAppSubscribedForWayPoints(
- ::testing::Matcher<am::ApplicationSharedPtr>(mock_app)))
- .WillOnce(Return(false));
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(MobileResultCodeIs(mobile_result::IGNORED), _));
-
- command_->Run();
-}
-
-TEST_F(UnSubscribeWayPointsRequestTest, Run_AppSubscribedForWayPoints_SUCCESS) {
- MockAppPtr mock_app(CreateMockApp());
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app));
-
- EXPECT_CALL(app_mngr_,
- IsAppSubscribedForWayPoints(
- ::testing::Matcher<am::ApplicationSharedPtr>(mock_app)))
- .WillOnce(Return(true));
-
- EXPECT_CALL(app_mngr_,
- ManageHMICommand(HMIResultCodeIs(
- hmi_apis::FunctionID::Navigation_UnsubscribeWayPoints)));
-
- command_->Run();
-}
-
-TEST_F(UnSubscribeWayPointsRequestTest, OnEvent_UnknownEvent_UNSUCCESS) {
- MockAppPtr mock_app(CreateMockApp());
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app));
-
- EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0);
-
- Event event(hmi_apis::FunctionID::INVALID_ENUM);
-
- command_->on_event(event);
-}
-
-TEST_F(UnSubscribeWayPointsRequestTest,
- OnEvent_ReceivedNavigationUnSubscribeWayPointsEvent_SUCCESS) {
- MockAppPtr mock_app(CreateMockApp());
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillRepeatedly(Return(mock_app));
-
- MessageSharedPtr event_msg(CreateMessage(smart_objects::SmartType_Map));
- (*event_msg)[am::strings::msg_params] = 0;
- (*event_msg)[am::strings::params][am::hmi_response::code] =
- mobile_result::SUCCESS;
- Event event(hmi_apis::FunctionID::Navigation_UnsubscribeWayPoints);
- event.set_smart_object(*event_msg);
-
- EXPECT_CALL(app_mngr_,
- UnsubscribeAppFromWayPoints(
- ::testing::Matcher<am::ApplicationSharedPtr>(mock_app)));
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(MobileResultCodeIs(mobile_result::SUCCESS), _));
-
- command_->on_event(event);
-}
-
-} // namespace unsubscribe_way_points_request
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/update_turn_list_request_test.cc b/src/components/application_manager/test/commands/mobile/update_turn_list_request_test.cc
deleted file mode 100644
index dacabba5fd..0000000000
--- a/src/components/application_manager/test/commands/mobile/update_turn_list_request_test.cc
+++ /dev/null
@@ -1,305 +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/mobile/update_turn_list_request.h"
-#include "interfaces/MOBILE_API.h"
-#include "utils/shared_ptr.h"
-#include "smart_objects/smart_object.h"
-#include "application_manager/commands/commands_test.h"
-#include "application_manager/commands/command_request_test.h"
-#include "application_manager/application.h"
-#include "application_manager/mock_application_manager.h"
-#include "application_manager/mock_application.h"
-#include "application_manager/mock_message_helper.h"
-#include "application_manager/mock_hmi_capabilities.h"
-#include "application_manager/policies/mock_policy_handler_interface.h"
-#include "application_manager/smart_object_keys.h"
-#include "application_manager/event_engine/event.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace mobile_commands_test {
-namespace update_turn_list_request {
-
-namespace am = ::application_manager;
-namespace mobile_result = mobile_apis::Result;
-
-using ::testing::_;
-using ::testing::Return;
-using ::testing::ReturnRef;
-using ::testing::Ref;
-using ::testing::Eq;
-
-using am::commands::UpdateTurnListRequest;
-using am::commands::MessageSharedPtr;
-using application_manager_test::MockHMICapabilities;
-
-namespace {
-const uint32_t kConnectionKey = 3u;
-const hmi_apis::FunctionID::eType kFunctionId =
- hmi_apis::FunctionID::Buttons_OnButtonEvent;
-const uint32_t kAppId = 5u;
-} // namespace
-
-class UpdateTurnListRequestTest
- : public CommandRequestTest<CommandsTestMocks::kIsNice> {
- public:
- UpdateTurnListRequestTest()
- : command_msg_(CreateMessage(smart_objects::SmartType_Map))
- , command_(CreateCommand<UpdateTurnListRequest>(command_msg_)) {
- (*command_msg_)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
- (*command_msg_)[am::strings::params][am::strings::function_id] =
- kFunctionId;
- }
-
- MessageSharedPtr command_msg_;
- ::utils::SharedPtr<UpdateTurnListRequest> command_;
- TypeIf<kMocksAreNice,
- NiceMock<policy_test::MockPolicyHandlerInterface>,
- policy_test::MockPolicyHandlerInterface>::Result mock_policy_handler_;
-};
-
-TEST_F(UpdateTurnListRequestTest, Run_ApplicationIsNotRegistered_UNSUCCESS) {
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(ApplicationSharedPtr()));
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(
- MobileResultCodeIs(mobile_result::APPLICATION_NOT_REGISTERED), _));
-
- command_->Run();
-}
-
-TEST_F(UpdateTurnListRequestTest, Run_InvalidNavigationText_UNSUCCESS) {
- (*command_msg_)[am::strings::msg_params][am::strings::turn_list][0]
- [am::strings::navigation_text] = "invalid_navigation_text\t\n";
-
- MockAppPtr mock_app(CreateMockApp());
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app));
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(MobileResultCodeIs(mobile_result::INVALID_DATA), _));
-
- command_->Run();
-}
-
-TEST_F(UpdateTurnListRequestTest, Run_InvalidTurnIcon_UNSUCCESS) {
- (*command_msg_)[am::strings::msg_params][am::strings::turn_list][0]
- [am::strings::navigation_text] = "valid_navigation_text";
- (*command_msg_)[am::strings::msg_params][am::strings::turn_list][0]
- [am::strings::turn_icon][am::strings::value] =
- "invalid_turn_icon\t\n";
-
- MockAppPtr mock_app(CreateMockApp());
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app));
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(MobileResultCodeIs(mobile_result::INVALID_DATA), _));
-
- command_->Run();
-}
-
-TEST_F(UpdateTurnListRequestTest,
- Run_ProcessSoftButtonsNotSucceeded_UNSUCCESS) {
- (*command_msg_)[am::strings::msg_params][am::strings::turn_list][0]
- [am::strings::navigation_text] = "valid_navigation_text";
- (*command_msg_)[am::strings::msg_params][am::strings::turn_list][0]
- [am::strings::turn_icon][am::strings::value] =
- "valid_turn_icon";
-
- MockAppPtr mock_app(CreateMockApp());
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app));
-
- EXPECT_CALL(app_mngr_, GetPolicyHandler())
- .WillOnce(ReturnRef(mock_policy_handler_));
-
- const mobile_result::eType kExpectedResult = mobile_result::INVALID_ENUM;
- EXPECT_CALL(mock_message_helper_,
- ProcessSoftButtons((*command_msg_)[am::strings::msg_params],
- Eq(mock_app),
- Ref(mock_policy_handler_),
- Ref(app_mngr_)))
- .WillOnce(Return(kExpectedResult));
-
- EXPECT_CALL(app_mngr_,
- ManageMobileCommand(MobileResultCodeIs(kExpectedResult), _));
-
- command_->Run();
-}
-
-TEST_F(UpdateTurnListRequestTest, Run_NoTurnList_UNSUCCESS) {
- MockAppPtr mock_app(CreateMockApp());
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app));
-
- EXPECT_CALL(app_mngr_, GetPolicyHandler())
- .WillOnce(ReturnRef(mock_policy_handler_));
-
- EXPECT_CALL(mock_message_helper_,
- ProcessSoftButtons((*command_msg_)[am::strings::msg_params],
- Eq(mock_app),
- Ref(mock_policy_handler_),
- Ref(app_mngr_)))
- .WillOnce(Return(mobile_result::SUCCESS));
-
- EXPECT_CALL(
- app_mngr_,
- ManageMobileCommand(MobileResultCodeIs(mobile_result::INVALID_DATA), _));
-
- command_->Run();
-}
-
-TEST_F(UpdateTurnListRequestTest, Run_ValidTurnList_SUCCESS) {
- const std::string kNavigationText = "valid_navigation_text";
-
- (*command_msg_)[am::strings::msg_params][am::strings::turn_list][0]
- [am::strings::navigation_text] = kNavigationText;
- (*command_msg_)[am::strings::msg_params][am::strings::turn_list][0]
- [am::strings::turn_icon][am::strings::value] =
- "valid_turn_icon";
- (*command_msg_)[am::strings::msg_params][am::strings::soft_buttons] = 0;
-
- MockAppPtr mock_app(CreateMockApp());
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app));
-
- EXPECT_CALL(app_mngr_, GetPolicyHandler())
- .WillOnce(ReturnRef(mock_policy_handler_));
-
- EXPECT_CALL(mock_message_helper_,
- ProcessSoftButtons((*command_msg_)[am::strings::msg_params],
- Eq(mock_app),
- Ref(mock_policy_handler_),
- Ref(app_mngr_)))
- .WillOnce(Return(mobile_result::SUCCESS));
-
- EXPECT_CALL(
- mock_message_helper_,
- VerifyImage(
- (*command_msg_)[am::strings::msg_params][am::strings::turn_list][0]
- [am::strings::turn_icon],
- Eq(mock_app),
- Ref(app_mngr_))).WillOnce(Return(mobile_result::SUCCESS));
-
- EXPECT_CALL(mock_message_helper_,
- SubscribeApplicationToSoftButton(_, _, kFunctionId));
-
- MessageSharedPtr result_msg(CatchHMICommandResult(CallRun(*command_)));
- ASSERT_TRUE(result_msg);
- EXPECT_EQ(
- hmi_apis::FunctionID::Navigation_UpdateTurnList,
- (*result_msg)[am::strings::params][am::strings::function_id].asInt());
-
- ASSERT_TRUE((*result_msg)[am::strings::msg_params][am::strings::turn_list][0]
- .keyExists(am::hmi_request::navi_text));
-
- EXPECT_TRUE((*result_msg)[am::strings::msg_params][am::strings::turn_list][0]
- [am::hmi_request::navi_text].keyExists(
- am::hmi_request::field_name));
- EXPECT_EQ(
- hmi_apis::Common_TextFieldName::turnText,
- (*result_msg)[am::strings::msg_params][am::strings::turn_list][0]
- [am::hmi_request::navi_text][am::hmi_request::field_name]
- .asInt());
-
- EXPECT_TRUE((*result_msg)[am::strings::msg_params][am::strings::turn_list][0]
- [am::hmi_request::navi_text].keyExists(
- am::hmi_request::field_text));
- EXPECT_EQ(
- kNavigationText,
- (*result_msg)[am::strings::msg_params][am::strings::turn_list][0]
- [am::hmi_request::navi_text][am::hmi_request::field_text]
- .asString());
-}
-
-TEST_F(UpdateTurnListRequestTest, OnEvent_UnknownEvent_UNSUCCESS) {
- Event event(hmi_apis::FunctionID::INVALID_ENUM);
-
- EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0);
-
- command_->on_event(event);
-}
-
-TEST_F(UpdateTurnListRequestTest, OnEvent_UnsupportedResource_SUCCESS) {
- MessageSharedPtr event_msg(CreateMessage(smart_objects::SmartType_Map));
- const hmi_apis::Common_Result::eType hmi_response_code =
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
- const mobile_result::eType mobile_response_code =
- mobile_result::UNSUPPORTED_RESOURCE;
- (*event_msg)[am::strings::params][am::hmi_response::code] = hmi_response_code;
- (*event_msg)[am::strings::msg_params] = 0;
-
- Event event(hmi_apis::FunctionID::Navigation_UpdateTurnList);
- event.set_smart_object(*event_msg);
-
- EXPECT_CALL(app_mngr_,
- ManageMobileCommand(MobileResultCodeIs(mobile_response_code), _));
-
- command_->on_event(event);
-}
-
-TEST_F(UpdateTurnListRequestTest,
- OnEvent_ReceivedNavigationUpdateTurnListEvent_SUCCESS) {
- const hmi_apis::Common_Result::eType hmi_response_code =
- hmi_apis::Common_Result::SUCCESS;
- const mobile_result::eType mobile_response_code = mobile_result::SUCCESS;
-
- MessageSharedPtr event_msg(CreateMessage(smart_objects::SmartType_Map));
- (*event_msg)[am::strings::params][am::hmi_response::code] = hmi_response_code;
- (*event_msg)[am::strings::msg_params] = 0;
-
- Event event(hmi_apis::FunctionID::Navigation_UpdateTurnList);
- event.set_smart_object(*event_msg);
-
- EXPECT_CALL(app_mngr_,
- ManageMobileCommand(MobileResultCodeIs(mobile_response_code), _));
-
- command_->on_event(event);
-}
-
-} // namespace update_turn_list_request
-} // namespace mobile_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace test