diff options
author | Levchenko <slevchenko@SLevchenko-lws-unq> | 2016-06-07 14:01:29 +0300 |
---|---|---|
committer | okozlovlux <okozlov@luxoft.com> | 2016-08-23 14:26:27 +0300 |
commit | 0ebc98982b89de28bf1ee421281ddf8ff45eb97b (patch) | |
tree | 5f20c5c8552242e934a3cfa3153a986a4af053dc /src/components/application_manager/test/commands/mobile/unsubscribe_button_request_test.cc | |
parent | ad7336cf7befae1d82521c691496510449c1581f (diff) | |
download | sdl_core-0ebc98982b89de28bf1ee421281ddf8ff45eb97b.tar.gz |
Create tools to test commands
Been done:
- Added specific abstract classes for
commands testing (CommandsTest
and CommandRequestTest);
- Been added unit tests for base
command classes (CommandImpl,
CommandRequestImpl, CommandResponseImpl);
- Been added unit tests for next
mobile response commands:
- ListFilesResponse
- ReadDIDResponse
- AlertManeuverResponse
- AlertResponse
- SubscribeButtonResponse
Related to: APPLINK-24911
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 | 103 |
1 files changed, 103 insertions, 0 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 new file mode 100644 index 0000000000..d9df08c9bc --- /dev/null +++ b/src/components/application_manager/test/commands/mobile/unsubscribe_button_request_test.cc @@ -0,0 +1,103 @@ +#include <stdint.h> +#include <string> + +#include "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "commands/command_request_test.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_message_helper.h" +#include "mobile/unsubscribe_button_request.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { + +namespace am = ::application_manager; +namespace mobile_result = mobile_apis::Result; + +using ::testing::_; + +using am::commands::UnsubscribeButtonRequest; +using am::commands::MessageSharedPtr; + +typedef ::utils::SharedPtr<UnsubscribeButtonRequest> CommandPtr; + +namespace { +const uint32_t kConnectionKey = 1u; +const mobile_apis::ButtonName::eType kButtonId = mobile_apis::ButtonName::OK; +} // namespace + +class UnsubscribeButtonRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> {}; + +TEST_F(UnsubscribeButtonRequestTest, Run_AppNotRegistered_UNSUCCESS) { + CommandPtr command(CreateCommand<UnsubscribeButtonRequest>()); + + EXPECT_CALL(app_mngr_, application(_)) + .WillOnce(Return(ApplicationSharedPtr())); + + EXPECT_CALL( + app_mngr_, + ManageMobileCommand( + MobileResultCodeIs(mobile_result::APPLICATION_NOT_REGISTERED), _)); + + command->Run(); +} + +TEST_F(UnsubscribeButtonRequestTest, + Run_UnsubscribeNotSubscribedButton_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)); + + EXPECT_CALL(*mock_app, UnsubscribeFromButton(kButtonId)) + .WillOnce(Return(false)); + + EXPECT_CALL( + app_mngr_, + ManageMobileCommand(MobileResultCodeIs(mobile_result::IGNORED), _)); + + command->Run(); +} + +TEST_F(UnsubscribeButtonRequestTest, Run_SUCCESS) { + const mobile_apis::ButtonName::eType kButtonId = mobile_apis::ButtonName::OK; + + 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)); + + EXPECT_CALL(*mock_app, UnsubscribeFromButton(kButtonId)) + .WillOnce(Return(true)); + + EXPECT_CALL(app_mngr_, + ManageHMICommand(HMIResultCodeIs( + hmi_apis::FunctionID::Buttons_OnButtonSubscription))); + EXPECT_CALL( + app_mngr_, + ManageMobileCommand(MobileResultCodeIs(mobile_result::SUCCESS), _)); + + EXPECT_CALL(*mock_app, UpdateHash()); + + command->Run(); +} + +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test |