summaryrefslogtreecommitdiff
path: root/src/components/application_manager/test/commands/mobile/set_global_properties_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/application_manager/test/commands/mobile/set_global_properties_test.cc')
-rw-r--r--src/components/application_manager/test/commands/mobile/set_global_properties_test.cc65
1 files changed, 32 insertions, 33 deletions
diff --git a/src/components/application_manager/test/commands/mobile/set_global_properties_test.cc b/src/components/application_manager/test/commands/mobile/set_global_properties_test.cc
index 7143bdf71a..641e5636a9 100644
--- a/src/components/application_manager/test/commands/mobile/set_global_properties_test.cc
+++ b/src/components/application_manager/test/commands/mobile/set_global_properties_test.cc
@@ -59,7 +59,6 @@ using am::CommandsMap;
using utils::custom_string::CustomString;
using ::utils::SharedPtr;
using ::testing::_;
-using ::testing::Mock;
using ::testing::Return;
using ::testing::ReturnRef;
@@ -75,9 +74,7 @@ const uint32_t kPosition = 1u;
class SetGlobalPropertiesRequestTest
: public CommandRequestTest<CommandsTestMocks::kIsNice> {
public:
- SetGlobalPropertiesRequestTest()
- : mock_message_helper_(*MockMessageHelper::message_helper_mock())
- , mock_app_(CreateMockApp()) {}
+ SetGlobalPropertiesRequestTest() : mock_app_(CreateMockApp()) {}
MessageSharedPtr CreateFullParamsUISO() {
MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
@@ -118,6 +115,8 @@ class SetGlobalPropertiesRequestTest
vr_help_array[0][am::strings::text] = kText;
vr_help_array[0][am::strings::position] = kPosition;
(*msg)[am::strings::msg_params][am::strings::vr_help] = vr_help_array;
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(mock_app_));
}
void OnEventUISetupHelper(MessageSharedPtr msg,
@@ -152,6 +151,8 @@ class SetGlobalPropertiesRequestTest
(*msg)[am::strings::msg_params][am::strings::timeout_prompt] =
timeout_prompt;
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(mock_app_));
EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(_, _, _)).Times(0);
EXPECT_CALL(app_mngr_,
RemoveAppFromTTSGlobalPropertiesList(kConnectionKey));
@@ -216,10 +217,6 @@ class SetGlobalPropertiesRequestTest
.WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
}
- void TearDown() OVERRIDE {
- Mock::VerifyAndClearExpectations(&mock_message_helper_);
- }
-
void ResultCommandExpectations(MessageSharedPtr msg,
const std::string& info) {
EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::success].asBool(),
@@ -242,13 +239,12 @@ class SetGlobalPropertiesRequestTest
.WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_TTS));
ON_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
- .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
+ .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
ON_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS))
- .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
+ .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
}
sync_primitives::Lock lock_;
- MockMessageHelper& mock_message_helper_;
MockAppPtr mock_app_;
};
@@ -323,6 +319,9 @@ TEST_F(SetGlobalPropertiesRequestTest, OnEvent_SUCCESS_Expect_MessageNotSend) {
utils::SharedPtr<SetGlobalPropertiesRequest> command =
CreateCommand<SetGlobalPropertiesRequest>(response);
+ MockAppPtr mock_app(CreateMockApp());
+ ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app));
+
EXPECT_CALL(
app_mngr_,
ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
@@ -348,9 +347,6 @@ TEST_F(SetGlobalPropertiesRequestTest,
utils::SharedPtr<SetGlobalPropertiesRequest> command =
CreateCommand<SetGlobalPropertiesRequest>(response);
- ON_CALL(mock_message_helper_, HMIToMobileResult(_))
- .WillByDefault(Return(mobile_apis::Result::UNSUPPORTED_RESOURCE));
-
EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
.WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
@@ -1032,8 +1028,6 @@ TEST_F(SetGlobalPropertiesRequestTest, OnEvent_PendingRequest_UNSUCCESS) {
SharedPtr<SetGlobalPropertiesRequest> command(
CreateCommand<SetGlobalPropertiesRequest>(msg));
- EXPECT_CALL(mock_message_helper_, HMIToMobileResult(_)).Times(0);
-
Event event(hmi_apis::FunctionID::UI_SetGlobalProperties);
event.set_smart_object(*msg);
@@ -1061,8 +1055,8 @@ TEST_F(SetGlobalPropertiesRequestTest, OnEvent_UIAndSuccessResultCode_SUCCESS) {
Event event(hmi_apis::FunctionID::UI_SetGlobalProperties);
event.set_smart_object(*msg);
- EXPECT_CALL(mock_message_helper_, HMIToMobileResult(_))
- .WillOnce(Return(mobile_apis::Result::SUCCESS));
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(mock_app_));
EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
.WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
@@ -1091,15 +1085,14 @@ TEST_F(SetGlobalPropertiesRequestTest, OnEvent_UIAndWarningResultCode_SUCCESS) {
.WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
OnEventUISetupHelper(msg, command);
- EXPECT_CALL(mock_message_helper_, HMIToMobileResult(_)).Times(0);
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(mock_app_));
Event event(hmi_apis::FunctionID::UI_SetGlobalProperties);
event.set_smart_object(*msg);
EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
.WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
- EXPECT_CALL(mock_message_helper_, HMIToMobileResult(_))
- .WillOnce(Return(mobile_apis::Result::SUCCESS));
EXPECT_CALL(app_mngr_,
ManageMobileCommand(_, am::commands::Command::ORIGIN_SDL))
.WillOnce(Return(true));
@@ -1126,9 +1119,6 @@ TEST_F(SetGlobalPropertiesRequestTest, OnEvent_InvalidApp_Canceled) {
EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
.WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
- EXPECT_CALL(mock_message_helper_, HMIToMobileResult(_))
- .WillOnce(Return(mobile_apis::Result::SUCCESS));
-
EXPECT_CALL(app_mngr_, application(kConnectionKey))
.WillRepeatedly(Return(MockAppPtr()));
@@ -1146,7 +1136,6 @@ TEST_F(SetGlobalPropertiesRequestTest, OnEvent_InvalidEventID_Canceled) {
SharedPtr<SetGlobalPropertiesRequest> command(
CreateCommand<SetGlobalPropertiesRequest>(msg));
- EXPECT_CALL(mock_message_helper_, HMIToMobileResult(_)).Times(0);
EXPECT_CALL(app_mngr_, application(kConnectionKey)).Times(0);
EXPECT_CALL(*mock_app_, UpdateHash()).Times(0);
@@ -1180,8 +1169,8 @@ TEST_F(SetGlobalPropertiesRequestTest,
ManageMobileCommand(_, am::commands::Command::ORIGIN_SDL))
.WillOnce(Return(true));
- EXPECT_CALL(mock_message_helper_, HMIToMobileResult(response_code))
- .WillOnce(Return(mobile_apis::Result::SUCCESS));
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(mock_app_));
Event event(hmi_apis::FunctionID::TTS_SetGlobalProperties);
event.set_smart_object(*msg);
@@ -1192,7 +1181,7 @@ TEST_F(SetGlobalPropertiesRequestTest,
TEST_F(SetGlobalPropertiesRequestTest,
OnEvent_TTSAndWarningsResultCode_SUCCESS) {
MessageSharedPtr msg = CreateMsgParams();
- hmi_apis::Common_Result::eType response_code =
+ const hmi_apis::Common_Result::eType response_code =
hmi_apis::Common_Result::WARNINGS;
(*msg)[am::strings::params][am::hmi_response::code] = response_code;
ON_CALL(
@@ -1210,17 +1199,27 @@ TEST_F(SetGlobalPropertiesRequestTest,
EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
.WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
- EXPECT_CALL(app_mngr_,
- ManageMobileCommand(_, am::commands::Command::ORIGIN_SDL))
- .WillOnce(Return(true));
+ MessageSharedPtr ui_command_result;
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
+ .WillOnce(DoAll(SaveArg<0>(&ui_command_result), Return(true)));
- EXPECT_CALL(mock_message_helper_, HMIToMobileResult(_))
- .WillOnce(Return(mobile_apis::Result::SUCCESS));
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(mock_app_));
Event event(hmi_apis::FunctionID::TTS_SetGlobalProperties);
event.set_smart_object(*msg);
command->on_event(event);
+
+ EXPECT_EQ((*ui_command_result)[am::strings::msg_params][am::strings::success]
+ .asBool(),
+ true);
+ EXPECT_EQ(
+ (*ui_command_result)[am::strings::msg_params][am::strings::result_code]
+ .asInt(),
+ static_cast<int32_t>(hmi_apis::Common_Result::WARNINGS));
}
} // namespace set_global_properties_request