summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Keeler <jacob.keeler@livioradio.com>2018-07-16 14:36:35 -0700
committerGitHub <noreply@github.com>2018-07-16 14:36:35 -0700
commit4dde9552b3d9ab5fa29502810be48bdf0f793cd7 (patch)
tree4870b3b1721cd9595a7118f789c610fa1b44f83e
parent5cff788119f1e62344b94aebb7ca23cf63dc39f8 (diff)
parent2f05a630fe5f35bc46f3003d9fc35d3451c130c4 (diff)
downloadsdl_core-4dde9552b3d9ab5fa29502810be48bdf0f793cd7.tar.gz
Merge pull request #2199 from smartdevicelink/feature/handling_VR_help_requests
Feature/handling vr help requests
-rw-r--r--src/components/application_manager/include/application_manager/application.h7
-rw-r--r--src/components/application_manager/include/application_manager/application_impl.h8
-rw-r--r--src/components/application_manager/include/application_manager/help_prompt_manager.h96
-rw-r--r--src/components/application_manager/include/application_manager/help_prompt_manager_impl.h188
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_global_properties_request.h8
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_request.cc24
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_command_request.cc5
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_sub_menu_request.cc6
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_hmi_status_notification.cc13
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_global_properties_request.cc76
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_command_request_test.cc22
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_command_request_test.cc18
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_sub_menu_test.cc9
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_hmi_status_notification_test.cc39
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_global_properties_test.cc192
-rw-r--r--src/components/application_manager/src/application_impl.cc5
-rw-r--r--src/components/application_manager/src/help_prompt_manager_impl.cc396
-rw-r--r--src/components/application_manager/src/helpers/application_helper.cc1
-rw-r--r--src/components/application_manager/src/message_helper/message_helper.cc21
-rw-r--r--src/components/application_manager/src/resumption/resume_ctrl_impl.cc6
-rwxr-xr-x[-rw-r--r--]src/components/application_manager/test/CMakeLists.txt8
-rw-r--r--src/components/application_manager/test/help_prompt_manager_test.cc369
-rw-r--r--src/components/application_manager/test/include/application_manager/mock_application.h4
-rw-r--r--src/components/application_manager/test/include/application_manager/mock_help_prompt_manager.h61
-rw-r--r--src/components/application_manager/test/message_helper/message_helper_test.cc15
-rw-r--r--src/components/application_manager/test/resumption/resume_ctrl_test.cc29
26 files changed, 1375 insertions, 251 deletions
diff --git a/src/components/application_manager/include/application_manager/application.h b/src/components/application_manager/include/application_manager/application.h
index df5819c1eb..cfc3c03a5b 100644
--- a/src/components/application_manager/include/application_manager/application.h
+++ b/src/components/application_manager/include/application_manager/application.h
@@ -46,6 +46,7 @@
#include "application_manager/message.h"
#include "application_manager/hmi_state.h"
#include "application_manager/application_state.h"
+#include "application_manager/help_prompt_manager.h"
#include "protocol_handler/protocol_handler.h"
#include "smart_objects/smart_object.h"
#include "utils/macro.h"
@@ -671,6 +672,12 @@ class Application : public virtual InitialApplicationData,
virtual UsageStatistics& usage_report() = 0;
/**
+ * @brief Access to HelpPromptManager interface
+ * @return object for Handling VR help
+ */
+ virtual HelpPromptManager& help_prompt_manager() = 0;
+
+ /**
* @brief SetInitialState sets initial HMI state for application on
* registration
* @param state Hmi state value
diff --git a/src/components/application_manager/include/application_manager/application_impl.h b/src/components/application_manager/include/application_manager/application_impl.h
index 809e8b5764..46706fad4f 100644
--- a/src/components/application_manager/include/application_manager/application_impl.h
+++ b/src/components/application_manager/include/application_manager/application_impl.h
@@ -44,6 +44,7 @@
#include "application_manager/application.h"
#include "application_manager/application_data_impl.h"
#include "application_manager/usage_statistics.h"
+#include "application_manager/help_prompt_manager_impl.h"
#include "application_manager/hmi_state.h"
#include "protocol_handler/protocol_handler.h"
@@ -268,6 +269,12 @@ class ApplicationImpl : public virtual Application,
UsageStatistics& usage_report();
+ /**
+ * @brief Access to HelpPromptManager interface
+ * @return object for Handling VR help
+ */
+ HelpPromptManager& help_prompt_manager() OVERRIDE;
+
bool AreCommandLimitsExceeded(mobile_apis::FunctionID::eType cmd_id,
TLimitSource source);
virtual void SubscribeToSoftButtons(int32_t cmd_id,
@@ -489,6 +496,7 @@ class ApplicationImpl : public virtual Application,
AppFilesMap app_files_;
std::set<mobile_apis::ButtonName::eType> subscribed_buttons_;
UsageStatistics usage_report_;
+ HelpPromptManagerImpl help_prompt_manager_impl_;
protocol_handler::MajorProtocolVersion protocol_version_;
bool is_voice_communication_application_;
sync_primitives::atomic_bool is_resuming_;
diff --git a/src/components/application_manager/include/application_manager/help_prompt_manager.h b/src/components/application_manager/include/application_manager/help_prompt_manager.h
new file mode 100644
index 0000000000..a0c34e77d7
--- /dev/null
+++ b/src/components/application_manager/include/application_manager/help_prompt_manager.h
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2018, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_HELP_PROMPT_MANAGER_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_HELP_PROMPT_MANAGER_H_
+
+#include "smart_objects/smart_object.h"
+
+namespace application_manager {
+/**
+ * @brief The HelpPromptManager is a mechanism for handling "help" requests
+ * by the user when the application does not provide any or such information.
+ */
+class HelpPromptManager {
+ public:
+ /**
+ * @brief Class destructor
+ */
+ virtual ~HelpPromptManager() {}
+
+ /**
+ * @brief Adds command to constructed values, and sends SetGlobalProperties if
+ * required
+ * @param cmd_id command unique ID
+ * @param command smart object with commands to add
+ * @param is_resumption flag for identifying if command was added during data
+ * resumption process
+ */
+ virtual void OnVrCommandAdded(const uint32_t cmd_id,
+ const smart_objects::SmartObject& command,
+ const bool is_resumption) = 0;
+
+ /**
+ * @brief Removes command from constructed values, and send
+ * SetGlobalProperties if required
+ * @param cmd_id command unique ID
+ * @param is_resumption flag for identifying if command was added during data
+ * resumption process
+ */
+ virtual void OnVrCommandDeleted(const uint32_t cmd_id,
+ const bool is_resumption) = 0;
+
+ /**
+ * @brief Stop constructing vrHelp and/or helpPrompt if they are present in
+ * message
+ * @param msg containing GlobalProperties
+ * @param is_response determines is the request or response for the for
+ * the SetGlobalPropertiesRequest
+ */
+ virtual void OnSetGlobalPropertiesReceived(
+ const smart_objects::SmartObject& msg, const bool is_response) = 0;
+
+ /**
+ * @brief Requests sending type behavior
+ */
+ enum class SendingType { kNoneSend, kSendHelpPrompt, kSendVRHelp, kSendBoth };
+
+ /**
+ * @brief Get current sending type
+ * @return current sending type
+ */
+ virtual SendingType GetSendingType() const = 0;
+};
+
+} // namespace application_manager
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_HELP_PROMPT_MANAGER_H_
diff --git a/src/components/application_manager/include/application_manager/help_prompt_manager_impl.h b/src/components/application_manager/include/application_manager/help_prompt_manager_impl.h
new file mode 100644
index 0000000000..42125375e2
--- /dev/null
+++ b/src/components/application_manager/include/application_manager/help_prompt_manager_impl.h
@@ -0,0 +1,188 @@
+/*
+ * Copyright (c) 2018, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_HELP_PROMPT_MANAGER_IMPL_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_HELP_PROMPT_MANAGER_IMPL_H_
+
+#include "application_manager/help_prompt_manager.h"
+
+#include <algorithm>
+#include <vector>
+
+#include "utils/lock.h"
+#include "utils/timer.h"
+
+namespace application_manager {
+
+class Application;
+class ApplicationManager;
+
+/**
+ * @brief The HelpPromptManagerImpl class implemented interface
+ * HelpPromptManager
+ * is a mechanism for handling "help" requests
+ * by the user when the application does not provide any or such information.
+ */
+class HelpPromptManagerImpl : public HelpPromptManager {
+ public:
+ /**
+ * @brief Container for buffering VR help commands
+ */
+ typedef std::pair<uint32_t, smart_objects::SmartObjectSPtr> VRCommandPair;
+ typedef std::vector<VRCommandPair> VRCommandPairs;
+
+ /**
+ * @brief Class constructor
+ * @param app owner for this class
+ */
+ HelpPromptManagerImpl(Application& app, ApplicationManager& app_manager);
+
+ /**
+ * @brief Class destructor
+ */
+ ~HelpPromptManagerImpl();
+
+ /**
+ * @brief Adds command to constructed values, and sends SetGlobalProperties if
+ * required
+ * @param cmd_id command unique ID
+ * @param command smart object with commands to add
+ * @param is_resumption flag for identifying if command was added during data
+ * resumption process
+ */
+ void OnVrCommandAdded(const uint32_t cmd_id,
+ const smart_objects::SmartObject& command,
+ const bool is_resumption) OVERRIDE;
+
+ /**
+ * @brief Removes command from constructed values, and send
+ * SetGlobalProperties if required
+ * @param cmd_id command unique ID
+ * @param is_resumption flag for identifying if command was added during data
+ * resumption process
+ */
+ void OnVrCommandDeleted(const uint32_t cmd_id,
+ const bool is_resumption) OVERRIDE;
+
+ /**
+ * @brief Stop constructing vrHelp and/or helpPrompt if they are present in
+ * message
+ * @param msg containing GlobalProperties
+ * @param is_response determines is the request or response for the for
+ * the SetGlobalPropertiesRequest
+ */
+ void OnSetGlobalPropertiesReceived(const smart_objects::SmartObject& msg,
+ const bool is_response) OVERRIDE;
+
+ /**
+ * @brief Get current sending type
+ * @return current sending type
+ */
+ SendingType GetSendingType() const OVERRIDE;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(HelpPromptManagerImpl);
+
+ /**
+ * @brief Add new smart object with VR command to the map
+ * @param cmd_id ID of VR command
+ * @param command smart object containing VR command structure
+ * @return true if first kLimitCommand commands was changed after adding
+ * of the current command otherwise returns false
+ */
+ bool AddCommand(const uint32_t cmd_id,
+ const smart_objects::SmartObject& command);
+ /**
+ * @brief Delete VR command from map by its cmd_id
+ * @param cmd_id ID of VR command
+ * @return true if first kLimitCommand commands was changed after deleting
+ * of the current command otherwise returns false
+ */
+ bool DeleteCommand(const uint32_t cmd_id);
+
+ /**
+ * @brief Send TTS request to HMI
+ */
+ void SendTTSRequest();
+
+ /**
+ * @brief Send UI request to HMI
+ */
+ void SendUIRequest();
+
+ /**
+ * @brief Send TTS and UI requests to HMI
+ */
+ void SendBothRequests();
+
+ /**
+ * @brief Send TTS or UI or both Requests
+ */
+ void SendRequests();
+
+ /**
+ * @brief Construct the helpPrompt parameter
+ */
+ void CreatePromptMsg(smart_objects::SmartObject& out_msg_params);
+
+ /**
+ * @brief Construct the vrHelp parameter
+ */
+ void CreateVRMsg(smart_objects::SmartObject& out_msg_params);
+
+ /**
+ * @brief Setting request type to send HMI
+ * @param msg containing request or response for the
+ * SetGlobalPropertiesRequest
+ */
+ void SetSendingType(const smart_objects::SmartObject& msg);
+
+ /**
+ * @brief Get the total count of commands in VRCommand pairs
+ * @param end_element pointer to VRCommandPairs element to which commands
+ * should be counted
+ * @return total count of commands
+ */
+ size_t GetCommandsCount(VRCommandPairs::const_iterator end_element) const;
+
+ Application& app_;
+ ApplicationManager& app_manager_;
+ VRCommandPairs vr_commands_;
+ sync_primitives::Lock vr_commands_lock_;
+ SendingType sending_type_;
+ bool is_tts_send_;
+ bool is_ui_send_;
+};
+
+} // namespace application_manager
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_HELP_PROMPT_MANAGER_IMPL_H_
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_global_properties_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_global_properties_request.h
index 7a8abaaad6..674de4731a 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_global_properties_request.h
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_global_properties_request.h
@@ -83,20 +83,12 @@ class SetGlobalPropertiesRequest
bool Init() FINAL;
private:
- // Verify correctness VrHelptitle value
- static bool ValidateVRHelpTitle(
- const smart_objects::SmartObject* const vr_help_so_ptr);
-
// prepare UI sending data (VrHelps, Menus, Keyboard) to SmartObject
static void PrepareUIRequestVRHelpData(
const app_mngr::ApplicationSharedPtr app,
const smart_objects::SmartObject& msg_params,
smart_objects::SmartObject& out_params);
- static bool PrepareUIRequestDefaultVRHelpData(
- const app_mngr::ApplicationSharedPtr app,
- smart_objects::SmartObject& out_params);
-
static void PrepareUIRequestMenuAndKeyboardData(
const app_mngr::ApplicationSharedPtr app,
const smart_objects::SmartObject& msg_params,
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_request.cc
index d1cb9763d9..1da9fc497f 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_request.cc
@@ -320,9 +320,10 @@ void AddCommandRequest::on_event(const event_engine::Event& event) {
return;
}
+ const uint32_t cmd_id =
+ (*message_)[strings::msg_params][strings::cmd_id].asUInt();
smart_objects::SmartObject msg_param(smart_objects::SmartType_Map);
- msg_param[strings::cmd_id] =
- (*message_)[strings::msg_params][strings::cmd_id];
+ msg_param[strings::cmd_id] = cmd_id;
msg_param[strings::app_id] = application->app_id();
switch (event.id()) {
@@ -458,8 +459,7 @@ void AddCommandRequest::on_event(const event_engine::Event& event) {
msg_params[strings::type] = hmi_apis::Common_VRCommandType::Command;
SendHMIRequest(hmi_apis::FunctionID::VR_DeleteCommand, &msg_params);
- application->RemoveCommand(
- (*message_)[strings::msg_params][strings::cmd_id].asUInt());
+ application->RemoveCommand(cmd_id);
result = false;
LOG4CXX_DEBUG(logger_, "Result " << result);
}
@@ -474,8 +474,7 @@ void AddCommandRequest::on_event(const event_engine::Event& event) {
SendHMIRequest(hmi_apis::FunctionID::UI_DeleteCommand, &msg_params);
- application->RemoveCommand(
- (*message_)[strings::msg_params][strings::cmd_id].asUInt());
+ application->RemoveCommand(cmd_id);
result = false;
LOG4CXX_DEBUG(logger_, "Result " << result);
}
@@ -501,7 +500,10 @@ void AddCommandRequest::on_event(const event_engine::Event& event) {
result = false;
}
- if (!result) {
+ if (result) {
+ application->help_prompt_manager().OnVrCommandAdded(
+ cmd_id, (*message_)[strings::msg_params], false);
+ } else {
RemoveCommand();
}
@@ -595,13 +597,13 @@ void AddCommandRequest::RemoveCommand() {
return;
}
+ const uint32_t cmd_id =
+ (*message_)[strings::msg_params][strings::cmd_id].asUInt();
smart_objects::SmartObject msg_params(smart_objects::SmartType_Map);
- msg_params[strings::cmd_id] =
- (*message_)[strings::msg_params][strings::cmd_id];
+ msg_params[strings::cmd_id] = cmd_id;
msg_params[strings::app_id] = app->app_id();
- app->RemoveCommand(
- (*message_)[strings::msg_params][strings::cmd_id].asUInt());
+ app->RemoveCommand(cmd_id);
if (BothSend() && !(is_vr_received_ || is_ui_received_)) {
// in case we have send bth UI and VR and no one respond
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_command_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_command_request.cc
index bbe787a123..38069c341e 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_command_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_command_request.cc
@@ -198,7 +198,7 @@ void DeleteCommandRequest::on_event(const event_engine::Event& event) {
}
smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params];
- const int32_t cmd_id = msg_params[strings::cmd_id].asInt();
+ const uint32_t cmd_id = msg_params[strings::cmd_id].asUInt();
smart_objects::SmartObject* command = application->FindCommand(cmd_id);
@@ -213,7 +213,8 @@ void DeleteCommandRequest::on_event(const event_engine::Event& event) {
std::string info;
const bool result = PrepareResponseParameters(result_code, info);
if (result) {
- application->RemoveCommand(msg_params[strings::cmd_id].asInt());
+ application->RemoveCommand(cmd_id);
+ application->help_prompt_manager().OnVrCommandDeleted(cmd_id, false);
}
SendResponse(
result, result_code, info.empty() ? NULL : info.c_str(), &msg_params);
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_sub_menu_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_sub_menu_request.cc
index 38113afcc2..9a01163702 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_sub_menu_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_sub_menu_request.cc
@@ -134,9 +134,11 @@ void DeleteSubMenuRequest::DeleteSubMenuUICommands(
(*it->second)[strings::menu_params][hmi_request::parent_id].asInt()) {
smart_objects::SmartObject msg_params =
smart_objects::SmartObject(smart_objects::SmartType_Map);
+ const uint32_t cmd_id = (*it->second)[strings::cmd_id].asUInt();
msg_params[strings::app_id] = app->app_id();
- msg_params[strings::cmd_id] = (*it->second)[strings::cmd_id].asInt();
- app->RemoveCommand((*it->second)[strings::cmd_id].asInt());
+ msg_params[strings::cmd_id] = cmd_id;
+ app->RemoveCommand(cmd_id);
+ app->help_prompt_manager().OnVrCommandDeleted(cmd_id, false);
it = commands.begin(); // Can not relay on
// iterators after erase was called
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_hmi_status_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_hmi_status_notification.cc
index a495423bce..9422bec478 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_hmi_status_notification.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_hmi_status_notification.cc
@@ -78,17 +78,8 @@ void OnHMIStatusNotification::Run() {
mobile_apis::HMILevel::eType hmi_level =
static_cast<mobile_apis::HMILevel::eType>(
(*message_)[strings::msg_params][strings::hmi_level].asInt());
- if ((mobile_apis::HMILevel::HMI_BACKGROUND == hmi_level) ||
- (mobile_apis::HMILevel::HMI_NONE == hmi_level)) {
- if (!(app->tts_properties_in_none())) {
- app->set_tts_properties_in_none(true);
- LOG4CXX_INFO(logger_,
- "OnHMIStatusNotification::Send TTS GlobalProperties"
- " with empty array to HMI");
- MessageHelper::SendTTSGlobalProperties(app, false, application_manager_);
- }
- } else if ((mobile_apis::HMILevel::HMI_FULL == hmi_level) ||
- (mobile_apis::HMILevel::HMI_LIMITED == hmi_level)) {
+ if ((mobile_apis::HMILevel::HMI_FULL == hmi_level) ||
+ (mobile_apis::HMILevel::HMI_LIMITED == hmi_level)) {
if (!(app->tts_properties_in_full())) {
app->set_tts_properties_in_full(true);
LOG4CXX_INFO(logger_,
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_global_properties_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_global_properties_request.cc
index 90ec06025e..92c72d7f66 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_global_properties_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_global_properties_request.cc
@@ -162,6 +162,9 @@ void SetGlobalPropertiesRequest::Run() {
params[strings::app_id] = app->app_id();
SendUIRequest(params, true);
+
+ auto& help_prompt_manager = app->help_prompt_manager();
+ help_prompt_manager.OnSetGlobalPropertiesReceived(params, false);
} else {
LOG4CXX_DEBUG(logger_, "VRHelp params does not present");
DCHECK_OR_RETURN_VOID(!is_vr_help_title_present && !is_vr_help_present);
@@ -169,15 +172,6 @@ void SetGlobalPropertiesRequest::Run() {
smart_objects::SmartObject params =
smart_objects::SmartObject(smart_objects::SmartType_Map);
- if (ValidateVRHelpTitle(app->vr_help_title())) {
- LOG4CXX_DEBUG(logger_, "App already contains VRHelp data");
- } else {
- if (!PrepareUIRequestDefaultVRHelpData(app, params)) {
- LOG4CXX_ERROR(logger_, "default VRHElp data could not be generated");
- SendResponse(false, mobile_apis::Result::INVALID_DATA);
- return;
- }
- }
PrepareUIRequestMenuAndKeyboardData(app, msg_params, params);
// Preparing data
@@ -247,6 +241,9 @@ void SetGlobalPropertiesRequest::Run() {
params[strings::app_id] = app->app_id();
SendTTSRequest(params, true);
+
+ auto& help_prompt_manager = app->help_prompt_manager();
+ help_prompt_manager.OnSetGlobalPropertiesReceived(params, false);
}
}
@@ -276,6 +273,9 @@ void SetGlobalPropertiesRequest::on_event(const event_engine::Event& event) {
using namespace helpers;
const smart_objects::SmartObject& message = event.smart_object();
+ ApplicationSharedPtr application =
+ application_manager_.application(connection_key());
+
switch (event.id()) {
case hmi_apis::FunctionID::UI_SetGlobalProperties: {
LOG4CXX_INFO(logger_, "Received UI_SetGlobalProperties event");
@@ -284,6 +284,10 @@ void SetGlobalPropertiesRequest::on_event(const event_engine::Event& event) {
ui_result_ = static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
GetInfo(message, ui_response_info_);
+ if (application.valid()) {
+ auto& help_prompt_manager = application->help_prompt_manager();
+ help_prompt_manager.OnSetGlobalPropertiesReceived(message, true);
+ }
break;
}
case hmi_apis::FunctionID::TTS_SetGlobalProperties: {
@@ -293,6 +297,10 @@ void SetGlobalPropertiesRequest::on_event(const event_engine::Event& event) {
tts_result_ = static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
GetInfo(message, tts_response_info_);
+ if (application.valid()) {
+ auto& help_prompt_manager = application->help_prompt_manager();
+ help_prompt_manager.OnSetGlobalPropertiesReceived(message, true);
+ }
break;
}
default: {
@@ -309,10 +317,6 @@ void SetGlobalPropertiesRequest::on_event(const event_engine::Event& event) {
std::string response_info;
const bool result = PrepareResponseParameters(result_code, response_info);
- // TODO{ALeshin} APPLINK-15858. connection_key removed during SendResponse
- ApplicationSharedPtr application =
- application_manager_.application(connection_key());
-
SendResponse(result,
result_code,
response_info.empty() ? NULL : response_info.c_str(),
@@ -356,17 +360,6 @@ bool SetGlobalPropertiesRequest::PrepareResponseParameters(
return result;
}
-bool SetGlobalPropertiesRequest::ValidateVRHelpTitle(
- const smart_objects::SmartObject* const vr_help_so_ptr) {
- LOG4CXX_AUTO_TRACE(logger_);
- if (vr_help_so_ptr) {
- const std::string& vr_help = vr_help_so_ptr->asString();
- LOG4CXX_TRACE(logger_, "App contains vr_help_title: \"" << vr_help << '"');
- return !vr_help.empty();
- }
- return false;
-}
-
void SetGlobalPropertiesRequest::PrepareUIRequestVRHelpData(
const ApplicationSharedPtr app,
const smart_objects::SmartObject& msg_params,
@@ -381,41 +374,6 @@ void SetGlobalPropertiesRequest::PrepareUIRequestVRHelpData(
out_params[strings::vr_help] = (*app->vr_help());
}
-bool SetGlobalPropertiesRequest::PrepareUIRequestDefaultVRHelpData(
- const ApplicationSharedPtr app, smart_objects::SmartObject& out_params) {
- LOG4CXX_AUTO_TRACE(logger_);
- DCHECK_OR_RETURN(app, false);
-
- LOG4CXX_DEBUG(logger_, "Generate default VRHelp data");
- const DataAccessor<CommandsMap> accessor = app->commands_map();
- const CommandsMap& cmdMap = accessor.GetData();
-
- int32_t index = 0;
- smart_objects::SmartObject vr_help_items;
- for (CommandsMap::const_iterator command_it = cmdMap.begin();
- cmdMap.end() != command_it;
- ++command_it) {
- const smart_objects::SmartObject& command = *command_it->second;
- if (!command.keyExists(strings::vr_commands)) {
- LOG4CXX_ERROR(logger_, "VR synonyms are empty");
- return false;
- }
- // use only first
- vr_help_items[index][strings::position] = (index + 1);
- vr_help_items[index++][strings::text] =
- (*command_it->second)[strings::vr_commands][0];
- }
-
- app->set_vr_help_title(smart_objects::SmartObject(app->name()));
-
- out_params[strings::vr_help_title] = (*app->vr_help_title());
- if (vr_help_items.length() > 0) {
- app->set_vr_help(vr_help_items);
- out_params[strings::vr_help] = (*app->vr_help());
- }
- return true;
-}
-
void SetGlobalPropertiesRequest::PrepareUIRequestMenuAndKeyboardData(
const ApplicationSharedPtr app,
const smart_objects::SmartObject& msg_params,
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_command_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_command_request_test.cc
index 0067be3f1b..9f60053eb3 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_command_request_test.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_command_request_test.cc
@@ -49,6 +49,7 @@
#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_help_prompt_manager.h"
namespace test {
namespace components {
@@ -57,6 +58,7 @@ namespace mobile_commands_test {
namespace add_command_request {
namespace am = application_manager;
+namespace am_test = application_manager_test;
using am::commands::CommandImpl;
using am::ApplicationManager;
using am::commands::MessageSharedPtr;
@@ -104,6 +106,8 @@ class AddCommandRequestTest
: msg_(CreateMessage())
, default_app_name_("test_default_app_name_")
, lock_ptr_(std::make_shared<sync_primitives::Lock>())
+ , mock_help_prompt_manager_(
+ std::make_shared<am_test::MockHelpPromptManager>())
, mock_app_(CreateMockApp()) {
EXPECT_CALL(app_mngr_, application(kConnectionKey))
.WillRepeatedly(Return(mock_app_));
@@ -226,6 +230,7 @@ class AddCommandRequestTest
SmartObjectSPtr so_ptr_;
const utils::custom_string::CustomString default_app_name_;
std::shared_ptr<sync_primitives::Lock> lock_ptr_;
+ std::shared_ptr<am_test::MockHelpPromptManager> mock_help_prompt_manager_;
MockAppPtr mock_app_;
};
@@ -524,6 +529,12 @@ TEST_F(AddCommandRequestTest, OnEvent_UI_SUCCESS) {
mock_rpc_service_,
ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand)))
.WillOnce(Return(true));
+
+ EXPECT_CALL(*mock_app_, help_prompt_manager())
+ .WillOnce(ReturnRef(*mock_help_prompt_manager_));
+ EXPECT_CALL(*mock_help_prompt_manager_,
+ OnVrCommandAdded(kCmdId, (*msg_)[msg_params], false));
+
utils::SharedPtr<AddCommandRequest> request_ptr =
CreateCommand<AddCommandRequest>(msg_);
request_ptr->Run();
@@ -549,6 +560,12 @@ TEST_F(AddCommandRequestTest, OnEvent_VR_SUCCESS) {
mock_rpc_service_,
ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::VR_AddCommand)))
.WillOnce(Return(true));
+
+ EXPECT_CALL(*mock_app_, help_prompt_manager())
+ .WillOnce(ReturnRef(*mock_help_prompt_manager_));
+ EXPECT_CALL(*mock_help_prompt_manager_,
+ OnVrCommandAdded(kCmdId, (*msg_)[msg_params], false));
+
utils::SharedPtr<AddCommandRequest> request_ptr =
CreateCommand<AddCommandRequest>(msg_);
request_ptr->Run();
@@ -665,6 +682,11 @@ TEST_F(AddCommandRequestTest,
EXPECT_CALL(mock_rpc_service_,
ManageMobileCommand(
MobileResultCodeIs(mobile_apis::Result::WARNINGS), _));
+
+ EXPECT_CALL(*mock_app_, help_prompt_manager())
+ .WillOnce(ReturnRef(*mock_help_prompt_manager_));
+ EXPECT_CALL(*mock_help_prompt_manager_, OnVrCommandAdded(kCmdId, _, false));
+
utils::SharedPtr<AddCommandRequest> request_ptr =
CreateCommand<AddCommandRequest>(msg_);
request_ptr->Run();
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_command_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_command_request_test.cc
index ac8803c2ca..e3a4e0f381 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_command_request_test.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_command_request_test.cc
@@ -44,6 +44,7 @@
#include "application_manager/mock_application.h"
#include "application_manager/mock_message_helper.h"
#include "application_manager/mock_hmi_interface.h"
+#include "application_manager/mock_help_prompt_manager.h"
#include "application_manager/event_engine/event.h"
namespace test {
@@ -56,6 +57,7 @@ using ::testing::_;
using ::testing::Return;
using ::testing::ReturnRef;
namespace am = ::application_manager;
+namespace am_test = application_manager_test;
using sdl_rpc_plugin::commands::DeleteCommandRequest;
using am::commands::MessageSharedPtr;
using am::event_engine::Event;
@@ -74,7 +76,10 @@ const uint32_t kConnectionKey = 2u;
class DeleteCommandRequestTest
: public CommandRequestTest<CommandsTestMocks::kIsNice> {
public:
- DeleteCommandRequestTest() : mock_app_(CreateMockApp()) {}
+ DeleteCommandRequestTest()
+ : mock_help_prompt_manager_(
+ std::make_shared<am_test::MockHelpPromptManager>())
+ , mock_app_(CreateMockApp()) {}
MessageSharedPtr CreateFullParamsUISO() {
MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
(*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey;
@@ -132,6 +137,7 @@ class DeleteCommandRequestTest
}
NiceMock<MockHmiInterfaces> hmi_interfaces_;
+ std::shared_ptr<am_test::MockHelpPromptManager> mock_help_prompt_manager_;
MockAppPtr mock_app_;
};
@@ -188,6 +194,11 @@ TEST_F(DeleteCommandRequestTest,
ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL))
.WillOnce(DoAll(SaveArg<0>(&vr_command_result), Return(true)));
+ EXPECT_CALL(*mock_app_, help_prompt_manager())
+ .WillOnce(ReturnRef(*mock_help_prompt_manager_));
+ EXPECT_CALL(*mock_help_prompt_manager_,
+ OnVrCommandDeleted(kCommandId, false));
+
command->on_event(event_vr);
ResultCommandExpectations(vr_command_result, "VR is not supported by system");
@@ -241,6 +252,11 @@ TEST_F(DeleteCommandRequestTest,
EXPECT_CALL(*app, UpdateHash());
+ EXPECT_CALL(*app, help_prompt_manager())
+ .WillOnce(ReturnRef(*mock_help_prompt_manager_));
+ EXPECT_CALL(*mock_help_prompt_manager_,
+ OnVrCommandDeleted(kCommandId, false));
+
MessageSharedPtr result_msg(
CatchMobileCommandResult(CallOnEvent(*command, event_ui)));
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_sub_menu_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_sub_menu_test.cc
index 7a187c46d1..5dad433d6d 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_sub_menu_test.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_sub_menu_test.cc
@@ -43,6 +43,7 @@
#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_help_prompt_manager.h"
namespace test {
namespace components {
@@ -55,6 +56,7 @@ using ::testing::Return;
using ::testing::ReturnRef;
using ::testing::InSequence;
namespace am = ::application_manager;
+namespace am_test = application_manager_test;
using am::commands::MessageSharedPtr;
using am::event_engine::Event;
using am::MockHmiInterfaces;
@@ -99,6 +101,8 @@ class DeleteSubMenuRequestTest
, accessor_(commands_map_, commands_lock_)
, message_(CreateMessage())
, command_(CreateCommand<DeleteSubMenuRequest>(message_))
+ , mock_help_prompt_manager_(
+ std::make_shared<am_test::MockHelpPromptManager>())
, app_(CreateMockApp()) {}
am::CommandsMap commands_map_;
@@ -107,6 +111,7 @@ class DeleteSubMenuRequestTest
MessageSharedPtr message_;
DeleteSubMenuRequestPtr command_;
+ std::shared_ptr<am_test::MockHelpPromptManager> mock_help_prompt_manager_;
MockAppPtr app_;
};
@@ -276,6 +281,9 @@ TEST_F(DeleteSubMenuRequestTest, OnEvent_DeleteSubmenu_SUCCESS) {
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_, help_prompt_manager())
+ .WillOnce(ReturnRef(*mock_help_prompt_manager_));
+ EXPECT_CALL(*mock_help_prompt_manager_, OnVrCommandDeleted(kCmdId, false));
EXPECT_CALL(
mock_rpc_service_,
ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_DeleteCommand)))
@@ -287,6 +295,7 @@ TEST_F(DeleteSubMenuRequestTest, OnEvent_DeleteSubmenu_SUCCESS) {
ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS),
am::commands::Command::SOURCE_SDL));
EXPECT_CALL(*app_, UpdateHash());
+
DeleteSubMenuRequestPtr command =
CreateCommand<DeleteSubMenuRequest>(message_);
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_hmi_status_notification_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_hmi_status_notification_test.cc
index 034fff73d7..afb1574cbf 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_hmi_status_notification_test.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_hmi_status_notification_test.cc
@@ -118,45 +118,6 @@ TEST_F(OnHMIStatusNotificationTest, Run_InvalidEnum_SUCCESS) {
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);
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_global_properties_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_global_properties_test.cc
index 5d31f48970..f39ccf7be3 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_global_properties_test.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_global_properties_test.cc
@@ -39,6 +39,7 @@
#include "gtest/gtest.h"
#include "application_manager/commands/command_request_test.h"
#include "application_manager/mock_application.h"
+#include "application_manager/mock_help_prompt_manager.h"
#include "application_manager/mock_application_manager.h"
#include "application_manager/mock_message_helper.h"
#include "application_manager/event_engine/event.h"
@@ -76,7 +77,11 @@ class SetGlobalPropertiesRequestTest
public:
SetGlobalPropertiesRequestTest()
: lock_ptr_(std::make_shared<sync_primitives::Lock>())
- , mock_app_(CreateMockApp()) {}
+ , mock_app_(CreateMockApp()) {
+ mock_help_prompt_manager_ =
+ std::shared_ptr<application_manager_test::MockHelpPromptManager>(
+ new application_manager_test::MockHelpPromptManager());
+ }
MessageSharedPtr CreateFullParamsUISO() {
MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
@@ -140,6 +145,11 @@ class SetGlobalPropertiesRequestTest
EXPECT_CALL(*mock_app_, set_keyboard_props(_)).Times(0);
EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId));
+ EXPECT_CALL(*mock_app_, help_prompt_manager())
+ .WillRepeatedly(ReturnRef(*mock_help_prompt_manager_.get()));
+ EXPECT_CALL(*mock_help_prompt_manager_,
+ OnSetGlobalPropertiesReceived(_, false));
+
command->Run();
}
@@ -162,14 +172,17 @@ class SetGlobalPropertiesRequestTest
.WillOnce(Return(mobile_apis::Result::SUCCESS));
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_app_, help_prompt_manager())
+ .WillRepeatedly(ReturnRef(*mock_help_prompt_manager_.get()));
+ EXPECT_CALL(*mock_help_prompt_manager_,
+ OnSetGlobalPropertiesReceived(_, false));
+
command->Run();
}
@@ -252,6 +265,8 @@ class SetGlobalPropertiesRequestTest
}
std::shared_ptr<sync_primitives::Lock> lock_ptr_;
MockAppPtr mock_app_;
+ std::shared_ptr<application_manager_test::MockHelpPromptManager>
+ mock_help_prompt_manager_;
};
TEST_F(SetGlobalPropertiesRequestTest,
@@ -293,6 +308,12 @@ TEST_F(SetGlobalPropertiesRequestTest,
ON_CALL(mock_message_helper_, VerifyImage(_, _, _))
.WillByDefault(Return(mobile_apis::Result::SUCCESS));
+
+ EXPECT_CALL(*mock_app_, help_prompt_manager())
+ .WillRepeatedly(ReturnRef(*mock_help_prompt_manager_.get()));
+ EXPECT_CALL(*mock_help_prompt_manager_,
+ OnSetGlobalPropertiesReceived(_, false)).Times(2);
+
EXPECT_CALL(
mock_message_helper_,
VerifyTtsFiles(
@@ -312,6 +333,9 @@ TEST_F(SetGlobalPropertiesRequestTest,
event_vr.set_smart_object(*msg_vr);
command->Run();
+
+ EXPECT_CALL(*mock_help_prompt_manager_,
+ OnSetGlobalPropertiesReceived(_, true));
command->on_event(event_vr);
MessageSharedPtr ui_command_result;
@@ -319,6 +343,8 @@ TEST_F(SetGlobalPropertiesRequestTest,
mock_rpc_service_,
ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL))
.WillOnce(DoAll(SaveArg<0>(&ui_command_result), Return(true)));
+ EXPECT_CALL(*mock_help_prompt_manager_,
+ OnSetGlobalPropertiesReceived(_, true));
command->on_event(event);
@@ -339,6 +365,12 @@ TEST_F(SetGlobalPropertiesRequestTest, OnEvent_SUCCESS_Expect_MessageNotSend) {
MockAppPtr mock_app(CreateMockApp());
ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app));
+
+ EXPECT_CALL(*mock_app, help_prompt_manager())
+ .WillOnce(ReturnRef(*mock_help_prompt_manager_.get()));
+ EXPECT_CALL(*mock_help_prompt_manager_,
+ OnSetGlobalPropertiesReceived(_, true));
+
EXPECT_CALL(
mock_rpc_service_,
ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL))
@@ -367,6 +399,9 @@ TEST_F(SetGlobalPropertiesRequestTest,
EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
.WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
+ EXPECT_CALL(*mock_app_, help_prompt_manager())
+ .WillRepeatedly(ReturnRef(*mock_help_prompt_manager_.get()));
+
MessageSharedPtr response_to_mobile;
EXPECT_CALL(
mock_rpc_service_,
@@ -374,6 +409,9 @@ TEST_F(SetGlobalPropertiesRequestTest,
.WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true)));
command->Run();
+
+ EXPECT_CALL(*mock_help_prompt_manager_,
+ OnSetGlobalPropertiesReceived(_, true)).Times(2);
command->on_event(event_ui);
command->on_event(event_tts);
@@ -441,6 +479,11 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_VRWithMenuAndKeyboard_SUCCESS) {
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
.WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
+ EXPECT_CALL(*mock_app_, help_prompt_manager())
+ .WillOnce(ReturnRef(*mock_help_prompt_manager_.get()));
+ EXPECT_CALL(*mock_help_prompt_manager_,
+ OnSetGlobalPropertiesReceived(_, false));
+
SharedPtr<SetGlobalPropertiesRequest> command(
CreateCommand<SetGlobalPropertiesRequest>(msg));
@@ -586,8 +629,6 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_NoVR_SUCCESS) {
.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));
@@ -607,37 +648,6 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_NoVR_SUCCESS) {
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_ptr_);
- 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(
- mock_rpc_service_,
- ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::INVALID_DATA),
- am::commands::Command::SOURCE_SDL));
-
- command->Run();
-}
-
TEST_F(SetGlobalPropertiesRequestTest, Run_NoVRNoDataNoDefault_Canceled) {
MessageSharedPtr msg = CreateMsgParams();
SmartObject keyboard_properties(smart_objects::SmartType_Map);
@@ -648,17 +658,6 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_NoVRNoDataNoDefault_Canceled) {
.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_ptr_);
- 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(_));
@@ -688,23 +687,6 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_NoVRNoDataDefaultCreated_SUCCESS) {
.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_ptr_);
- 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));
@@ -723,50 +705,6 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_NoVRNoDataDefaultCreated_SUCCESS) {
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_ptr_);
- 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);
@@ -784,8 +722,6 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_TTSHelpAndTimeout_SUCCESS) {
EXPECT_CALL(mock_message_helper_, VerifyTtsFiles(timeout_prompt, _, _))
.WillOnce(Return(mobile_apis::Result::SUCCESS));
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));
@@ -800,6 +736,11 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_TTSHelpAndTimeout_SUCCESS) {
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS))
.WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
+ EXPECT_CALL(*mock_app_, help_prompt_manager())
+ .WillOnce(ReturnRef(*mock_help_prompt_manager_.get()));
+ EXPECT_CALL(*mock_help_prompt_manager_,
+ OnSetGlobalPropertiesReceived(_, false));
+
SharedPtr<SetGlobalPropertiesRequest> command(
CreateCommand<SetGlobalPropertiesRequest>(msg));
@@ -818,8 +759,6 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_TTSOnlyHelp_SUCCESS) {
EXPECT_CALL(mock_message_helper_, VerifyTtsFiles(help_prompt, _, _))
.WillOnce(Return(mobile_apis::Result::SUCCESS));
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);
@@ -832,6 +771,10 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_TTSOnlyHelp_SUCCESS) {
ON_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS))
.WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
+ EXPECT_CALL(*mock_app_, help_prompt_manager())
+ .WillOnce(ReturnRef(*mock_help_prompt_manager_.get()));
+ EXPECT_CALL(*mock_help_prompt_manager_,
+ OnSetGlobalPropertiesReceived(_, false));
SharedPtr<SetGlobalPropertiesRequest> command(
CreateCommand<SetGlobalPropertiesRequest>(msg));
@@ -850,8 +793,6 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_TTSOnlyTimeout_SUCCESS) {
EXPECT_CALL(mock_message_helper_, VerifyTtsFiles(timeout_prompt, _, _))
.WillOnce(Return(mobile_apis::Result::SUCCESS));
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));
@@ -864,6 +805,10 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_TTSOnlyTimeout_SUCCESS) {
ON_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS))
.WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
+ EXPECT_CALL(*mock_app_, help_prompt_manager())
+ .WillOnce(ReturnRef(*mock_help_prompt_manager_.get()));
+ EXPECT_CALL(*mock_help_prompt_manager_,
+ OnSetGlobalPropertiesReceived(_, false));
SharedPtr<SetGlobalPropertiesRequest> command(
CreateCommand<SetGlobalPropertiesRequest>(msg));
@@ -1055,6 +1000,11 @@ TEST_F(SetGlobalPropertiesRequestTest, OnEvent_PendingRequest_UNSUCCESS) {
Event event(hmi_apis::FunctionID::UI_SetGlobalProperties);
event.set_smart_object(*msg);
+ EXPECT_CALL(*mock_app_, help_prompt_manager())
+ .WillOnce(ReturnRef(*mock_help_prompt_manager_.get()));
+ EXPECT_CALL(*mock_help_prompt_manager_,
+ OnSetGlobalPropertiesReceived(_, true));
+
command->on_event(event);
}
@@ -1082,6 +1032,9 @@ TEST_F(SetGlobalPropertiesRequestTest, OnEvent_UIAndSuccessResultCode_SUCCESS) {
EXPECT_CALL(app_mngr_, application(kConnectionKey))
.WillOnce(Return(mock_app_));
+ EXPECT_CALL(*mock_help_prompt_manager_,
+ OnSetGlobalPropertiesReceived(_, true));
+
EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
.WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
EXPECT_CALL(mock_rpc_service_,
@@ -1114,6 +1067,8 @@ TEST_F(SetGlobalPropertiesRequestTest, OnEvent_UIAndWarningResultCode_SUCCESS) {
Event event(hmi_apis::FunctionID::UI_SetGlobalProperties);
event.set_smart_object(*msg);
+ EXPECT_CALL(*mock_help_prompt_manager_,
+ OnSetGlobalPropertiesReceived(_, true));
EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
.WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
EXPECT_CALL(mock_rpc_service_,
@@ -1159,7 +1114,7 @@ TEST_F(SetGlobalPropertiesRequestTest, OnEvent_InvalidEventID_Canceled) {
SharedPtr<SetGlobalPropertiesRequest> command(
CreateCommand<SetGlobalPropertiesRequest>(msg));
- EXPECT_CALL(app_mngr_, application(kConnectionKey)).Times(0);
+ EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(mock_app_));
EXPECT_CALL(*mock_app_, UpdateHash()).Times(0);
Event event(hmi_apis::FunctionID::TTS_Stopped);
@@ -1190,6 +1145,8 @@ TEST_F(SetGlobalPropertiesRequestTest,
EXPECT_CALL(mock_rpc_service_,
ManageMobileCommand(_, am::commands::Command::SOURCE_SDL))
.WillOnce(Return(true));
+ EXPECT_CALL(*mock_help_prompt_manager_,
+ OnSetGlobalPropertiesReceived(_, true));
EXPECT_CALL(app_mngr_, application(kConnectionKey))
.WillOnce(Return(mock_app_));
@@ -1221,6 +1178,9 @@ TEST_F(SetGlobalPropertiesRequestTest,
EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
.WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
+ EXPECT_CALL(*mock_app_, help_prompt_manager())
+ .WillOnce(ReturnRef(*mock_help_prompt_manager_.get()));
+
MessageSharedPtr ui_command_result;
EXPECT_CALL(
mock_rpc_service_,
@@ -1229,6 +1189,8 @@ TEST_F(SetGlobalPropertiesRequestTest,
EXPECT_CALL(app_mngr_, application(kConnectionKey))
.WillOnce(Return(mock_app_));
+ EXPECT_CALL(*mock_help_prompt_manager_,
+ OnSetGlobalPropertiesReceived(_, true));
Event event(hmi_apis::FunctionID::TTS_SetGlobalProperties);
event.set_smart_object(*msg);
diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc
index 2a2e13fc0d..717fbeba1b 100644
--- a/src/components/application_manager/src/application_impl.cc
+++ b/src/components/application_manager/src/application_impl.cc
@@ -126,6 +126,7 @@ ApplicationImpl::ApplicationImpl(
, device_id_(device_id)
, secondary_device_id_(0)
, usage_report_(mobile_app_id, statistics_manager)
+ , help_prompt_manager_impl_(*this, application_manager)
, protocol_version_(
protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_3)
, is_voice_communication_application_(false)
@@ -797,6 +798,10 @@ UsageStatistics& ApplicationImpl::usage_report() {
return usage_report_;
}
+HelpPromptManager& ApplicationImpl::help_prompt_manager() {
+ return help_prompt_manager_impl_;
+}
+
bool ApplicationImpl::AreCommandLimitsExceeded(
mobile_apis::FunctionID::eType cmd_id, TLimitSource source) {
TimevalStruct current = date_time::DateTime::getCurrentTime();
diff --git a/src/components/application_manager/src/help_prompt_manager_impl.cc b/src/components/application_manager/src/help_prompt_manager_impl.cc
new file mode 100644
index 0000000000..0587327791
--- /dev/null
+++ b/src/components/application_manager/src/help_prompt_manager_impl.cc
@@ -0,0 +1,396 @@
+/*
+ * Copyright (c) 2018, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include "application_manager/help_prompt_manager_impl.h"
+#include "application_manager/application.h"
+#include "application_manager/application_manager.h"
+#include "application_manager/commands/command_impl.h"
+#include "application_manager/message_helper.h"
+#include "application_manager/smart_object_keys.h"
+#include "smart_objects/smart_object.h"
+#include "utils/logger.h"
+#include "utils/make_shared.h"
+
+CREATE_LOGGERPTR_GLOBAL(logger_, "HelpPromptManagerImpl")
+
+namespace {
+const size_t kLimitCommand = 30;
+}
+
+namespace application_manager {
+
+HelpPromptManagerImpl::HelpPromptManagerImpl(Application& app,
+ ApplicationManager& app_manager)
+ : app_(app)
+ , app_manager_(app_manager)
+ , sending_type_(SendingType::kSendBoth)
+ , is_tts_send_(false)
+ , is_ui_send_(false) {}
+
+HelpPromptManagerImpl::~HelpPromptManagerImpl() {
+ LOG4CXX_AUTO_TRACE(logger_);
+}
+
+bool HelpPromptManagerImpl::AddCommand(
+ const uint32_t cmd_id, const smart_objects::SmartObject& command) {
+ if (!command.keyExists(strings::vr_commands)) {
+ LOG4CXX_DEBUG(logger_, "vr_commands does`t present");
+ return false;
+ }
+
+ sync_primitives::AutoLock lock(vr_commands_lock_);
+ auto it = std::find_if(
+ vr_commands_.begin(),
+ vr_commands_.end(),
+ [cmd_id](const VRCommandPair& pair) { return pair.first == cmd_id; });
+
+ if (vr_commands_.end() != it) {
+ LOG4CXX_DEBUG(logger_, "Commands with id:" << cmd_id << " already exists");
+ return false;
+ }
+
+ const smart_objects::SmartObject& commands = command[strings::vr_commands];
+ const size_t count_new_commands = commands.length();
+ const bool limit_exceeded =
+ kLimitCommand <= GetCommandsCount(vr_commands_.end());
+
+ LOG4CXX_DEBUG(logger_, "Will be added " << count_new_commands << " commands");
+
+ smart_objects::SmartObjectSPtr vr_item =
+ utils::MakeShared<smart_objects::SmartObject>(
+ smart_objects::SmartType_Array);
+ smart_objects::SmartArray& ar_vr_cmd = *(vr_item->asArray());
+ smart_objects::SmartArray& ar_cmd = *(commands.asArray());
+ ar_vr_cmd.reserve(count_new_commands);
+ ar_vr_cmd.insert(
+ ar_vr_cmd.end(), ar_cmd.begin(), ar_cmd.begin() + count_new_commands);
+ vr_commands_.push_back(std::make_pair(cmd_id, vr_item));
+
+ LOG4CXX_DEBUG(logger_,
+ "VR commands with id: " << cmd_id << " added for appID: "
+ << app_.app_id() << ". Total "
+ << vr_commands_.size() << " in cache");
+
+ return !limit_exceeded;
+}
+
+bool HelpPromptManagerImpl::DeleteCommand(const uint32_t cmd_id) {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ sync_primitives::AutoLock lock(vr_commands_lock_);
+
+ auto it = std::find_if(
+ vr_commands_.begin(),
+ vr_commands_.end(),
+ [cmd_id](const VRCommandPair& pair) { return pair.first == cmd_id; });
+
+ if (vr_commands_.end() == it) {
+ LOG4CXX_WARN(logger_, "VR command with id: " << cmd_id << " not found");
+ return false;
+ }
+
+ const size_t commands_before_current = GetCommandsCount(it);
+ vr_commands_.erase(it);
+ LOG4CXX_DEBUG(logger_,
+ "VR command with id: "
+ << cmd_id << " found after " << commands_before_current
+ << " commands was deleted for appID: " << app_.app_id()
+ << " Cache size after deleting: " << vr_commands_.size());
+
+ return commands_before_current < kLimitCommand;
+}
+
+void HelpPromptManagerImpl::OnVrCommandAdded(
+ const uint32_t cmd_id,
+ const smart_objects::SmartObject& command,
+ const bool is_resumption) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ if (SendingType::kNoneSend == sending_type_) {
+ LOG4CXX_DEBUG(logger_,
+ "SendingType::kNoneSend"
+ << " commands with id:" << cmd_id
+ << " will not be added");
+ return;
+ }
+ if (AddCommand(cmd_id, command) && !is_resumption) {
+ SendRequests();
+ }
+}
+
+void HelpPromptManagerImpl::OnVrCommandDeleted(const uint32_t cmd_id,
+ const bool is_resumption) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ if (SendingType::kNoneSend == sending_type_) {
+ LOG4CXX_DEBUG(logger_,
+ "SendingType::kNoneSend"
+ << " commands with id:" << cmd_id
+ << " will not be deleted");
+ return;
+ }
+ if (DeleteCommand(cmd_id) && !is_resumption) {
+ SendRequests();
+ }
+}
+
+void HelpPromptManagerImpl::OnSetGlobalPropertiesReceived(
+ const smart_objects::SmartObject& msg, const bool is_response) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ if (SendingType::kNoneSend == sending_type_) {
+ LOG4CXX_DEBUG(logger_,
+ "SendingType::kNoneSend"
+ " do not track SetGlobalProperties");
+ return;
+ }
+
+ if (!is_response) {
+ if (msg.keyExists(strings::help_prompt)) {
+ is_tts_send_ = true;
+ }
+ if (msg.keyExists(strings::vr_help)) {
+ is_ui_send_ = true;
+ }
+
+ LOG4CXX_DEBUG(logger_, "is_tts_send_:" << is_tts_send_);
+ LOG4CXX_DEBUG(logger_, "is_ui_send_:" << is_ui_send_);
+ return;
+ }
+
+ SetSendingType(msg);
+}
+
+HelpPromptManagerImpl::SendingType HelpPromptManagerImpl::GetSendingType()
+ const {
+ return sending_type_;
+}
+
+size_t HelpPromptManagerImpl::GetCommandsCount(
+ VRCommandPairs::const_iterator end_element) const {
+ size_t commands_count = 0;
+ std::for_each(vr_commands_.begin(),
+ end_element,
+ [&commands_count](const VRCommandPair& pair) {
+ commands_count += pair.second->length();
+ });
+ return commands_count;
+}
+
+void HelpPromptManagerImpl::SendTTSRequest() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ LOG4CXX_DEBUG(logger_, "TTS request for appID:" << app_.app_id());
+ smart_objects::SmartObjectSPtr tts_global_properties =
+ utils::MakeShared<smart_objects::SmartObject>(
+ smart_objects::SmartType_Map);
+ if (tts_global_properties) {
+ smart_objects::SmartObject& ref = *tts_global_properties;
+
+ ref[strings::params][strings::message_type] =
+ hmi_apis::messageType::request;
+ ref[strings::params][strings::protocol_version] =
+ commands::CommandImpl::protocol_version_;
+ ref[strings::params][strings::protocol_type] =
+ commands::CommandImpl::hmi_protocol_type_;
+ ref[strings::params][strings::correlation_id] =
+ app_manager_.GetNextHMICorrelationID();
+
+ smart_objects::SmartObject& so_to_send = *tts_global_properties;
+ so_to_send[strings::params][strings::function_id] =
+ hmi_apis::FunctionID::TTS_SetGlobalProperties;
+
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+
+ CreatePromptMsg(msg_params);
+
+ msg_params[strings::app_id] = app_.app_id();
+ so_to_send[strings::msg_params] = msg_params;
+ app_manager_.GetRPCService().ManageHMICommand(tts_global_properties);
+ }
+ is_tts_send_ = false;
+}
+
+void HelpPromptManagerImpl::SendUIRequest() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ LOG4CXX_DEBUG(logger_, "UI request for appID:" << app_.app_id());
+ smart_objects::SmartObjectSPtr ui_global_properties =
+ utils::MakeShared<smart_objects::SmartObject>(
+ smart_objects::SmartType_Map);
+ if (ui_global_properties) {
+ smart_objects::SmartObject& ref = *ui_global_properties;
+
+ ref[strings::params][strings::message_type] =
+ hmi_apis::messageType::request;
+ ref[strings::params][strings::protocol_version] =
+ commands::CommandImpl::protocol_version_;
+ ref[strings::params][strings::protocol_type] =
+ commands::CommandImpl::hmi_protocol_type_;
+ ref[strings::params][strings::correlation_id] =
+ app_manager_.GetNextHMICorrelationID();
+
+ smart_objects::SmartObject& so_to_send = *ui_global_properties;
+ so_to_send[strings::params][strings::function_id] =
+ hmi_apis::FunctionID::UI_SetGlobalProperties;
+
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+
+ CreateVRMsg(msg_params);
+
+ msg_params[strings::app_id] = app_.app_id();
+ so_to_send[strings::msg_params] = msg_params;
+ app_manager_.GetRPCService().ManageHMICommand(ui_global_properties);
+ }
+ is_ui_send_ = false;
+}
+
+void HelpPromptManagerImpl::SendBothRequests() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ SendTTSRequest();
+ SendUIRequest();
+}
+
+void HelpPromptManagerImpl::SendRequests() {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ sync_primitives::AutoLock lock(vr_commands_lock_);
+ switch (sending_type_) {
+ case SendingType::kSendHelpPrompt:
+ SendTTSRequest();
+ return;
+ case SendingType::kSendVRHelp:
+ SendUIRequest();
+ return;
+ case SendingType::kSendBoth:
+ SendBothRequests();
+ return;
+ case SendingType::kNoneSend:
+ break;
+ }
+ LOG4CXX_DEBUG(logger_,
+ "SendingType:" << static_cast<uint32_t>(sending_type_)
+ << " request not sending");
+}
+
+void HelpPromptManagerImpl::CreatePromptMsg(
+ smart_objects::SmartObject& out_msg_params) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ out_msg_params[strings::help_prompt] =
+ smart_objects::SmartObject(smart_objects::SmartType_Array);
+ uint32_t index = 0;
+ for (size_t i = 0; i < vr_commands_.size(); ++i) {
+ const VRCommandPair& pair = vr_commands_[i];
+ for (size_t j = 0; j < pair.second->length() && index < kLimitCommand;
+ ++j) {
+ smart_objects::SmartObject item(smart_objects::SmartType_Map);
+
+ item[strings::text] = pair.second->getElement(j).asString();
+ item[strings::type] = mobile_apis::SpeechCapabilities::SC_TEXT;
+
+ out_msg_params[strings::help_prompt][index++] = item;
+ }
+ }
+ app_.set_help_prompt(out_msg_params[strings::help_prompt]);
+}
+
+void HelpPromptManagerImpl::CreateVRMsg(
+ smart_objects::SmartObject& out_msg_params) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ if (false == out_msg_params.keyExists(strings::vr_help_title)) {
+ if (app_.vr_help_title()) {
+ out_msg_params[strings::vr_help_title] = (*app_.vr_help_title());
+ } else {
+ out_msg_params[strings::vr_help_title] = app_.name();
+ }
+ }
+ out_msg_params[strings::vr_help] =
+ smart_objects::SmartObject(smart_objects::SmartType_Array);
+ uint32_t index = 0;
+ for (size_t i = 0; i < vr_commands_.size(); ++i) {
+ const VRCommandPair& pair = vr_commands_[i];
+ for (size_t j = 0; j < pair.second->length() && index < kLimitCommand;
+ ++j) {
+ smart_objects::SmartObject item(smart_objects::SmartType_Map);
+
+ item[strings::text] = pair.second->getElement(j).asString();
+ item[strings::position] = index + 1;
+
+ out_msg_params[strings::vr_help][index++] = item;
+ }
+ }
+ if (out_msg_params[strings::vr_help].empty()) {
+ out_msg_params.erase(strings::vr_help);
+ app_.reset_vr_help();
+ } else {
+ app_.set_vr_help(out_msg_params[strings::vr_help]);
+ }
+}
+
+void HelpPromptManagerImpl::SetSendingType(
+ const smart_objects::SmartObject& msg) {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ hmi_apis::Common_Result::eType result =
+ static_cast<hmi_apis::Common_Result::eType>(
+ msg[strings::params][hmi_response::code].asInt());
+ LOG4CXX_DEBUG(logger_, "HMI response result:" << result);
+ if (hmi_apis::Common_Result::eType::SUCCESS == result) {
+ hmi_apis::FunctionID::eType function_id =
+ static_cast<hmi_apis::FunctionID::eType>(
+ msg[strings::params][strings::function_id].asUInt());
+ LOG4CXX_DEBUG(logger_, "Function id:" << function_id);
+ switch (function_id) {
+ case hmi_apis::FunctionID::TTS_SetGlobalProperties: {
+ if (is_tts_send_) {
+ is_tts_send_ = false;
+ sending_type_ = SendingType::kSendHelpPrompt == sending_type_
+ ? SendingType::kNoneSend
+ : SendingType::kSendVRHelp;
+ }
+ break;
+ }
+ case hmi_apis::FunctionID::UI_SetGlobalProperties: {
+ if (is_ui_send_) {
+ is_ui_send_ = false;
+ sending_type_ = SendingType::kSendVRHelp == sending_type_
+ ? SendingType::kNoneSend
+ : SendingType::kSendHelpPrompt;
+ }
+ break;
+ }
+ default: { break; }
+ }
+ LOG4CXX_DEBUG(
+ logger_,
+ "Sending type set to:" << static_cast<uint32_t>(sending_type_));
+ }
+}
+
+} // namespace application_manager
diff --git a/src/components/application_manager/src/helpers/application_helper.cc b/src/components/application_manager/src/helpers/application_helper.cc
index 66afd6b0b6..59f1c6caf2 100644
--- a/src/components/application_manager/src/helpers/application_helper.cc
+++ b/src/components/application_manager/src/helpers/application_helper.cc
@@ -21,6 +21,7 @@ void DeleteCommands(ApplicationSharedPtr app, ApplicationManager& app_manager) {
for (auto cmd : cmap) {
MessageHelper::SendDeleteCommandRequest(cmd.second, app, app_manager);
app->RemoveCommand(cmd.first);
+ app->help_prompt_manager().OnVrCommandDeleted(cmd.first, true);
}
}
diff --git a/src/components/application_manager/src/message_helper/message_helper.cc b/src/components/application_manager/src/message_helper/message_helper.cc
index 47bcffd3f5..81491b7bf9 100644
--- a/src/components/application_manager/src/message_helper/message_helper.cc
+++ b/src/components/application_manager/src/message_helper/message_helper.cc
@@ -1069,9 +1069,19 @@ MessageHelper::CreateGlobalPropertiesRequestsToHMI(
return requests;
}
+ auto& help_prompt_manager =
+ const_cast<Application*>(app.get())->help_prompt_manager();
+
+ const bool can_send_ui = helpers::Compare<HelpPromptManager::SendingType,
+ helpers::EQ,
+ helpers::ONE>(
+ help_prompt_manager.GetSendingType(),
+ HelpPromptManager::SendingType::kSendVRHelp,
+ HelpPromptManager::SendingType::kSendBoth);
+
// UI global properties
- if (app->vr_help_title() || app->vr_help()) {
+ if (can_send_ui && (app->vr_help_title() || app->vr_help())) {
smart_objects::SmartObjectSPtr ui_global_properties =
CreateMessageForHMI(hmi_apis::messageType::request, correlation_id);
if (!ui_global_properties) {
@@ -1105,8 +1115,15 @@ MessageHelper::CreateGlobalPropertiesRequestsToHMI(
requests.push_back(ui_global_properties);
}
+ const bool can_send_vr = helpers::Compare<HelpPromptManager::SendingType,
+ helpers::EQ,
+ helpers::ONE>(
+ help_prompt_manager.GetSendingType(),
+ HelpPromptManager::SendingType::kSendHelpPrompt,
+ HelpPromptManager::SendingType::kSendBoth);
+
// TTS global properties
- if (app->help_prompt() || app->timeout_prompt()) {
+ if (can_send_vr && (app->help_prompt() || app->timeout_prompt())) {
smart_objects::SmartObjectSPtr tts_global_properties =
CreateMessageForHMI(hmi_apis::messageType::request, correlation_id);
if (!tts_global_properties) {
diff --git a/src/components/application_manager/src/resumption/resume_ctrl_impl.cc b/src/components/application_manager/src/resumption/resume_ctrl_impl.cc
index 2cdab710f1..be2bff5534 100644
--- a/src/components/application_manager/src/resumption/resume_ctrl_impl.cc
+++ b/src/components/application_manager/src/resumption/resume_ctrl_impl.cc
@@ -625,8 +625,12 @@ void ResumeCtrlImpl::AddCommands(ApplicationSharedPtr application,
saved_app[strings::application_commands];
for (size_t i = 0; i < app_commands.length(); ++i) {
const smart_objects::SmartObject& command = app_commands[i];
+ const uint32_t cmd_id = command[strings::cmd_id].asUInt();
+ const bool is_resumption = true;
- application->AddCommand(command[strings::cmd_id].asUInt(), command);
+ application->AddCommand(cmd_id, command);
+ application->help_prompt_manager().OnVrCommandAdded(
+ cmd_id, command, is_resumption);
}
ProcessHMIRequests(MessageHelper::CreateAddCommandRequestToHMI(
application, application_manager_));
diff --git a/src/components/application_manager/test/CMakeLists.txt b/src/components/application_manager/test/CMakeLists.txt
index 579ffe8c1b..2a6c973bdc 100644..100755
--- a/src/components/application_manager/test/CMakeLists.txt
+++ b/src/components/application_manager/test/CMakeLists.txt
@@ -45,6 +45,7 @@ include_directories(
${COMPONENTS_DIR}/media_manager/include/
${COMPONENTS_DIR}/security_manager/include/
${COMPONENTS_DIR}/application_manager/test/include/
+ ${COMPONENTS_DIR}/application_manager/rpc_plugins/sdl_rpc_plugin/include/
${BSON_INCLUDE_DIRECTORY}
)
@@ -72,6 +73,10 @@ set(testSourcesMockHmi
${AM_TEST_DIR}/application_manager_impl_mock_hmi_test.cc
)
+set(testSourcesHelpPromptManager
+ ${AM_TEST_DIR}/help_prompt_manager_test.cc
+ ${AM_TEST_DIR}/mock_message_helper.cc
+)
set (RequestController_SOURCES
${AM_TEST_DIR}/request_controller/request_controller_test.cc
${AM_TEST_DIR}/mock_message_helper.cc
@@ -80,6 +85,7 @@ set (RequestController_SOURCES
set(LIBRARIES
Utils
ApplicationManager
+ sdl_rpc_plugin
jsoncpp
Policy
connectionHandler
@@ -131,6 +137,8 @@ create_test("application_manager_test" "${testSources}" "${LIBRARIES}")
create_test("application_manager_mock_hmi_test" "${testSourcesMockHmi}" "${LIBRARIES}")
#add_dependencies("application_manager_test" libbson)
+create_test("help_prompt_manager_test" "${testSourcesHelpPromptManager}" "${LIBRARIES}")
+
create_test("request_controller_test" "${RequestController_SOURCES}" "${LIBRARIES}")
set(ResumptionData_SOURCES
diff --git a/src/components/application_manager/test/help_prompt_manager_test.cc b/src/components/application_manager/test/help_prompt_manager_test.cc
new file mode 100644
index 0000000000..335e8e4f64
--- /dev/null
+++ b/src/components/application_manager/test/help_prompt_manager_test.cc
@@ -0,0 +1,369 @@
+/*
+ * Copyright (c) 2018, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "application_manager/application_impl.h"
+#include "application_manager/commands/command_request_test.h"
+#include "application_manager/commands/commands_test.h"
+#include "application_manager/hmi_state.h"
+#include "application_manager/mock_application.h"
+#include "application_manager/mock_event_dispatcher.h"
+#include "application_manager/mock_help_prompt_manager.h"
+#include "application_manager/mock_message_helper.h"
+#include "application_manager/mock_resumption_data.h"
+#include "connection_handler/mock_connection_handler.h"
+#include "gtest/gtest.h"
+#include "policy/usage_statistics/mock_statistics_manager.h"
+#include "protocol_handler/mock_session_observer.h"
+#include "sdl_rpc_plugin/commands/mobile/set_global_properties_request.h"
+#include "utils/file_system.h"
+
+namespace test {
+namespace components {
+namespace application_manager_test {
+
+namespace {
+const uint32_t kConnectionKey = 1u;
+const uint32_t kCorrelationKey = 2u;
+const uint32_t kAppId = 10u;
+const uint32_t kCmdId = 1u;
+const std::string kPolicyAppId = "fake_app_id";
+const uint32_t kTimeout = 10000u;
+const std::string kText = "one";
+const uint32_t kPosition = 1u;
+const std::string kFirstVrCommand = "first";
+const int32_t kGrammarId = 12;
+const std::string kDirectoryName = "./test_storage";
+const uint8_t expected_tread_pool_size = 2u;
+const uint8_t stop_streaming_timeout = 1u;
+const std::vector<std::string> kTimeoutPrompt{"timeoutPrompt"};
+} // namespace
+
+using namespace application_manager;
+using namespace policy;
+using namespace test::components::commands_test;
+using namespace mobile_apis;
+
+using am::HmiStatePtr;
+using sdl_rpc_plugin::commands::SetGlobalPropertiesRequest;
+using testing::_;
+using testing::Mock;
+using testing::NiceMock;
+using testing::Return;
+using testing::ReturnRef;
+using usage_statistics_test::MockStatisticsManager;
+
+class ApplicationImplTest : public ApplicationImpl {
+ public:
+ ApplicationImplTest(
+ uint32_t application_id,
+ const std::string& policy_app_id,
+ const std::string& mac_address,
+ const connection_handler::DeviceHandle device_id,
+ const custom_str::CustomString& app_name,
+ utils::SharedPtr<usage_statistics::StatisticsManager> statistics_manager,
+ ApplicationManager& application_manager,
+ MockHelpPromptManager& mock_help_prompt_manager)
+ : ApplicationImpl(application_id,
+ policy_app_id,
+ mac_address,
+ device_id,
+ app_name,
+ statistics_manager,
+ application_manager)
+ , mock_help_prompt_manager_(mock_help_prompt_manager) {}
+
+ HelpPromptManager& help_prompt_manager() OVERRIDE {
+ return mock_help_prompt_manager_;
+ }
+
+ private:
+ MockHelpPromptManager& mock_help_prompt_manager_;
+};
+
+class HelpPromptManagerTest : public ::testing::Test {
+ public:
+ HelpPromptManagerTest()
+ : mock_message_helper_(*MockMessageHelper::message_helper_mock()) {}
+ void SetUp() OVERRIDE;
+ void TearDown() OVERRIDE;
+ MessageSharedPtr CreateMsgParams();
+ void VRArraySetupHelper(MessageSharedPtr msg,
+ SmartObject& vr_help_title,
+ SmartObject& vr_help_array);
+ void CreateBasicParamsVRRequest(MessageSharedPtr msg);
+ void CreateApplication(MockHelpPromptManager& mock_help_prompt_manager);
+ HmiStatePtr CreateTestHmiState();
+
+ template <class Command>
+ SharedPtr<Command> CreateCommand(MessageSharedPtr& msg) {
+ return ::utils::MakeShared<Command>(msg,
+ app_mngr_,
+ mock_rpc_service_,
+ mock_hmi_capabilities_,
+ mock_policy_handler_);
+ }
+
+ protected:
+ typedef CommandsTest<CommandsTestMocks::kIsNice>::MockAppManager
+ MockAppManager;
+ MockAppManager app_mngr_;
+ utils::SharedPtr<ApplicationImplTest> app_impl_;
+ MockHmiInterfaces mock_hmi_interfaces_;
+ NiceMock<event_engine_test::MockEventDispatcher> mock_event_dispatcher_;
+ NiceMock<MockApplicationManagerSettings> app_mngr_settings_;
+ utils::SharedPtr<application_manager_test::MockApplication> mock_app_;
+ sync_primitives::Lock app_lock_;
+ MockRPCService mock_rpc_service_;
+ application_manager_test::MockHMICapabilities mock_hmi_capabilities_;
+ policy_test::MockPolicyHandlerInterface mock_policy_handler_;
+ MockMessageHelper& mock_message_helper_;
+ utils::SharedPtr<MockHelpPromptManager> mock_help_prompt_manager_;
+};
+
+void HelpPromptManagerTest::SetUp() {
+ ON_CALL(app_mngr_, hmi_interfaces())
+ .WillByDefault(ReturnRef(mock_hmi_interfaces_));
+ ON_CALL(mock_hmi_interfaces_, GetInterfaceFromFunction(_))
+ .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_SDL));
+ ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
+ .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
+
+ ON_CALL(app_mngr_, get_settings())
+ .WillByDefault(ReturnRef(app_mngr_settings_));
+ ON_CALL(app_mngr_, event_dispatcher())
+ .WillByDefault(ReturnRef(mock_event_dispatcher_));
+ ON_CALL(app_mngr_settings_, default_timeout())
+ .WillByDefault(ReturnRef(kTimeout));
+ ON_CALL(app_mngr_settings_, app_icons_folder())
+ .WillByDefault(ReturnRef(kDirectoryName));
+ ON_CALL(app_mngr_settings_, app_storage_folder())
+ .WillByDefault(ReturnRef(kDirectoryName));
+ ON_CALL(app_mngr_settings_, audio_data_stopped_timeout())
+ .WillByDefault(Return(0));
+ ON_CALL(app_mngr_settings_, video_data_stopped_timeout())
+ .WillByDefault(Return(0));
+
+ mock_help_prompt_manager_ =
+ utils::SharedPtr<MockHelpPromptManager>(new MockHelpPromptManager());
+
+ HmiStatePtr state = utils::MakeShared<HmiState>(
+ static_cast<utils::SharedPtr<Application> >(mock_app_),
+ app_mngr_,
+ HmiState::STATE_ID_REGULAR);
+
+ std::string path = file_system::CreateDirectory("storage");
+ file_system::CreateFile(path + "/" + "certificate");
+
+ mock_app_ = utils::MakeShared<application_manager_test::MockApplication>();
+}
+
+void HelpPromptManagerTest::TearDown() {
+ Mock::VerifyAndClearExpectations(&mock_message_helper_);
+}
+
+MessageSharedPtr HelpPromptManagerTest::CreateMsgParams() {
+ MessageSharedPtr msg =
+ ::utils::MakeShared<SmartObject>(smart_objects::SmartType_Map);
+ (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey;
+ (*msg)[am::strings::msg_params][am::strings::app_id] = kAppId;
+ return msg;
+}
+
+void HelpPromptManagerTest::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;
+}
+
+void HelpPromptManagerTest::CreateBasicParamsVRRequest(MessageSharedPtr msg) {
+ SmartObject& msg_params = (*msg)[strings::msg_params];
+ msg_params[strings::cmd_id] = kCmdId;
+ msg_params[strings::vr_commands] =
+ SmartObject(smart_objects::SmartType_Array);
+ msg_params[strings::vr_commands][0] = kFirstVrCommand;
+ msg_params[strings::type] = kPosition;
+ msg_params[strings::grammar_id] = kGrammarId;
+ msg_params[strings::info] = "VR info";
+}
+
+HmiStatePtr HelpPromptManagerTest::CreateTestHmiState() {
+ HmiStatePtr testState = utils::MakeShared<HmiState>(
+ static_cast<utils::SharedPtr<Application> >(app_impl_),
+ app_mngr_,
+ HmiState::STATE_ID_REGULAR);
+ testState->set_hmi_level(HMILevel::INVALID_ENUM);
+ testState->set_audio_streaming_state(AudioStreamingState::NOT_AUDIBLE);
+ testState->set_system_context(SystemContext::SYSCTXT_MAIN);
+ return testState;
+}
+
+void HelpPromptManagerTest::CreateApplication(
+ MockHelpPromptManager& mock_help_prompt_manager) {
+ const std::string policy_app_id = "p_app_id";
+ const std::string mac_address = "MA:CA:DD:RE:SS";
+ const connection_handler::DeviceHandle device_id = 1;
+ const custom_str::CustomString app_name("");
+
+ app_impl_.reset(
+ new ApplicationImplTest(kAppId,
+ policy_app_id,
+ mac_address,
+ device_id,
+ app_name,
+ utils::MakeShared<MockStatisticsManager>(),
+ app_mngr_,
+ mock_help_prompt_manager));
+ HmiStatePtr initial_state = CreateTestHmiState();
+ app_impl_->SetInitialState(initial_state);
+}
+
+TEST_F(HelpPromptManagerTest, AddCommand_OnVrCommandAdded) {
+ CreateApplication(*mock_help_prompt_manager_.get());
+ MessageSharedPtr msg =
+ ::utils::MakeShared<SmartObject>(smart_objects::SmartType_Map);
+ CreateBasicParamsVRRequest(msg);
+ (*msg)[strings::params][hmi_response::code] =
+ hmi_apis::Common_Result::SUCCESS;
+ (*msg)[strings::msg_params][strings::cmd_id] = kCmdId;
+
+ app_impl_->AddCommand(kCmdId, (*msg)[strings::msg_params]);
+}
+
+TEST_F(HelpPromptManagerTest, RemoveCommand_OnVrCommandDeleted) {
+ CreateApplication(*mock_help_prompt_manager_.get());
+ MessageSharedPtr msg =
+ ::utils::MakeShared<SmartObject>(smart_objects::SmartType_Map);
+ CreateBasicParamsVRRequest(msg);
+ (*msg)[strings::params][hmi_response::code] =
+ hmi_apis::Common_Result::SUCCESS;
+ (*msg)[strings::msg_params][strings::cmd_id] = kCmdId;
+
+ app_impl_->AddCommand(kCmdId, (*msg)[strings::msg_params]);
+ app_impl_->RemoveCommand(kCmdId);
+}
+
+TEST_F(HelpPromptManagerTest,
+ Request_OnSetGlobalPropertiesReceived_TTS_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(mock_message_helper_, VerifyImageVrHelpItems(_, _, _)).Times(0);
+ EXPECT_CALL(mock_message_helper_, VerifyTtsFiles(help_prompt, _, _))
+ .WillOnce(Return(mobile_apis::Result::SUCCESS));
+ EXPECT_CALL(mock_message_helper_, VerifyTtsFiles(timeout_prompt, _, _))
+ .WillOnce(Return(mobile_apis::Result::SUCCESS));
+
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(mock_app_));
+ EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey));
+
+ EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId));
+ 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_hmi_interfaces_,
+ GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_SetGlobalProperties))
+ .WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_TTS));
+
+ EXPECT_CALL(*mock_app_, help_prompt_manager())
+ .WillOnce(ReturnRef(*mock_help_prompt_manager_.get()));
+ EXPECT_CALL(*mock_help_prompt_manager_,
+ OnSetGlobalPropertiesReceived(_, false));
+
+ SharedPtr<SetGlobalPropertiesRequest> command(
+ CreateCommand<SetGlobalPropertiesRequest>(msg));
+
+ command->Run();
+}
+
+TEST_F(HelpPromptManagerTest,
+ Request_OnSetGlobalPropertiesReceived_UI_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(app_mngr_, application(kConnectionKey))
+ .WillRepeatedly(Return(mock_app_));
+
+ 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));
+
+ EXPECT_CALL(*mock_app_, help_prompt_manager())
+ .WillOnce(ReturnRef(*mock_help_prompt_manager_.get()));
+ EXPECT_CALL(*mock_help_prompt_manager_,
+ OnSetGlobalPropertiesReceived(_, false));
+
+ SharedPtr<SetGlobalPropertiesRequest> command(
+ CreateCommand<SetGlobalPropertiesRequest>(msg));
+
+ command->Run();
+}
+
+} // namespace application_manager_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/include/application_manager/mock_application.h b/src/components/application_manager/test/include/application_manager/mock_application.h
index 626931dcf9..47a39d742c 100644
--- a/src/components/application_manager/test/include/application_manager/mock_application.h
+++ b/src/components/application_manager/test/include/application_manager/mock_application.h
@@ -162,6 +162,10 @@ class MockApplication : public ::application_manager::Application {
bool(mobile_apis::FunctionID::eType cmd_id,
::application_manager::TLimitSource source));
MOCK_METHOD0(usage_report, ::application_manager::UsageStatistics&());
+ MOCK_METHOD0(help_prompt_manager,
+ ::application_manager::HelpPromptManager&());
+ MOCK_CONST_METHOD0(help_prompt_manager,
+ const ::application_manager::HelpPromptManager&());
MOCK_METHOD1(SetInitialState, void(::application_manager::HmiStatePtr state));
MOCK_METHOD1(SetRegularState, void(::application_manager::HmiStatePtr state));
MOCK_METHOD1(SetPostponedState,
diff --git a/src/components/application_manager/test/include/application_manager/mock_help_prompt_manager.h b/src/components/application_manager/test/include/application_manager/mock_help_prompt_manager.h
new file mode 100644
index 0000000000..a415f94d56
--- /dev/null
+++ b/src/components/application_manager/test/include/application_manager/mock_help_prompt_manager.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2018, Ford Motor Company
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+*
+* Redistributions of source code must retain the above copyright notice, this
+* list of conditions and the following disclaimer.
+*
+* Redistributions in binary form must reproduce the above copyright notice,
+* this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided with the
+* distribution.
+*
+* Neither the name of the Ford Motor Company nor the names of its contributors
+* may be used to endorse or promote products derived from this software
+* without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+* POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_HELP_PROMPT_MANAGER_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_HELP_PROMPT_MANAGER_H_
+#include "gmock/gmock.h"
+
+namespace test {
+namespace components {
+namespace application_manager_test {
+
+using namespace application_manager;
+
+class MockHelpPromptManager : public ::application_manager::HelpPromptManager {
+ public:
+ MockHelpPromptManager() {}
+ MOCK_METHOD3(OnVrCommandAdded,
+ void(uint32_t cmd_id,
+ const smart_objects::SmartObject& command,
+ const bool should_send_requests));
+ MOCK_METHOD2(OnVrCommandDeleted,
+ void(uint32_t cmd_id, const bool should_send_requests));
+ MOCK_METHOD2(OnSetGlobalPropertiesReceived,
+ void(const smart_objects::SmartObject& msg, bool is_response));
+ MOCK_CONST_METHOD0(GetSendingType, SendingType());
+};
+
+} // namespace application_manager_test
+} // namespace components
+} // namespace test
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_HELP_PROMPT_MANAGER_H_
diff --git a/src/components/application_manager/test/message_helper/message_helper_test.cc b/src/components/application_manager/test/message_helper/message_helper_test.cc
index e43348cc80..0e48d39e24 100644
--- a/src/components/application_manager/test/message_helper/message_helper_test.cc
+++ b/src/components/application_manager/test/message_helper/message_helper_test.cc
@@ -38,6 +38,7 @@
#include "utils/make_shared.h"
#include "application_manager/policies/policy_handler.h"
#include "application_manager/mock_application.h"
+#include "application_manager/mock_help_prompt_manager.h"
#include "utils/custom_string.h"
#include "utils/lock.h"
#include "policy/mock_policy_settings.h"
@@ -148,6 +149,13 @@ TEST(MessageHelperTestCreate,
EXPECT_CALL(*appSharedMock, help_prompt()).Times(AtLeast(1));
EXPECT_CALL(*appSharedMock, timeout_prompt()).Times(AtLeast(1));
+ std::shared_ptr<MockHelpPromptManager> mock_help_prompt_manager =
+ std::make_shared<MockHelpPromptManager>();
+ EXPECT_CALL(*appSharedMock, help_prompt_manager())
+ .WillRepeatedly(ReturnRef(*mock_help_prompt_manager));
+ EXPECT_CALL(*mock_help_prompt_manager, GetSendingType())
+ .WillRepeatedly(Return(HelpPromptManager::SendingType::kSendBoth));
+
smart_objects::SmartObjectList ptr =
MessageHelper::CreateGlobalPropertiesRequestsToHMI(appSharedMock, 0u);
@@ -191,6 +199,13 @@ TEST(MessageHelperTestCreate,
.WillRepeatedly(Return(&(*objPtr)[4]));
EXPECT_CALL(*appSharedMock, app_id()).WillRepeatedly(Return(0));
+ std::shared_ptr<MockHelpPromptManager> mock_help_prompt_manager =
+ std::make_shared<MockHelpPromptManager>();
+ EXPECT_CALL(*appSharedMock, help_prompt_manager())
+ .WillRepeatedly(ReturnRef(*mock_help_prompt_manager));
+ EXPECT_CALL(*mock_help_prompt_manager, GetSendingType())
+ .WillRepeatedly(Return(HelpPromptManager::SendingType::kSendBoth));
+
smart_objects::SmartObjectList ptr =
MessageHelper::CreateGlobalPropertiesRequestsToHMI(appSharedMock, 0u);
diff --git a/src/components/application_manager/test/resumption/resume_ctrl_test.cc b/src/components/application_manager/test/resumption/resume_ctrl_test.cc
index 4a99c75c5b..f126e95e33 100644
--- a/src/components/application_manager/test/resumption/resume_ctrl_test.cc
+++ b/src/components/application_manager/test/resumption/resume_ctrl_test.cc
@@ -38,6 +38,7 @@
#include "application_manager/usage_statistics.h"
#include "application_manager/mock_application.h"
#include "application_manager/mock_app_extension.h"
+#include "application_manager/mock_help_prompt_manager.h"
#include "application_manager/mock_resumption_data.h"
#include "interfaces/MOBILE_API.h"
#include "application_manager/application_manager_impl.h"
@@ -98,6 +99,8 @@ class ResumeCtrlTest : public ::testing::Test {
::utils::MakeShared<NiceMock<resumption_test::MockResumptionData> >(
mock_app_mngr_);
mock_app_ = utils::MakeShared<NiceMock<MockApplication> >();
+ mock_help_prompt_manager_ =
+ std::shared_ptr<MockHelpPromptManager>(new MockHelpPromptManager());
mock_app_extension_ = utils::MakeShared<
NiceMock<application_manager_test::MockAppExtension> >();
const_app_ =
@@ -158,6 +161,7 @@ class ResumeCtrlTest : public ::testing::Test {
utils::SharedPtr<NiceMock<resumption_test::MockResumptionData> >
mock_storage_;
utils::SharedPtr<NiceMock<MockApplication> > mock_app_;
+ std::shared_ptr<MockHelpPromptManager> mock_help_prompt_manager_;
application_manager::ApplicationConstSharedPtr const_app_;
const uint32_t kTestAppId_;
const std::string kTestPolicyAppId_;
@@ -348,9 +352,13 @@ TEST_F(ResumeCtrlTest, StartResumption_AppWithCommands) {
.WillByDefault(DoAll(SetArgReferee<2>(saved_app), Return(true)));
EXPECT_CALL(*mock_app_, UpdateHash());
EXPECT_CALL(*mock_app_, set_grammar_id(kTestGrammarId_));
+ ON_CALL(*mock_app_, help_prompt_manager())
+ .WillByDefault(ReturnRef(*mock_help_prompt_manager_));
for (uint32_t i = 0; i < count_of_commands; ++i) {
EXPECT_CALL(*mock_app_, AddCommand(i, test_application_commands[i]));
+ EXPECT_CALL(*mock_help_prompt_manager_,
+ OnVrCommandAdded(i, test_application_commands[i], true));
}
smart_objects::SmartObjectList requests;
@@ -609,9 +617,16 @@ TEST_F(ResumeCtrlTest, StartAppHmiStateResumption_AppInFull) {
saved_app[application_manager::strings::ign_off_count] = ign_off_count;
saved_app[application_manager::strings::hmi_level] = restored_test_type;
+ application_manager::CommandsMap command;
+ DataAccessor<application_manager::CommandsMap> data_accessor(
+ command, app_set_lock_ptr_);
+
EXPECT_CALL(mock_state_controller_, SetRegularState(_, restored_test_type))
.Times(AtLeast(1));
GetInfoFromApp();
+ EXPECT_CALL(mock_app_mngr_, GetDefaultHmiLevel(const_app_))
+ .WillRepeatedly(Return(kDefaultTestLevel_));
+ EXPECT_CALL(*mock_app_, commands_map()).WillRepeatedly(Return(data_accessor));
ON_CALL(*mock_storage_,
GetSavedApplication(kTestPolicyAppId_, kMacAddress_, _))
.WillByDefault(DoAll(SetArgReferee<2>(saved_app), Return(true)));
@@ -769,6 +784,10 @@ TEST_F(
TEST_F(ResumeCtrlTest, RestoreAppHMIState_RestoreHMILevelFull) {
mobile_apis::HMILevel::eType restored_test_type = eType::HMI_FULL;
+ ::application_manager::CommandsMap command;
+ DataAccessor<application_manager::CommandsMap> data_accessor(
+ command, app_set_lock_ptr_);
+
smart_objects::SmartObject saved_app;
saved_app[application_manager::strings::hash_id] = kHash_;
saved_app[application_manager::strings::grammar_id] = kTestGrammarId_;
@@ -777,6 +796,9 @@ TEST_F(ResumeCtrlTest, RestoreAppHMIState_RestoreHMILevelFull) {
EXPECT_CALL(mock_state_controller_, SetRegularState(_, restored_test_type))
.Times(AtLeast(1));
GetInfoFromApp();
+ EXPECT_CALL(mock_app_mngr_, GetDefaultHmiLevel(const_app_))
+ .WillRepeatedly(Return(kDefaultTestLevel_));
+ EXPECT_CALL(*mock_app_, commands_map()).WillRepeatedly(Return(data_accessor));
ON_CALL(*mock_storage_,
GetSavedApplication(kTestPolicyAppId_, kMacAddress_, _))
.WillByDefault(DoAll(SetArgReferee<2>(saved_app), Return(true)));
@@ -841,6 +863,10 @@ TEST_F(ResumeCtrlTest, ApplicationResumptiOnTimer_AppInFull) {
ON_CALL(mock_app_mngr_, application(kTestAppId_))
.WillByDefault(Return(mock_app_));
+ ::application_manager::CommandsMap command;
+ DataAccessor<application_manager::CommandsMap> data_accessor(
+ command, app_set_lock_ptr_);
+
mobile_apis::HMILevel::eType restored_test_type = eType::HMI_FULL;
const uint32_t ign_off_count = 0u;
smart_objects::SmartObject saved_app;
@@ -853,6 +879,9 @@ TEST_F(ResumeCtrlTest, ApplicationResumptiOnTimer_AppInFull) {
EXPECT_CALL(state_controller, SetRegularState(_, restored_test_type))
.Times(AtLeast(1));
GetInfoFromApp();
+ EXPECT_CALL(mock_app_mngr_, GetDefaultHmiLevel(const_app_))
+ .WillRepeatedly(Return(kDefaultTestLevel_));
+ EXPECT_CALL(*mock_app_, commands_map()).WillRepeatedly(Return(data_accessor));
ON_CALL(*mock_storage_,
GetSavedApplication(kTestPolicyAppId_, kMacAddress_, _))
.WillByDefault(DoAll(SetArgReferee<2>(saved_app), Return(true)));