summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShobhit Adlakha <ShobhitAd@users.noreply.github.com>2021-07-02 10:00:40 -0700
committerGitHub <noreply@github.com>2021-07-02 10:00:40 -0700
commit10c6562dbe4e4d6d88090f9a41f7433b2c760d3a (patch)
tree2f4d2b9e8c97297548eedcc135e1f4f3f9c2aa70
parent5ecfd16ff038fc8c964183e4e26231e3803a05ff (diff)
downloadsdl_core-10c6562dbe4e4d6d88090f9a41f7433b2c760d3a.tar.gz
Feature/Add Unit test cases for GetSystemCapability (#3729)
* Add additional test cases * Add additional test cases and fix style * Address review comments
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/get_system_capability_request_test.cc194
1 files changed, 194 insertions, 0 deletions
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/get_system_capability_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/get_system_capability_request_test.cc
index 74c61410e8..3574385274 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/get_system_capability_request_test.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/get_system_capability_request_test.cc
@@ -33,8 +33,11 @@
#include "mobile/get_system_capability_request.h"
#include "application_manager/commands/command_request_test.h"
+#include "application_manager/message_helper.h"
#include "gtest/gtest.h"
#include "interfaces/MOBILE_API.h"
+#include "resumption/last_state_impl.h"
+#include "resumption/last_state_wrapper_impl.h"
#include "smart_objects/smart_object.h"
namespace test {
@@ -44,8 +47,11 @@ namespace mobile_commands_test {
namespace get_system_capability_request_test {
using sdl_rpc_plugin::commands::GetSystemCapabilityRequest;
+using ::test::components::application_manager_test::MockAppServiceManager;
using ::testing::_;
using ::testing::Return;
+using ::testing::ReturnPointee;
+
typedef std::shared_ptr<GetSystemCapabilityRequest>
GetSystemCapabilityRequestPtr;
@@ -64,6 +70,12 @@ class GetSystemCapabilityRequestTest
command_ = CreateCommand<GetSystemCapabilityRequest>(message_);
mock_app_ = CreateMockApp();
+ last_state_ = std::make_shared<resumption::LastStateWrapperImpl>(
+ std::make_shared<resumption::LastStateImpl>("app_storage_folder",
+ "app_info_storage"));
+ mock_app_service_mngr_ =
+ std::make_shared<MockAppServiceManager>(app_mngr_, last_state_);
+
ON_CALL(app_mngr_, application(kConnectionKey))
.WillByDefault(Return(mock_app_));
}
@@ -71,6 +83,8 @@ class GetSystemCapabilityRequestTest
GetSystemCapabilityRequestPtr command_;
MessageSharedPtr message_;
MockAppPtr mock_app_;
+ std::shared_ptr<MockAppServiceManager> mock_app_service_mngr_;
+ resumption::LastStateWrapperPtr last_state_;
};
TEST_F(
@@ -117,6 +131,186 @@ TEST_F(
command_->Run();
}
+TEST_F(GetSystemCapabilityRequestTest,
+ Run_GetSystemDisplayCapabilities_AppNotRegistered) {
+ EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(nullptr));
+ EXPECT_CALL(
+ mock_rpc_service_,
+ ManageMobileCommand(
+ MobileResultCodeIs(mobile_apis::Result::APPLICATION_NOT_REGISTERED),
+ Command::CommandSource::SOURCE_SDL));
+ ASSERT_TRUE(command_->Init());
+ command_->Run();
+}
+
+TEST_F(GetSystemCapabilityRequestTest,
+ Run_GetSystemDisplayCapabilities_NAVIGATION_SUCCESSResultCode) {
+ (*message_)[strings::msg_params][strings::system_capability_type] =
+ mobile_apis::SystemCapabilityType::NAVIGATION;
+
+ smart_objects::SmartObjectSPtr system_navigation_capabilities(
+ std::make_shared<smart_objects::SmartObject>());
+ EXPECT_CALL(mock_hmi_capabilities_, navigation_capability())
+ .Times(2)
+ .WillRepeatedly(Return(system_navigation_capabilities));
+
+ ON_CALL(app_mngr_, GetAppServiceManager())
+ .WillByDefault(ReturnPointee(mock_app_service_mngr_));
+
+ EXPECT_CALL(
+ mock_rpc_service_,
+ ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS),
+ Command::CommandSource::SOURCE_SDL));
+
+ ASSERT_TRUE(command_->Init());
+ command_->Run();
+}
+
+TEST_F(GetSystemCapabilityRequestTest,
+ Run_GetSystemDisplayCapabilities_PHONECALL_SUCCESSResultCode) {
+ (*message_)[strings::msg_params][strings::system_capability_type] =
+ mobile_apis::SystemCapabilityType::PHONE_CALL;
+
+ smart_objects::SmartObjectSPtr system_phonecall_capabilities(
+ std::make_shared<smart_objects::SmartObject>());
+ EXPECT_CALL(mock_hmi_capabilities_, phone_capability())
+ .Times(2)
+ .WillRepeatedly(Return(system_phonecall_capabilities));
+
+ EXPECT_CALL(
+ mock_rpc_service_,
+ ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS),
+ Command::CommandSource::SOURCE_SDL));
+
+ ASSERT_TRUE(command_->Init());
+ command_->Run();
+}
+
+TEST_F(GetSystemCapabilityRequestTest,
+ Run_GetSystemDisplayCapabilities_VIDEOSTREAMING_SUCCESSResultCode) {
+ (*message_)[strings::msg_params][strings::system_capability_type] =
+ mobile_apis::SystemCapabilityType::VIDEO_STREAMING;
+
+ smart_objects::SmartObjectSPtr system_videostreaming_capabilities(
+ std::make_shared<smart_objects::SmartObject>());
+ EXPECT_CALL(mock_hmi_capabilities_, video_streaming_capability())
+ .Times(2)
+ .WillRepeatedly(Return(system_videostreaming_capabilities));
+
+ EXPECT_CALL(
+ mock_rpc_service_,
+ ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS),
+ Command::CommandSource::SOURCE_SDL));
+
+ ASSERT_TRUE(command_->Init());
+ command_->Run();
+}
+
+TEST_F(GetSystemCapabilityRequestTest,
+ Run_GetSystemDisplayCapabilities_REMOTECONTROL_SUCCESSResultCode) {
+ (*message_)[strings::msg_params][strings::system_capability_type] =
+ mobile_apis::SystemCapabilityType::REMOTE_CONTROL;
+
+ EXPECT_CALL(*mock_app_, is_remote_control_supported()).WillOnce(Return(true));
+ EXPECT_CALL(mock_hmi_capabilities_, is_rc_cooperating())
+ .WillOnce(Return(true));
+
+ smart_objects::SmartObjectSPtr system_remotecontrol_capabilities(
+ std::make_shared<smart_objects::SmartObject>());
+ EXPECT_CALL(mock_hmi_capabilities_, rc_capability())
+ .Times(2)
+ .WillRepeatedly(Return(system_remotecontrol_capabilities));
+
+ EXPECT_CALL(
+ mock_rpc_service_,
+ ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS),
+ Command::CommandSource::SOURCE_SDL));
+
+ ASSERT_TRUE(command_->Init());
+ command_->Run();
+}
+
+TEST_F(GetSystemCapabilityRequestTest,
+ Run_GetSystemDisplayCapabilities_REMOTECONTROL_DISALLOWEDResultCode) {
+ (*message_)[strings::msg_params][strings::system_capability_type] =
+ mobile_apis::SystemCapabilityType::REMOTE_CONTROL;
+
+ EXPECT_CALL(*mock_app_, is_remote_control_supported())
+ .WillOnce(Return(false));
+ EXPECT_CALL(
+ mock_rpc_service_,
+ ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::DISALLOWED),
+ Command::CommandSource::SOURCE_SDL));
+
+ ASSERT_TRUE(command_->Init());
+ command_->Run();
+}
+
+TEST_F(GetSystemCapabilityRequestTest,
+ Run_GetSystemDisplayCapabilities_APPSERVICES_SUCCESSResultCode) {
+ (*message_)[strings::msg_params][strings::system_capability_type] =
+ mobile_apis::SystemCapabilityType::APP_SERVICES;
+
+ ON_CALL(app_mngr_, GetAppServiceManager())
+ .WillByDefault(ReturnPointee(mock_app_service_mngr_));
+
+ std::vector<smart_objects::SmartObject> app_services;
+ EXPECT_CALL(*mock_app_service_mngr_, GetAllServiceRecords())
+ .WillOnce(Return(app_services));
+
+ ON_CALL(*application_manager::MockMessageHelper::message_helper_mock(),
+ CreateAppServiceCapabilities(app_services))
+ .WillByDefault(Return(smart_objects::SmartObject()));
+
+ EXPECT_CALL(
+ mock_rpc_service_,
+ ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS),
+ Command::CommandSource::SOURCE_SDL));
+
+ ASSERT_TRUE(command_->Init());
+ command_->Run();
+}
+
+TEST_F(GetSystemCapabilityRequestTest,
+ Run_GetSystemDisplayCapabilities_SEATLOCATION_SUCCESSResultCode) {
+ (*message_)[strings::msg_params][strings::system_capability_type] =
+ mobile_apis::SystemCapabilityType::SEAT_LOCATION;
+
+ smart_objects::SmartObjectSPtr system_seatlocation_capabilities(
+ std::make_shared<smart_objects::SmartObject>());
+ EXPECT_CALL(mock_hmi_capabilities_, seat_location_capability())
+ .Times(2)
+ .WillRepeatedly(Return(system_seatlocation_capabilities));
+
+ EXPECT_CALL(
+ mock_rpc_service_,
+ ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS),
+ Command::CommandSource::SOURCE_SDL));
+
+ ASSERT_TRUE(command_->Init());
+ command_->Run();
+}
+
+TEST_F(GetSystemCapabilityRequestTest,
+ Run_GetSystemDisplayCapabilities_DRIVERDISTRACTION_SUCCESSResultCode) {
+ (*message_)[strings::msg_params][strings::system_capability_type] =
+ mobile_apis::SystemCapabilityType::DRIVER_DISTRACTION;
+
+ smart_objects::SmartObjectSPtr system_driverdistraction_capabilities(
+ std::make_shared<smart_objects::SmartObject>());
+ EXPECT_CALL(mock_hmi_capabilities_, driver_distraction_capability())
+ .Times(2)
+ .WillRepeatedly(Return(system_driverdistraction_capabilities));
+
+ EXPECT_CALL(
+ mock_rpc_service_,
+ ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS),
+ Command::CommandSource::SOURCE_SDL));
+
+ ASSERT_TRUE(command_->Init());
+ command_->Run();
+}
+
} // namespace get_system_capability_request_test
} // namespace mobile_commands_test
} // namespace commands_test