diff options
Diffstat (limited to 'src/components/application_manager/test/commands/mobile/unsubscribe_button_request_test.cc')
-rw-r--r-- | src/components/application_manager/test/commands/mobile/unsubscribe_button_request_test.cc | 65 |
1 files changed, 58 insertions, 7 deletions
diff --git a/src/components/application_manager/test/commands/mobile/unsubscribe_button_request_test.cc b/src/components/application_manager/test/commands/mobile/unsubscribe_button_request_test.cc index a71f8a43c8..46a1ce02eb 100644 --- a/src/components/application_manager/test/commands/mobile/unsubscribe_button_request_test.cc +++ b/src/components/application_manager/test/commands/mobile/unsubscribe_button_request_test.cc @@ -6,6 +6,7 @@ #include "application_manager/commands/command_request_test.h" #include "application_manager/mock_application_manager.h" #include "application_manager/mock_message_helper.h" +#include "application_manager/mock_hmi_capabilities.h" #include "application_manager/commands/mobile/unsubscribe_button_request.h" namespace test { @@ -30,7 +31,13 @@ const mobile_apis::ButtonName::eType kButtonId = mobile_apis::ButtonName::OK; } // namespace class UnsubscribeButtonRequestTest - : public CommandRequestTest<CommandsTestMocks::kIsNice> {}; + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + public: + typedef TypeIf<kMocksAreNice, + NiceMock<application_manager_test::MockHMICapabilities>, + application_manager_test::MockHMICapabilities>::Result + MockHMICapabilities; +}; TEST_F(UnsubscribeButtonRequestTest, Run_AppNotRegistered_UNSUCCESS) { CommandPtr command(CreateCommand<UnsubscribeButtonRequest>()); @@ -55,13 +62,21 @@ TEST_F(UnsubscribeButtonRequestTest, CommandPtr command(CreateCommand<UnsubscribeButtonRequest>(command_msg)); + UnsubscribeButtonRequestTest::MockHMICapabilities hmi_capabilities; + EXPECT_CALL(app_mngr_, hmi_capabilities()) + .WillOnce(ReturnRef(hmi_capabilities)); + EXPECT_CALL(hmi_capabilities, is_ui_cooperating()).WillOnce(Return(true)); + + MessageSharedPtr button_caps_ptr(CreateMessage(smart_objects::SmartType_Map)); + (*button_caps_ptr)[0][am::hmi_response::button_name] = kButtonId; + EXPECT_CALL(hmi_capabilities, button_capabilities()) + .WillOnce(Return(button_caps_ptr.get())); + MockAppPtr mock_app(CreateMockApp()); EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app)); - EXPECT_CALL(*mock_app, UnsubscribeFromButton(kButtonId)) .WillOnce(Return(false)); - EXPECT_CALL( app_mngr_, ManageMobileCommand(MobileResultCodeIs(mobile_result::IGNORED), _)); @@ -69,9 +84,35 @@ TEST_F(UnsubscribeButtonRequestTest, command->Run(); } -TEST_F(UnsubscribeButtonRequestTest, Run_SUCCESS) { - const mobile_apis::ButtonName::eType kButtonId = mobile_apis::ButtonName::OK; +TEST_F(UnsubscribeButtonRequestTest, + Run_UnsubscribeNotAllowedByHmiCapabilities_UNSUCCESS) { + MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); + (*command_msg)[am::strings::params][am::strings::connection_key] = + kConnectionKey; + (*command_msg)[am::strings::msg_params][am::strings::button_name] = kButtonId; + CommandPtr command(CreateCommand<UnsubscribeButtonRequest>(command_msg)); + MockAppPtr mock_app(CreateMockApp()); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app)); + + UnsubscribeButtonRequestTest::MockHMICapabilities hmi_capabilities; + EXPECT_CALL(app_mngr_, hmi_capabilities()) + .WillOnce(ReturnRef(hmi_capabilities)); + EXPECT_CALL(hmi_capabilities, is_ui_cooperating()).WillOnce(Return(true)); + + MessageSharedPtr button_caps_ptr(CreateMessage(smart_objects::SmartType_Map)); + EXPECT_CALL(hmi_capabilities, button_capabilities()) + .WillOnce(Return(button_caps_ptr.get())); + + EXPECT_CALL(app_mngr_, + ManageMobileCommand( + MobileResultCodeIs(mobile_result::UNSUPPORTED_RESOURCE), _)); + + command->Run(); +} + +TEST_F(UnsubscribeButtonRequestTest, Run_SUCCESS) { MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); (*command_msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; @@ -79,9 +120,19 @@ TEST_F(UnsubscribeButtonRequestTest, Run_SUCCESS) { CommandPtr command(CreateCommand<UnsubscribeButtonRequest>(command_msg)); + UnsubscribeButtonRequestTest::MockHMICapabilities hmi_capabilities; + EXPECT_CALL(app_mngr_, hmi_capabilities()) + .WillOnce(ReturnRef(hmi_capabilities)); + EXPECT_CALL(hmi_capabilities, is_ui_cooperating()).WillOnce(Return(true)); + + MessageSharedPtr button_caps_ptr(CreateMessage(smart_objects::SmartType_Map)); + (*button_caps_ptr)[0][am::hmi_response::button_name] = kButtonId; + EXPECT_CALL(hmi_capabilities, button_capabilities()) + .WillOnce(Return(button_caps_ptr.get())); + MockAppPtr mock_app(CreateMockApp()); EXPECT_CALL(app_mngr_, application(kConnectionKey)) - .WillOnce(Return(mock_app)); + .WillRepeatedly(Return(mock_app)); EXPECT_CALL(*mock_app, UnsubscribeFromButton(kButtonId)) .WillOnce(Return(true)); @@ -94,7 +145,7 @@ TEST_F(UnsubscribeButtonRequestTest, Run_SUCCESS) { ManageMobileCommand(MobileResultCodeIs(mobile_result::SUCCESS), _)); EXPECT_CALL(*mock_app, UpdateHash()); - + command->Init(); command->Run(); } |