diff options
Diffstat (limited to 'src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_request_test.cc')
-rw-r--r-- | src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_request_test.cc | 167 |
1 files changed, 97 insertions, 70 deletions
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_request_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_request_test.cc index 123c22b944..532a62df3b 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_request_test.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_request_test.cc @@ -38,6 +38,8 @@ #include "gtest/gtest.h" #include "rc_rpc_plugin/mock/mock_interior_data_cache.h" #include "rc_rpc_plugin/mock/mock_interior_data_manager.h" +#include "rc_rpc_plugin/mock/mock_rc_capabilities_manager.h" +#include "rc_rpc_plugin/mock/mock_rc_consent_manager.h" #include "rc_rpc_plugin/mock/mock_resource_allocation_manager.h" #include "rc_rpc_plugin/rc_app_extension.h" #include "rc_rpc_plugin/rc_command_factory.h" @@ -74,7 +76,9 @@ const int32_t kConnectionKey = 5u; const uint32_t kAppId = 0u; const uint32_t kAppId2 = 1u; const int kModuleId = 153u; -const auto module_type = mobile_apis::ModuleType::RADIO; +const auto module_eType = mobile_apis::ModuleType::RADIO; +const auto module_type = "RADIO"; +const auto module_id = "eb7739ea-b263-4fe1-af9c-9311d1acac2d"; const int32_t time_frame_of_allowed_requests = 1; const uint32_t max_request_in_time_frame = 5u; } // namespace @@ -91,7 +95,8 @@ class GetInteriorVehicleDataRequestTest , rc_app_extention_(std::make_shared<RCAppExtension>(kModuleId)) , rc_app_extention2_(std::make_shared<RCAppExtension>(kModuleId)) , apps_lock_(std::make_shared<sync_primitives::Lock>()) - , apps_da_(apps_, apps_lock_) { + , apps_da_(apps_, apps_lock_) + , rc_capabilities_(smart_objects::SmartType::SmartType_Array) { ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kAppId)); ON_CALL(*mock_app2_, app_id()).WillByDefault(Return(kAppId2)); ON_CALL(*mock_app_, is_remote_control_supported()) @@ -125,6 +130,8 @@ class GetInteriorVehicleDataRequestTest std::pair<uint32_t, int32_t> frequency; frequency.first = max_request_in_time_frame; frequency.second = time_frame_of_allowed_requests; + smart_objects::SmartObject control_caps((smart_objects::SmartType_Array)); + rc_capabilities_[strings::kradioControlCapabilities] = control_caps; ON_CALL(app_mngr_, get_settings()) .WillByDefault(ReturnRef(app_mngr_settings_)); ON_CALL(app_mngr_settings_, get_interior_vehicle_data_frequency()) @@ -144,7 +151,7 @@ class GetInteriorVehicleDataRequestTest ON_CALL(app_mngr_, hmi_capabilities()) .WillByDefault(ReturnRef(mock_hmi_capabilities_)); ON_CALL(mock_hmi_capabilities_, rc_capability()) - .WillByDefault(Return(nullptr)); + .WillByDefault(Return(&rc_capabilities_)); ON_CALL(mock_policy_handler_, CheckHMIType( _, mobile_apis::AppHMIType::eType::REMOTE_CONTROL, nullptr)) @@ -153,6 +160,8 @@ class GetInteriorVehicleDataRequestTest .WillByDefault(Return(true)); ON_CALL(mock_allocation_manager_, is_rc_enabled()) .WillByDefault(Return(true)); + ON_CALL(mock_rc_capabilities_manager_, CheckIfModuleExistsInCapabilities(_)) + .WillByDefault(Return(true)); } template <class Command> @@ -164,7 +173,9 @@ class GetInteriorVehicleDataRequestTest mock_policy_handler_, mock_allocation_manager_, mock_interior_data_cache_, - mock_interior_data_manager_}; + mock_interior_data_manager_, + mock_rc_capabilities_manager_, + mock_rc_consent_manger_}; return std::make_shared<Command>(msg ? msg : msg = CreateMessage(), params); } @@ -182,6 +193,10 @@ class GetInteriorVehicleDataRequestTest application_manager::ApplicationSet apps_; const std::shared_ptr<sync_primitives::Lock> apps_lock_; DataAccessor<application_manager::ApplicationSet> apps_da_; + testing::NiceMock<rc_rpc_plugin_test::MockRCCapabilitiesManager> + mock_rc_capabilities_manager_; + smart_objects::SmartObject rc_capabilities_; + testing::NiceMock<MockRCConsentManager> mock_rc_consent_manger_; }; TEST_F(GetInteriorVehicleDataRequestTest, @@ -189,14 +204,16 @@ TEST_F(GetInteriorVehicleDataRequestTest, // Arrange MessageSharedPtr mobile_message = CreateBasicMessage(); (*mobile_message)[application_manager::strings::msg_params] - [message_params::kModuleType] = module_type; - ON_CALL(mock_interior_data_cache_, Contains(enums_value::kRadio)) + [message_params::kModuleType] = module_eType; + (*mobile_message)[application_manager::strings::msg_params] + [message_params::kModuleType] = module_id; + const ModuleUid module(module_type, module_id); + ON_CALL(mock_interior_data_cache_, Contains(module)) .WillByDefault(Return(false)); ON_CALL(mock_interior_data_manager_, CheckRequestsToHMIFrequency(_)) .WillByDefault(Return(true)); - std::shared_ptr<rc_rpc_plugin::commands::GetInteriorVehicleDataRequest> - command = CreateRCCommand< - rc_rpc_plugin::commands::GetInteriorVehicleDataRequest>( + auto command = + CreateRCCommand<rc_rpc_plugin::commands::GetInteriorVehicleDataRequest>( mobile_message); // Expectations @@ -216,16 +233,18 @@ TEST_F(GetInteriorVehicleDataRequestTest, // Arrange MessageSharedPtr mobile_message = CreateBasicMessage(); (*mobile_message)[application_manager::strings::msg_params] - [message_params::kModuleType] = module_type; + [message_params::kModuleType] = module_eType; + (*mobile_message)[application_manager::strings::msg_params] + [message_params::kModuleId] = module_id; (*mobile_message)[application_manager::strings::msg_params] [message_params::kSubscribe] = true; - ON_CALL(mock_interior_data_cache_, Contains(enums_value::kRadio)) + const ModuleUid module(module_type, module_id); + ON_CALL(mock_interior_data_cache_, Contains(module)) .WillByDefault(Return(false)); ON_CALL(mock_interior_data_manager_, CheckRequestsToHMIFrequency(_)) .WillByDefault(Return(true)); - std::shared_ptr<rc_rpc_plugin::commands::GetInteriorVehicleDataRequest> - command = CreateRCCommand< - rc_rpc_plugin::commands::GetInteriorVehicleDataRequest>( + auto command = + CreateRCCommand<rc_rpc_plugin::commands::GetInteriorVehicleDataRequest>( mobile_message); // Expectations @@ -243,10 +262,13 @@ TEST_F( GetInteriorVehicleDataRequestTest, Execute_ExpectMessageNotSentToHMI_SuccessSentToMobile_AppSubscribed_DataFromCache) { // Arrange - rc_app_extention_->SubscribeToInteriorVehicleData(enums_value::kRadio); + const ModuleUid module(module_type, module_id); + rc_app_extention_->SubscribeToInteriorVehicleData(module); MessageSharedPtr mobile_message = CreateBasicMessage(); (*mobile_message)[application_manager::strings::msg_params] - [message_params::kModuleType] = module_type; + [message_params::kModuleType] = module_eType; + (*mobile_message)[application_manager::strings::msg_params] + [message_params::kModuleId] = module_id; smart_objects::SmartObject radio_data; smart_objects::SmartObject sis_data; smart_objects::SmartObject gps_data; @@ -261,15 +283,14 @@ TEST_F( radio_data[message_params::kBand] = enums_value::kAM; radio_data[message_params::kSisData] = sis_data; - std::shared_ptr<rc_rpc_plugin::commands::GetInteriorVehicleDataRequest> - command = CreateRCCommand< - rc_rpc_plugin::commands::GetInteriorVehicleDataRequest>( + auto command = + CreateRCCommand<rc_rpc_plugin::commands::GetInteriorVehicleDataRequest>( mobile_message); // Expectations - EXPECT_CALL(mock_interior_data_cache_, Contains(enums_value::kRadio)) + EXPECT_CALL(mock_interior_data_cache_, Contains(module)) .WillOnce(Return(true)); - EXPECT_CALL(mock_interior_data_cache_, Retrieve(enums_value::kRadio)) + EXPECT_CALL(mock_interior_data_cache_, Retrieve(module)) .WillOnce(Return(radio_data)); EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).Times(0); MessageSharedPtr command_result; @@ -291,13 +312,16 @@ TEST_F( TEST_F( GetInteriorVehicleDataRequestTest, - Execute_ExpectCorrectMessageSentToHMI_LastAppSubscribedUnsubscibe_ClearCache) { + Execute_ExpectCorrectMessageSentToHMI_LastAppSubscribedUnsubscribe_ClearCache) { // Arrange MessageSharedPtr mobile_message = CreateBasicMessage(); (*mobile_message)[application_manager::strings::msg_params] - [message_params::kModuleType] = module_type; + [message_params::kModuleType] = module_eType; (*mobile_message)[application_manager::strings::msg_params] [message_params::kSubscribe] = false; + (*mobile_message)[application_manager::strings::msg_params] + [message_params::kModuleId] = module_id; + const ModuleUid module(module_type, module_id); MessageSharedPtr hmi_response = CreateBasicMessage(); ns_smart_device_link::ns_smart_objects::SmartObject& hmi_msg_params = @@ -306,9 +330,11 @@ TEST_F( hmi_apis::Common_Result::SUCCESS; hmi_msg_params[application_manager::hmi_response::code] = response_code; hmi_msg_params[application_manager::strings::connection_key] = kConnectionKey; + hmi_msg_params[message_params::kModuleData][message_params::kModuleId] = + module_id; apps_.insert(mock_app_); - rc_app_extention_->SubscribeToInteriorVehicleData(enums_value::kRadio); + rc_app_extention_->SubscribeToInteriorVehicleData(module); ON_CALL(app_mngr_, applications()).WillByDefault(Return(apps_da_)); ON_CALL(mock_interior_data_manager_, CheckRequestsToHMIFrequency(_)) .WillByDefault(Return(true)); @@ -324,12 +350,11 @@ TEST_F( ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS), _)) .WillOnce(Return(true)); - EXPECT_CALL(mock_interior_data_cache_, Remove(enums_value::kRadio)); + EXPECT_CALL(mock_interior_data_cache_, Remove(module)); // Act - std::shared_ptr<rc_rpc_plugin::commands::GetInteriorVehicleDataRequest> - command = CreateRCCommand< - rc_rpc_plugin::commands::GetInteriorVehicleDataRequest>( + auto command = + CreateRCCommand<rc_rpc_plugin::commands::GetInteriorVehicleDataRequest>( mobile_message); ASSERT_TRUE(command->Init()); command->Run(); @@ -344,28 +369,30 @@ TEST_F(GetInteriorVehicleDataRequestTest, // Arrange MessageSharedPtr mobile_message = CreateBasicMessage(); (*mobile_message)[application_manager::strings::msg_params] - [message_params::kModuleType] = module_type; + [message_params::kModuleType] = module_eType; (*mobile_message)[application_manager::strings::msg_params] [message_params::kSubscribe] = false; + (*mobile_message)[application_manager::strings::msg_params] + [message_params::kModuleId] = module_id; + const ModuleUid module(module_type, module_id); apps_.insert(mock_app_); apps_.insert(mock_app2_); - rc_app_extention_->SubscribeToInteriorVehicleData(enums_value::kRadio); - rc_app_extention2_->SubscribeToInteriorVehicleData(enums_value::kRadio); + rc_app_extention_->SubscribeToInteriorVehicleData(module); + rc_app_extention2_->SubscribeToInteriorVehicleData(module); smart_objects::SmartObject radio_data; radio_data[message_params::kBand] = enums_value::kAM; ON_CALL(app_mngr_, applications()).WillByDefault(Return(apps_da_)); - std::shared_ptr<rc_rpc_plugin::commands::GetInteriorVehicleDataRequest> - command = CreateRCCommand< - rc_rpc_plugin::commands::GetInteriorVehicleDataRequest>( + auto command = + CreateRCCommand<rc_rpc_plugin::commands::GetInteriorVehicleDataRequest>( mobile_message); // Expectations - EXPECT_CALL(mock_interior_data_cache_, Contains(enums_value::kRadio)) + EXPECT_CALL(mock_interior_data_cache_, Contains(module)) .WillOnce(Return(true)); - EXPECT_CALL(mock_interior_data_cache_, Retrieve(enums_value::kRadio)) + EXPECT_CALL(mock_interior_data_cache_, Retrieve(module)) .WillOnce(Return(radio_data)); EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).Times(0); @@ -380,8 +407,8 @@ TEST_F(GetInteriorVehicleDataRequestTest, command->Run(); // Assert - EXPECT_FALSE( - rc_app_extention_->IsSubscibedToInteriorVehicleData(enums_value::kRadio)); + EXPECT_FALSE(rc_app_extention_->IsSubscribedToInteriorVehicleDataOfType( + enums_value::kRadio)); EXPECT_EQ((*command_result)[application_manager::strings::msg_params] [message_params::kModuleData] [message_params::kRadioControlData], @@ -395,14 +422,12 @@ TEST_F( MessageSharedPtr mobile_message = CreateBasicMessage(); ns_smart_device_link::ns_smart_objects::SmartObject& msg_params = (*mobile_message)[application_manager::strings::msg_params]; - msg_params[message_params::kModuleType] = mobile_apis::ModuleType::RADIO; - std::shared_ptr<rc_rpc_plugin::commands::GetInteriorVehicleDataRequest> - command = CreateRCCommand< - rc_rpc_plugin::commands::GetInteriorVehicleDataRequest>( + msg_params[message_params::kModuleType] = module_eType; + auto command = + CreateRCCommand<rc_rpc_plugin::commands::GetInteriorVehicleDataRequest>( mobile_message); - smart_objects::SmartObject rc_capabilities; ON_CALL(mock_hmi_capabilities_, rc_capability()) - .WillByDefault(Return(&rc_capabilities)); + .WillByDefault(Return(nullptr)); // Expectations EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).Times(0); @@ -423,10 +448,9 @@ TEST_F( MessageSharedPtr mobile_message = CreateBasicMessage(); ns_smart_device_link::ns_smart_objects::SmartObject& msg_params = (*mobile_message)[application_manager::strings::msg_params]; - msg_params[message_params::kModuleType] = mobile_apis::ModuleType::RADIO; - std::shared_ptr<rc_rpc_plugin::commands::GetInteriorVehicleDataRequest> - command = CreateRCCommand< - rc_rpc_plugin::commands::GetInteriorVehicleDataRequest>( + msg_params[message_params::kModuleType] = module_eType; + auto command = + CreateRCCommand<rc_rpc_plugin::commands::GetInteriorVehicleDataRequest>( mobile_message); ON_CALL(mock_policy_handler_, CheckModule(_, _)).WillByDefault(Return(false)); @@ -451,12 +475,14 @@ TEST_F(GetInteriorVehicleDataRequestTest, // Arrange MessageSharedPtr mobile_message = CreateBasicMessage(); auto& msg_params = (*mobile_message)[strings::msg_params]; - msg_params[message_params::kModuleType] = module_type; + msg_params[message_params::kModuleType] = module_eType; MessageSharedPtr hmi_response_message = CreateBasicMessage(); auto& hmi_response_params = (*hmi_response_message)[strings::msg_params]; hmi_response_params[hmi_response::code] = hmi_apis::Common_Result::SUCCESS; hmi_response_params[strings::connection_key] = kConnectionKey; + hmi_response_params[message_params::kModuleData][message_params::kModuleId] = + module_id; ON_CALL(mock_interior_data_cache_, Contains(_)).WillByDefault(Return(false)); ON_CALL(mock_interior_data_manager_, CheckRequestsToHMIFrequency(_)) @@ -494,7 +520,7 @@ TEST_F(GetInteriorVehicleDataRequestTest, MessageSharedPtr mobile_message = CreateBasicMessage(); auto& msg_params = (*mobile_message)[application_manager::strings::msg_params]; - msg_params[message_params::kModuleType] = module_type; + msg_params[message_params::kModuleType] = module_eType; MessageSharedPtr hmi_message = CreateBasicMessage(); auto& hmi_msg_params = (*hmi_message)[strings::params]; @@ -526,14 +552,16 @@ TEST_F(GetInteriorVehicleDataRequestTest, } TEST_F(GetInteriorVehicleDataRequestTest, - OnEvent_InvalidHmiResponse_DontUnsubscibeLastApp_NoClearCache) { + OnEvent_InvalidHmiResponse_DontUnsubscribeLastApp_NoClearCache) { // Arrange MessageSharedPtr mobile_message = CreateBasicMessage(); (*mobile_message)[application_manager::strings::msg_params] - [message_params::kModuleType] = module_type; + [message_params::kModuleType] = module_eType; + (*mobile_message)[application_manager::strings::msg_params] + [message_params::kModuleId] = module_id; (*mobile_message)[application_manager::strings::msg_params] [message_params::kSubscribe] = false; - + const ModuleUid module(module_type, module_id); MessageSharedPtr hmi_response = CreateBasicMessage(); ns_smart_device_link::ns_smart_objects::SmartObject& hmi_msg_params = (*hmi_response)[application_manager::strings::params]; @@ -542,7 +570,7 @@ TEST_F(GetInteriorVehicleDataRequestTest, hmi_msg_params[application_manager::strings::connection_key] = kConnectionKey; apps_.insert(mock_app_); - rc_app_extention_->SubscribeToInteriorVehicleData(enums_value::kRadio); + rc_app_extention_->SubscribeToInteriorVehicleData(module); ON_CALL(app_mngr_, applications()).WillByDefault(Return(apps_da_)); ON_CALL(mock_interior_data_manager_, CheckRequestsToHMIFrequency(_)) .WillByDefault(Return(true)); @@ -561,9 +589,8 @@ TEST_F(GetInteriorVehicleDataRequestTest, EXPECT_CALL(mock_interior_data_cache_, Clear()).Times(0); // Act - std::shared_ptr<rc_rpc_plugin::commands::GetInteriorVehicleDataRequest> - command = CreateRCCommand< - rc_rpc_plugin::commands::GetInteriorVehicleDataRequest>( + auto command = + CreateRCCommand<rc_rpc_plugin::commands::GetInteriorVehicleDataRequest>( mobile_message); ASSERT_TRUE(command->Init()); command->Run(); @@ -573,32 +600,33 @@ TEST_F(GetInteriorVehicleDataRequestTest, command->on_event(event); // Assert - EXPECT_TRUE( - rc_app_extention_->IsSubscibedToInteriorVehicleData(enums_value::kRadio)); + EXPECT_TRUE(rc_app_extention_->IsSubscribedToInteriorVehicleData(module)); } TEST_F(GetInteriorVehicleDataRequestTest, Execute_ExpectRejectDuToRequestLimitation_NoCahce) { // Arrange - rc_app_extention_->UnsubscribeFromInteriorVehicleData(enums_value::kRadio); + rc_app_extention_->UnsubscribeFromInteriorVehicleDataOfType( + enums_value::kRadio); MessageSharedPtr mobile_message = CreateBasicMessage(); (*mobile_message)[application_manager::strings::msg_params] - [message_params::kModuleType] = module_type; + [message_params::kModuleType] = module_eType; + (*mobile_message)[application_manager::strings::msg_params] + [message_params::kModuleId] = module_id; smart_objects::SmartObject radio_data; radio_data[message_params::kBand] = enums_value::kAM; - std::shared_ptr<rc_rpc_plugin::commands::GetInteriorVehicleDataRequest> - command = CreateRCCommand< - rc_rpc_plugin::commands::GetInteriorVehicleDataRequest>( + auto command = + CreateRCCommand<rc_rpc_plugin::commands::GetInteriorVehicleDataRequest>( mobile_message); + const ModuleUid module(module_type, module_id); size_t i = 0; for (; i <= max_request_in_time_frame; ++i) { // Expectations EXPECT_CALL(mock_interior_data_manager_, - CheckRequestsToHMIFrequency(enums_value::kRadio)) + CheckRequestsToHMIFrequency(module)) .WillOnce(Return(true)); - EXPECT_CALL(mock_interior_data_manager_, - StoreRequestToHMITime(enums_value::kRadio)); - EXPECT_CALL(mock_interior_data_cache_, Contains(enums_value::kRadio)) + EXPECT_CALL(mock_interior_data_manager_, StoreRequestToHMITime(module)); + EXPECT_CALL(mock_interior_data_cache_, Contains(module)) .WillRepeatedly(Return(false)); EXPECT_CALL( mock_rpc_service_, @@ -612,8 +640,7 @@ TEST_F(GetInteriorVehicleDataRequestTest, } // Expectations - EXPECT_CALL(mock_interior_data_manager_, - CheckRequestsToHMIFrequency(enums_value::kRadio)) + EXPECT_CALL(mock_interior_data_manager_, CheckRequestsToHMIFrequency(module)) .WillOnce(Return(false)); EXPECT_CALL( mock_rpc_service_, |