summaryrefslogtreecommitdiff
path: root/src/components/application_manager/test/application_manager_impl_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/application_manager/test/application_manager_impl_test.cc')
-rw-r--r--src/components/application_manager/test/application_manager_impl_test.cc104
1 files changed, 103 insertions, 1 deletions
diff --git a/src/components/application_manager/test/application_manager_impl_test.cc b/src/components/application_manager/test/application_manager_impl_test.cc
index 1f0b705f41..cc6c1418c4 100644
--- a/src/components/application_manager/test/application_manager_impl_test.cc
+++ b/src/components/application_manager/test/application_manager_impl_test.cc
@@ -105,6 +105,13 @@ const std::string kAppName = "appName";
const WindowID kDefaultWindowId =
mobile_apis::PredefinedWindows::DEFAULT_WINDOW;
+typedef MockMessageHelper::MockServiceStatusUpdateNotificationBuilder*
+ MockServiceStatusUpdatePtr;
+typedef hmi_apis::Common_ServiceUpdateReason::eType ServiceUpdateReason;
+typedef hmi_apis::Common_ServiceType::eType ServiceType;
+typedef hmi_apis::Common_ServiceEvent::eType ServiceEvent;
+typedef utils::Optional<ServiceUpdateReason> UpdateReasonOptional;
+
#if defined(CLOUD_APP_WEBSOCKET_TRANSPORT_SUPPORT)
// Cloud application params
const std::string kEndpoint = "endpoint";
@@ -119,7 +126,20 @@ const bool kEnabled = true;
#endif // CLOUD_APP_WEBSOCKET_TRANSPORT_SUPPORT
} // namespace
-class ApplicationManagerImplTest : public ::testing::Test {
+struct ServiceStatus {
+ ServiceType service_type_;
+ ServiceEvent service_event_;
+ UpdateReasonOptional reason_;
+
+ ServiceStatus(ServiceType type,
+ ServiceEvent event,
+ UpdateReasonOptional reason)
+ : service_type_(type), service_event_(event), reason_(reason) {}
+};
+
+class ApplicationManagerImplTest
+ : public ::testing::Test,
+ public ::testing::WithParamInterface<ServiceStatus> {
public:
ApplicationManagerImplTest()
: app_id_(0u)
@@ -133,6 +153,8 @@ class ApplicationManagerImplTest : public ::testing::Test {
new MockAppServiceManager(mock_app_mngr_, mock_last_state_))
, mock_message_helper_(
application_manager::MockMessageHelper::message_helper_mock())
+ , mock_service_status_update_(application_manager::MockMessageHelper::
+ on_service_update_builder_mock())
{
#ifdef ENABLE_LOG
@@ -149,10 +171,17 @@ class ApplicationManagerImplTest : public ::testing::Test {
CreateAppManager();
ON_CALL(*mock_app_ptr_, app_id()).WillByDefault(Return(kConnectionKey));
ON_CALL(*mock_app_ptr_, device()).WillByDefault(Return(kDeviceId));
+ ON_CALL(mock_session_observer_, GetDataOnSessionKey(_, _, _, _))
+ .WillByDefault(DoAll(SetArgPointee<3u>(kDeviceId), Return(0)));
ON_CALL(mock_connection_handler_, GetDataOnSessionKey(_, _, _, &kDeviceId))
.WillByDefault(DoAll(SetArgPointee<3u>(app_id_), Return(0)));
ON_CALL(mock_connection_handler_, get_session_observer())
.WillByDefault(ReturnRef(mock_session_observer_));
+ std::unique_ptr<rpc_service::RPCService> unique_rpc_service(
+ new MockRPCService);
+ app_manager_impl_->SetRPCService(unique_rpc_service);
+ mock_rpc_service_ =
+ static_cast<MockRPCService*>(&(app_manager_impl_->GetRPCService()));
app_manager_impl_->SetMockRPCService(mock_rpc_service_);
app_manager_impl_->resume_controller().set_resumption_storage(
mock_storage_);
@@ -250,11 +279,83 @@ class ApplicationManagerImplTest : public ::testing::Test {
std::unique_ptr<am::ApplicationManagerImpl> app_manager_impl_;
MockAppServiceManager* mock_app_service_manager_;
application_manager::MockMessageHelper* mock_message_helper_;
+ MockServiceStatusUpdatePtr mock_service_status_update_;
std::shared_ptr<MockApplication> mock_app_ptr_;
NiceMock<protocol_handler_test::MockProtocolHandler> mock_protocol_handler_;
};
+INSTANTIATE_TEST_CASE_P(
+ ProcessServiceStatusUpdate_REQUEST_ACCEPTED,
+ ApplicationManagerImplTest,
+ ::testing::Values(ServiceStatus(ServiceType::AUDIO,
+ ServiceEvent::REQUEST_ACCEPTED,
+ UpdateReasonOptional::EMPTY),
+ ServiceStatus(ServiceType::VIDEO,
+ ServiceEvent::REQUEST_ACCEPTED,
+ UpdateReasonOptional::EMPTY),
+ ServiceStatus(ServiceType::RPC,
+ ServiceEvent::REQUEST_ACCEPTED,
+ UpdateReasonOptional::EMPTY)));
+
+INSTANTIATE_TEST_CASE_P(
+ ProcessServiceStatusUpdate_REQUEST_RECEIVED,
+ ApplicationManagerImplTest,
+ ::testing::Values(ServiceStatus(ServiceType::AUDIO,
+ ServiceEvent::REQUEST_RECEIVED,
+ UpdateReasonOptional::EMPTY),
+ ServiceStatus(ServiceType::VIDEO,
+ ServiceEvent::REQUEST_RECEIVED,
+ UpdateReasonOptional::EMPTY),
+ ServiceStatus(ServiceType::RPC,
+ ServiceEvent::REQUEST_RECEIVED,
+ UpdateReasonOptional::EMPTY)));
+
+INSTANTIATE_TEST_CASE_P(
+ ProcessServiceStatusUpdate_REQUEST_REJECTED,
+ ApplicationManagerImplTest,
+ ::testing::Values(ServiceStatus(ServiceType::AUDIO,
+ ServiceEvent::REQUEST_REJECTED,
+ UpdateReasonOptional::EMPTY),
+ ServiceStatus(ServiceType::VIDEO,
+ ServiceEvent::REQUEST_REJECTED,
+ UpdateReasonOptional::EMPTY),
+ ServiceStatus(ServiceType::RPC,
+ ServiceEvent::REQUEST_REJECTED,
+ UpdateReasonOptional::EMPTY)));
+
+TEST_P(ApplicationManagerImplTest,
+ ProcessServiceStatusUpdate_SendMessageToHMI) {
+ smart_objects::SmartObjectSPtr notification_(
+ new smart_objects::SmartObject(smart_objects::SmartType_Map));
+ (*notification_)[strings::msg_params][hmi_notification::service_type] =
+ GetParam().service_type_;
+ (*notification_)[strings::msg_params][hmi_notification::service_event] =
+ GetParam().service_event_;
+ (*notification_)[strings::msg_params][strings::app_id] = kConnectionKey;
+
+ AddMockApplication();
+
+ ON_CALL(*mock_app_ptr_, app_id()).WillByDefault(Return(kConnectionKey));
+ ON_CALL(*mock_service_status_update_,
+ CreateBuilder(GetParam().service_type_, GetParam().service_event_))
+ .WillByDefault(Return(*mock_service_status_update_));
+ ON_CALL(*mock_service_status_update_, AddAppID(kConnectionKey))
+ .WillByDefault(ReturnRef(*mock_service_status_update_));
+ ON_CALL(*mock_service_status_update_, AddServiceUpdateReason(_))
+ .WillByDefault(ReturnRef(*mock_service_status_update_));
+ ON_CALL(*mock_service_status_update_, notification())
+ .WillByDefault(Return(notification_));
+
+ EXPECT_CALL(*mock_rpc_service_, ManageHMICommand(notification_))
+ .WillOnce(Return(true));
+
+ app_manager_impl_->ProcessServiceStatusUpdate(kConnectionKey,
+ GetParam().service_type_,
+ GetParam().service_event_,
+ GetParam().reason_);
+}
+
TEST_F(ApplicationManagerImplTest, ProcessQueryApp_ExpectSuccess) {
using namespace ns_smart_device_link::ns_smart_objects;
SmartObject app_data;
@@ -844,6 +945,7 @@ TEST_F(ApplicationManagerImplTest,
std::shared_ptr<MockApplication> nonswitching_app_ptr =
std::make_shared<MockApplication>();
+
const std::string nonswitching_device_id = "nonswitching";
const std::string nonswitching_device_id_hash =
encryption::MakeHash(nonswitching_device_id);