diff options
Diffstat (limited to 'src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_button_request_test.cc')
-rw-r--r-- | src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_button_request_test.cc | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_button_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_button_request_test.cc index bbc18504a6..0196b59b79 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_button_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_button_request_test.cc @@ -73,6 +73,8 @@ class SubscribeButtonRequestTest }; typedef SubscribeButtonRequestTest::MockHMICapabilities MockHMICapabilities; +const utils::SemanticVersion mock_semantic_version(5, 0, 0); +const utils::SemanticVersion mock_semantic_version_4_5(4, 5, 0); TEST_F(SubscribeButtonRequestTest, Run_AppNotRegistered_UNSUCCESS) { CommandPtr command(CreateCommand<SubscribeButtonRequest>()); @@ -110,6 +112,9 @@ TEST_F(SubscribeButtonRequestTest, Run_UiIsNotSupported_UNSUCCESS) { MockAppPtr app(CreateMockApp()); ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app)); + ON_CALL(*app, msg_version()).WillByDefault(ReturnRef(mock_semantic_version)); + ON_CALL(*app, is_media_application()).WillByDefault(Return(false)); + ON_CALL(mock_hmi_capabilities_, is_ui_cooperating()) .WillByDefault(Return(false)); @@ -130,6 +135,7 @@ TEST_F(SubscribeButtonRequestTest, Run_IsSubscribedToButton_UNSUCCESS) { MockAppPtr app(CreateMockApp()); ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app)); + ON_CALL(*app, msg_version()).WillByDefault(ReturnRef(mock_semantic_version)); ON_CALL(*app, is_media_application()).WillByDefault(Return(true)); ON_CALL(mock_hmi_capabilities_, is_ui_cooperating()) @@ -160,6 +166,7 @@ TEST_F(SubscribeButtonRequestTest, Run_SUCCESS) { MockAppPtr app(CreateMockApp()); ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app)); + ON_CALL(*app, msg_version()).WillByDefault(ReturnRef(mock_semantic_version)); ON_CALL(*app, is_media_application()).WillByDefault(Return(true)); ON_CALL(mock_hmi_capabilities_, is_ui_cooperating()) @@ -195,6 +202,60 @@ TEST_F(SubscribeButtonRequestTest, Run_SUCCESS) { [am::strings::result_code].asInt())); } +TEST_F(SubscribeButtonRequestTest, Run_SUCCESS_App_Version_4_5) { + const mobile_apis::ButtonName::eType kButtonName = + mobile_apis::ButtonName::OK; + + MessageSharedPtr msg(CreateMessage()); + (*msg)[am::strings::msg_params][am::strings::button_name] = kButtonName; + CommandPtr command(CreateCommand<SubscribeButtonRequest>(msg)); + + MockAppPtr app(CreateMockApp()); + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app)); + ON_CALL(*app, msg_version()) + .WillByDefault(ReturnRef(mock_semantic_version_4_5)); + ON_CALL(*app, is_media_application()).WillByDefault(Return(true)); + + ON_CALL(mock_hmi_capabilities_, is_ui_cooperating()) + .WillByDefault(Return(true)); + + MessageSharedPtr button_caps_ptr(CreateMessage(smart_objects::SmartType_Map)); + (*button_caps_ptr)[0][am::hmi_response::button_name] = kButtonName; + (*button_caps_ptr)[1][am::hmi_response::button_name] = + mobile_apis::ButtonName::PLAY_PAUSE; + + ON_CALL(mock_hmi_capabilities_, button_capabilities()) + .WillByDefault(Return(button_caps_ptr.get())); + + ON_CALL(*app, IsSubscribedToButton(_)).WillByDefault(Return(false)); + + MessageSharedPtr hmi_result_msg; + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)) + .WillOnce(DoAll(SaveArg<0>(&hmi_result_msg), Return(true))); + + MessageSharedPtr mobile_result_msg; + EXPECT_CALL(this->mock_rpc_service_, ManageMobileCommand(_, _)) + .WillOnce(DoAll(SaveArg<0>(&mobile_result_msg), Return(true))); + ASSERT_TRUE(command->Init()); + command->Run(); + + EXPECT_EQ(hmi_apis::FunctionID::Buttons_OnButtonSubscription, + static_cast<hmi_apis::FunctionID::eType>( + (*hmi_result_msg)[am::strings::params][am::strings::function_id] + .asInt())); + + EXPECT_EQ(hmi_apis::Common_ButtonName::PLAY_PAUSE, + static_cast<hmi_apis::Common_ButtonName::eType>( + (*hmi_result_msg)[am::strings::msg_params][am::strings::name] + .asInt())); + + EXPECT_EQ(mobile_apis::Result::SUCCESS, + static_cast<mobile_apis::Result::eType>( + (*mobile_result_msg)[am::strings::msg_params] + [am::strings::result_code].asInt())); +} + } // namespace subscribe_button_request } // namespace mobile_commands_test } // namespace commands_test |