summaryrefslogtreecommitdiff
path: root/src/components/application_manager/test/commands/mobile/change_registration_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/application_manager/test/commands/mobile/change_registration_test.cc')
-rw-r--r--src/components/application_manager/test/commands/mobile/change_registration_test.cc99
1 files changed, 64 insertions, 35 deletions
diff --git a/src/components/application_manager/test/commands/mobile/change_registration_test.cc b/src/components/application_manager/test/commands/mobile/change_registration_test.cc
index 2fd43a6353..3d7671015c 100644
--- a/src/components/application_manager/test/commands/mobile/change_registration_test.cc
+++ b/src/components/application_manager/test/commands/mobile/change_registration_test.cc
@@ -66,7 +66,6 @@ using am::commands::MessageSharedPtr;
using am::ApplicationSharedPtr;
using am::MockMessageHelper;
using ::testing::_;
-using ::testing::Mock;
using ::utils::SharedPtr;
using ::testing::Return;
using ::testing::ReturnRef;
@@ -80,7 +79,6 @@ namespace strings = ::application_manager::strings;
namespace hmi_response = ::application_manager::hmi_response;
namespace {
-const int32_t kCommandId = 1;
const uint32_t kAppId = 1u;
const uint32_t kCmdId = 1u;
const uint32_t kConnectionKey = 2u;
@@ -90,8 +88,7 @@ class ChangeRegistrationRequestTest
: public CommandRequestTest<CommandsTestMocks::kIsNice> {
public:
ChangeRegistrationRequestTest()
- : mock_message_helper_(*MockMessageHelper::message_helper_mock())
- , mock_app_(CreateMockApp())
+ : mock_app_(CreateMockApp())
, supported_languages_(CreateMessage(smart_objects::SmartType_Array)) {}
MessageSharedPtr CreateMsgFromMobile() {
@@ -121,26 +118,26 @@ class ChangeRegistrationRequestTest
EXPECT_CALL(
mock_hmi_interfaces_,
GetInterfaceFromFunction(hmi_apis::FunctionID::UI_ChangeRegistration))
- .WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
+ .WillRepeatedly(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
EXPECT_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
- .WillOnce(Return(am::HmiInterfaces::STATE_AVAILABLE));
+ .WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE));
EXPECT_CALL(
mock_hmi_interfaces_,
GetInterfaceFromFunction(hmi_apis::FunctionID::VR_ChangeRegistration))
- .WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_VR));
+ .WillRepeatedly(Return(am::HmiInterfaces::HMI_INTERFACE_VR));
EXPECT_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR))
- .WillOnce(Return(am::HmiInterfaces::STATE_AVAILABLE));
+ .WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE));
EXPECT_CALL(
mock_hmi_interfaces_,
GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_ChangeRegistration))
- .WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_TTS));
+ .WillRepeatedly(Return(am::HmiInterfaces::HMI_INTERFACE_TTS));
EXPECT_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS))
- .WillOnce(Return(am::HmiInterfaces::STATE_AVAILABLE));
+ .WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE));
}
void CheckExpectations(const hmi_apis::Common_Result::eType hmi_response,
@@ -148,14 +145,11 @@ class ChangeRegistrationRequestTest
const am::HmiInterfaces::InterfaceState state,
const bool success,
const hmi_apis::Common_Result::eType ui_hmi_response =
- hmi_apis::Common_Result::WARNINGS,
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE,
const hmi_apis::Common_Result::eType vr_hmi_response =
hmi_apis::Common_Result::UNSUPPORTED_RESOURCE) {
MessageSharedPtr msg_from_mobile = CreateMsgFromMobile();
- ON_CALL(mock_message_helper_, HMIToMobileResult(_))
- .WillByDefault(Return(mobile_response));
-
utils::SharedPtr<ChangeRegistrationRequest> command =
CreateCommand<ChangeRegistrationRequest>(msg_from_mobile);
MockAppPtr mock_app = CreateMockApp();
@@ -173,6 +167,8 @@ class ChangeRegistrationRequestTest
EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(accessor));
EXPECT_CALL(*app, name()).WillOnce(ReturnRef(name));
PrepareExpectationBeforeRun();
+ EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
+ .WillRepeatedly(Return(state));
command->Run();
MessageSharedPtr ui_response = CreateMessage(smart_objects::SmartType_Map);
@@ -184,9 +180,6 @@ class ChangeRegistrationRequestTest
(*tts_response)[strings::params][hmi_response::code] = hmi_response;
(*tts_response)[strings::msg_params] = 0;
- EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
- .WillRepeatedly(Return(state));
-
am::event_engine::Event event_ui(
hmi_apis::FunctionID::UI_ChangeRegistration);
event_ui.set_smart_object(*ui_response);
@@ -251,10 +244,6 @@ class ChangeRegistrationRequestTest
.WillByDefault(ReturnRef(hmi_capabilities_));
}
- void TearDown() OVERRIDE {
- Mock::VerifyAndClearExpectations(&mock_message_helper_);
- }
-
void ExpectationsHmiCapabilities(
smart_objects::SmartObjectSPtr supported_languages) {
EXPECT_CALL(hmi_capabilities_, ui_supported_languages())
@@ -282,7 +271,6 @@ class ChangeRegistrationRequestTest
MockHMICapabilities;
sync_primitives::Lock app_set_lock_;
MockHMICapabilities hmi_capabilities_;
- MockMessageHelper& mock_message_helper_;
MockAppPtr mock_app_;
MessageSharedPtr supported_languages_;
MockPolicyHandlerInterface mock_policy_handler_;
@@ -379,11 +367,52 @@ TEST_F(ChangeRegistrationRequestTest,
}
TEST_F(ChangeRegistrationRequestTest,
- OnEvent_TTS_UNSUPPORTED_RESOURCE_STATE_NOT_AVAILABLE_Expect_true) {
- CheckExpectations(hmi_apis::Common_Result::SUCCESS,
- mobile_apis::Result::UNSUPPORTED_RESOURCE,
- am::HmiInterfaces::STATE_NOT_AVAILABLE,
- true);
+ OnEvent_TTS_UNSUPPORTED_RESOURCE_STATE_NOT_AVAILABLE_Expect_false) {
+ MessageSharedPtr msg_from_mobile = CreateMsgFromMobile();
+ utils::SharedPtr<ChangeRegistrationRequest> command =
+ CreateCommand<ChangeRegistrationRequest>(msg_from_mobile);
+ MockAppPtr mock_app = CreateMockApp();
+ ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app));
+ ON_CALL(*mock_app, app_id()).WillByDefault(Return(1));
+ am::ApplicationSet application_set;
+ const utils::custom_string::CustomString name("name");
+ MockAppPtr app = CreateMockApp();
+ app->set_name(name);
+ DataAccessor<am::ApplicationSet> accessor(application_set, app_set_lock_);
+ application_set.insert(app);
+ EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(accessor));
+ EXPECT_CALL(*app, name()).WillOnce(ReturnRef(name));
+
+ ON_CALL(app_mngr_, hmi_capabilities())
+ .WillByDefault(ReturnRef(hmi_capabilities_));
+ (*supported_languages_)[0] =
+ static_cast<int32_t>(mobile_apis::Language::EN_US);
+ EXPECT_CALL(hmi_capabilities_, ui_supported_languages())
+ .WillOnce(Return(supported_languages_.get()));
+ EXPECT_CALL(hmi_capabilities_, vr_supported_languages())
+ .WillOnce(Return(supported_languages_.get()));
+ EXPECT_CALL(hmi_capabilities_, tts_supported_languages())
+ .WillOnce(Return(supported_languages_.get()));
+
+ EXPECT_CALL(app_mngr_, hmi_interfaces())
+ .WillRepeatedly(ReturnRef(mock_hmi_interfaces_));
+
+ EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
+ .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
+
+ MessageSharedPtr response_to_mobile;
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
+ .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true)));
+ command->Run();
+
+ EXPECT_EQ(
+ (*response_to_mobile)[strings::msg_params][strings::success].asBool(),
+ false);
+ EXPECT_EQ(
+ (*response_to_mobile)[strings::msg_params][strings::result_code].asInt(),
+ static_cast<int32_t>(mobile_apis::Result::UNSUPPORTED_RESOURCE));
}
TEST_F(ChangeRegistrationRequestTest,
@@ -403,17 +432,17 @@ TEST_F(ChangeRegistrationRequestTest,
}
TEST_F(ChangeRegistrationRequestTest,
- OnEvent_TTS_UNSUPPORTED_RESOURCE_SUCCESS_STATE_AVAILABLE_Expect_false) {
+ OnEvent_TTS_UNSUPPORTED_RESOURCE_SUCCESS_STATE_AVAILABLE_Expect_true) {
CheckExpectations(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE,
mobile_apis::Result::UNSUPPORTED_RESOURCE,
am::HmiInterfaces::STATE_AVAILABLE,
- false,
+ true,
hmi_apis::Common_Result::SUCCESS,
hmi_apis::Common_Result::SUCCESS);
}
TEST_F(ChangeRegistrationRequestTest,
- OnEvent_TTS_SUCCESS_STATE_AVAILABLE_Expect_false) {
+ OnEvent_TTS_SUCCESS_STATE_AVAILABLE_Expect_true) {
CheckExpectations(hmi_apis::Common_Result::SUCCESS,
mobile_apis::Result::SUCCESS,
am::HmiInterfaces::STATE_AVAILABLE,
@@ -425,7 +454,7 @@ TEST_F(ChangeRegistrationRequestTest,
TEST_F(ChangeRegistrationRequestTest,
OnEvent_TTS_WRONG_LANGUAGE_STATE_AVAILABLE_Expect_true) {
CheckExpectations(hmi_apis::Common_Result::WRONG_LANGUAGE,
- mobile_apis::Result::SUCCESS,
+ mobile_apis::Result::WRONG_LANGUAGE,
am::HmiInterfaces::STATE_AVAILABLE,
true,
hmi_apis::Common_Result::SUCCESS,
@@ -435,7 +464,7 @@ TEST_F(ChangeRegistrationRequestTest,
TEST_F(ChangeRegistrationRequestTest,
OnEvent_TTS_INVALID_DATA_STATE_AVAILABLE_Expect_false) {
CheckExpectations(hmi_apis::Common_Result::INVALID_DATA,
- mobile_apis::Result::SUCCESS,
+ mobile_apis::Result::INVALID_DATA,
am::HmiInterfaces::STATE_AVAILABLE,
false,
hmi_apis::Common_Result::SUCCESS,
@@ -473,14 +502,14 @@ TEST_F(ChangeRegistrationRequestTest,
.WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
ON_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
- .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
+ .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
ON_CALL(mock_hmi_interfaces_,
GetInterfaceFromFunction(hmi_apis::FunctionID::VR_ChangeRegistration))
.WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_VR));
ON_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR))
- .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
+ .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
ON_CALL(
mock_hmi_interfaces_,
@@ -488,7 +517,7 @@ TEST_F(ChangeRegistrationRequestTest,
.WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_TTS));
ON_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS))
- .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
+ .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
command->Run();