Skip to content

Commit 000e14c

Browse files
iCollinv-malko4
andauthored
Fix bug ResetGlobalProperties (#2337)
Fix bug `ResetGlobalProperties` does't reset `HELPPROMPT` and `VRHELPITEMS` to default values Fix UT's after bugfixing - Fix `ResetGlobalPropertiesRequestTest` - Add mock function into `MockApplicationManagerSettings` Github issue #1306 Co-authored-by: v-malko4 <vmalkov@luxoft.com>
1 parent 9cc81b7 commit 000e14c

File tree

5 files changed

+100
-2
lines changed

5 files changed

+100
-2
lines changed

src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/reset_global_properties_request.cc

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,21 @@ bool ResetGlobalPropertiesRequest::ResetHelpPromt(
198198
SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
199199
return false;
200200
}
201+
const std::vector<std::string>& help_prompt =
202+
application_manager_.get_settings().help_prompt();
203+
201204
smart_objects::SmartObject so_help_prompt =
202205
smart_objects::SmartObject(smart_objects::SmartType_Array);
206+
207+
for (size_t i = 0; i < help_prompt.size(); ++i) {
208+
smart_objects::SmartObject help_prompt_item =
209+
smart_objects::SmartObject(smart_objects::SmartType_Map);
210+
help_prompt_item[strings::text] = help_prompt[i];
211+
help_prompt_item[strings::type] =
212+
hmi_apis::Common_SpeechCapabilities::SC_TEXT;
213+
so_help_prompt[i] = help_prompt_item;
214+
}
215+
203216
app->set_help_prompt(so_help_prompt);
204217
return true;
205218
}
@@ -218,7 +231,7 @@ bool ResetGlobalPropertiesRequest::ResetTimeoutPromt(
218231
smart_objects::SmartObject so_time_out_promt =
219232
smart_objects::SmartObject(smart_objects::SmartType_Array);
220233

221-
for (uint32_t i = 0; i < time_out_promt.size(); ++i) {
234+
for (size_t i = 0; i < time_out_promt.size(); ++i) {
222235
smart_objects::SmartObject timeoutPrompt =
223236
smart_objects::SmartObject(smart_objects::SmartType_Map);
224237
timeoutPrompt[strings::text] = time_out_promt[i];
@@ -238,8 +251,16 @@ bool ResetGlobalPropertiesRequest::ResetVrHelpTitleItems(
238251
SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
239252
return false;
240253
}
254+
255+
const std::string& vr_help_title =
256+
application_manager_.get_settings().vr_help_title();
257+
smart_objects::SmartObject so_vr_help_title =
258+
smart_objects::SmartObject(smart_objects::SmartType_String);
259+
so_vr_help_title[strings::vr_help_title] = vr_help_title;
260+
241261
app->reset_vr_help_title();
242262
app->reset_vr_help();
263+
app->set_vr_help_title(so_vr_help_title);
243264

244265
return true;
245266
}

src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/reset_global_properties_test.cc

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,21 @@ TEST_F(ResetGlobalPropertiesRequestTest, Run_InvalidVrHelp_UNSUCCESS) {
139139
mobile_apis::GlobalProperty::KEYBOARDPROPERTIES;
140140

141141
EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey));
142+
std::vector<std::string> help_prompt = {"help_prompt"};
143+
144+
EXPECT_CALL(app_mngr_settings_, help_prompt())
145+
.WillOnce(ReturnRef(help_prompt));
146+
147+
smart_objects::SmartObject help_prompt_ =
148+
smart_objects::SmartObject(smart_objects::SmartType_Map);
149+
help_prompt_[am::strings::text] = help_prompt[0];
150+
help_prompt_[am::strings::type] =
151+
hmi_apis::Common_SpeechCapabilities::SC_TEXT;
152+
142153
smart_objects::SmartObject so_prompt =
143154
smart_objects::SmartObject(smart_objects::SmartType_Array);
155+
so_prompt[0] = help_prompt_;
156+
144157
EXPECT_CALL(*mock_app_, set_help_prompt(so_prompt));
145158

146159
std::vector<std::string> time_out_prompt;
@@ -161,6 +174,15 @@ TEST_F(ResetGlobalPropertiesRequestTest, Run_InvalidVrHelp_UNSUCCESS) {
161174

162175
EXPECT_CALL(*mock_app_, set_timeout_prompt(so_time_out_prompt));
163176

177+
std::string vr_help_title("vr_help_title");
178+
EXPECT_CALL(app_mngr_settings_, vr_help_title())
179+
.WillOnce(ReturnRef(vr_help_title));
180+
181+
smart_objects::SmartObject so_vr_help_title =
182+
smart_objects::SmartObject(smart_objects::SmartType_String);
183+
so_vr_help_title[am::strings::vr_help_title] = vr_help_title;
184+
EXPECT_CALL(*mock_app_, set_vr_help_title(so_vr_help_title));
185+
164186
EXPECT_CALL(*mock_app_, reset_vr_help_title());
165187
EXPECT_CALL(*mock_app_, reset_vr_help());
166188

@@ -190,8 +212,21 @@ TEST_F(ResetGlobalPropertiesRequestTest, Run_SUCCESS) {
190212
mobile_apis::GlobalProperty::KEYBOARDPROPERTIES;
191213

192214
EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey));
215+
216+
std::vector<std::string> help_prompt = {"help_prompt"};
217+
218+
EXPECT_CALL(app_mngr_settings_, help_prompt())
219+
.WillOnce(ReturnRef(help_prompt));
220+
221+
smart_objects::SmartObject help_prompt_ =
222+
smart_objects::SmartObject(smart_objects::SmartType_Map);
223+
help_prompt_[am::strings::text] = help_prompt[0];
224+
help_prompt_[am::strings::type] =
225+
hmi_apis::Common_SpeechCapabilities::SC_TEXT;
226+
193227
smart_objects::SmartObject so_prompt =
194228
smart_objects::SmartObject(smart_objects::SmartType_Array);
229+
so_prompt[0] = help_prompt_;
195230
EXPECT_CALL(*mock_app_, set_help_prompt(so_prompt));
196231

197232
std::vector<std::string> time_out_prompt;
@@ -212,6 +247,15 @@ TEST_F(ResetGlobalPropertiesRequestTest, Run_SUCCESS) {
212247

213248
EXPECT_CALL(*mock_app_, set_timeout_prompt(so_time_out_prompt));
214249

250+
std::string vr_help_title("vr_help_title");
251+
EXPECT_CALL(app_mngr_settings_, vr_help_title())
252+
.WillOnce(ReturnRef(vr_help_title));
253+
254+
smart_objects::SmartObject so_vr_help_title =
255+
smart_objects::SmartObject(smart_objects::SmartType_String);
256+
so_vr_help_title[am::strings::vr_help_title] = vr_help_title;
257+
EXPECT_CALL(*mock_app_, set_vr_help_title(so_vr_help_title));
258+
215259
EXPECT_CALL(*mock_app_, reset_vr_help_title());
216260
EXPECT_CALL(*mock_app_, reset_vr_help());
217261

@@ -267,6 +311,15 @@ TEST_F(ResetGlobalPropertiesRequestTest,
267311
(*msg_)[am::strings::msg_params][am::strings::properties][0] =
268312
mobile_apis::GlobalProperty::VRHELPTITLE;
269313

314+
std::string vr_help_title("vr_help_title");
315+
EXPECT_CALL(app_mngr_settings_, vr_help_title())
316+
.WillOnce(ReturnRef(vr_help_title));
317+
318+
smart_objects::SmartObject so_vr_help_title =
319+
smart_objects::SmartObject(smart_objects::SmartType_String);
320+
so_vr_help_title[am::strings::vr_help_title] = vr_help_title;
321+
EXPECT_CALL(*mock_app_, set_vr_help_title(so_vr_help_title));
322+
270323
EXPECT_CALL(*mock_app_, reset_vr_help_title());
271324
EXPECT_CALL(*mock_app_, reset_vr_help());
272325
EXPECT_CALL(*mock_app_, set_reset_global_properties_active(true));
@@ -363,6 +416,15 @@ TEST_F(ResetGlobalPropertiesRequestTest, OnEvent_InvalidApp_NoHashUpdate) {
363416
(*msg_)[am::strings::msg_params][am::strings::properties][0] =
364417
mobile_apis::GlobalProperty::VRHELPTITLE;
365418

419+
std::string vr_help_title("vr_help_title");
420+
EXPECT_CALL(app_mngr_settings_, vr_help_title())
421+
.WillOnce(ReturnRef(vr_help_title));
422+
423+
smart_objects::SmartObject so_vr_help_title =
424+
smart_objects::SmartObject(smart_objects::SmartType_String);
425+
so_vr_help_title[am::strings::vr_help_title] = vr_help_title;
426+
EXPECT_CALL(*mock_app_, set_vr_help_title(so_vr_help_title));
427+
366428
EXPECT_CALL(*mock_app_, reset_vr_help_title());
367429
EXPECT_CALL(*mock_app_, reset_vr_help());
368430

src/components/application_manager/src/message_helper/message_helper.cc

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1316,9 +1316,20 @@ smart_objects::SmartObjectSPtr MessageHelper::CreateAppVrHelp(
13161316
return NULL;
13171317
}
13181318
smart_objects::SmartObject& vr_help = *result;
1319-
vr_help[strings::vr_help_title] = app->name();
1319+
const smart_objects::SmartObject* vr_help_title = app->vr_help_title();
1320+
if (vr_help_title &&
1321+
vr_help_title->keyExists(strings::vr_help_title)) {
1322+
vr_help[strings::vr_help_title] =
1323+
(*vr_help_title)[strings::vr_help_title].asString();
1324+
}
13201325

13211326
int32_t index = 0;
1327+
1328+
smart_objects::SmartObject so_vr_help(smart_objects::SmartType_Map);
1329+
so_vr_help[strings::position] = index + 1;
1330+
so_vr_help[strings::text] = app->name();
1331+
vr_help[strings::vr_help][index++] = so_vr_help;
1332+
13221333
if (app->vr_synonyms()) {
13231334
smart_objects::SmartObject item(smart_objects::SmartType_Map);
13241335
item[strings::text] = (*(app->vr_synonyms())).getElement(0);

src/components/include/application_manager/application_manager_settings.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ class ApplicationManagerSettings : public RequestControlerSettings,
7272
virtual const std::string& tts_delimiter() const = 0;
7373
virtual const uint32_t& put_file_in_none() const = 0;
7474
virtual const std::string& sdl_version() const = 0;
75+
virtual const std::string& vr_help_title() const = 0;
7576
virtual const std::vector<std::string>& time_out_promt() const = 0;
77+
virtual const std::vector<std::string>& help_prompt() const = 0;
7678
virtual const std::string& hmi_capabilities_file_name() const = 0;
7779
virtual const std::string& video_server_type() const = 0;
7880
virtual const std::string& audio_server_type() const = 0;

src/components/include/test/application_manager/mock_application_manager_settings.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ class MockApplicationManagerSettings
7878
MOCK_CONST_METHOD0(tts_delimiter, const std::string&());
7979
MOCK_CONST_METHOD0(put_file_in_none, const uint32_t&());
8080
MOCK_CONST_METHOD0(sdl_version, const std::string&());
81+
MOCK_CONST_METHOD0(vr_help_title, const std::string&());
82+
MOCK_CONST_METHOD0(help_prompt, const std::vector<std::string>&());
8183
MOCK_CONST_METHOD0(time_out_promt, const std::vector<std::string>&());
8284
MOCK_CONST_METHOD0(hmi_capabilities_file_name, const std::string&());
8385
MOCK_CONST_METHOD0(video_server_type, const std::string&());

0 commit comments

Comments
 (0)