From 9808e0ce656b103fa3ddcf90c76031d7e4a87452 Mon Sep 17 00:00:00 2001 From: "Mykhailo Vorobiov (GitHub)" <61186891+mvorobio@users.noreply.github.com> Date: Thu, 2 Apr 2020 10:25:17 +0300 Subject: [PATCH 1/4] Update SetInteriorVehicleDataRequestTests Check if read only parameters are cut off before sending a message to HMI. --- .../set_interior_vehicle_data_request_test.cc | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc index 5a822a2fe49..31dd4a479fd 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc @@ -48,6 +48,7 @@ using application_manager::ApplicationSet; using application_manager::commands::MessageSharedPtr; +using rc_rpc_plugin::commands::SetInteriorVehicleDataRequest; using test::components::application_manager_test::MockApplication; using test::components::application_manager_test::MockApplicationManager; using test::components::commands_test::CommandRequestTest; @@ -56,6 +57,7 @@ using test::components::commands_test::HMIResultCodeIs; using ::testing::_; using ::testing::NiceMock; using ::testing::Return; +using ::testing::ReturnRef; using ::testing::SaveArg; namespace { @@ -186,24 +188,23 @@ TEST_F(SetInteriorVehicleDataRequestTest, TEST_F( SetInteriorVehicleDataRequestTest, Execute_ValidWithSettableAndReadOnlyParams_ExpectCutReadOnlyAndResendToHMI) { - // Arrange + using namespace rc_rpc_plugin::message_params; - MessageSharedPtr mobile_message = CreateBasicMessage(); - ns_smart_device_link::ns_smart_objects::SmartObject& msg_params = + auto mobile_message = CreateBasicMessage(); + auto& msg_params = (*mobile_message)[application_manager::strings::msg_params]; - msg_params[message_params::kModuleData][message_params::kModuleType] = - mobile_apis::ModuleType::RADIO; - smart_objects::SmartObject radio_control_data(smart_objects::SmartType_Map); - radio_control_data[message_params::kState] = true; - radio_control_data[message_params::kRadioEnable] = true; - msg_params[message_params::kModuleData][message_params::kRadioControlData] = - radio_control_data; + msg_params[kModuleData][kModuleType] = mobile_apis::ModuleType::RADIO; + auto& control_data = msg_params[kModuleData][kRadioControlData]; + control_data[kState] = true; + control_data[kRadioEnable] = true; - // Expectations - EXPECT_CALL(mock_policy_handler_, CheckModule(kPolicyAppId, _)) - .WillOnce(Return(rc_rpc_plugin::TypeAccess::kAllowed)); + ON_CALL(mock_rc_capabilities_manager_, ControlDataForType(_, _)) + .WillByDefault(ReturnRef(control_data)); + ON_CALL(mock_rc_capabilities_manager_, AreReadOnlyParamsPresent(_, _, _)) + .WillByDefault(Return(true)); - EXPECT_CALL(app_mngr_, RemoveHMIFakeParameters(_, _)); + EXPECT_CALL(mock_policy_handler_, CheckModule(kPolicyAppId, _)) + .WillOnce(Return(true)); EXPECT_CALL( mock_rpc_service_, @@ -211,13 +212,12 @@ TEST_F( HMIResultCodeIs(hmi_apis::FunctionID::RC_SetInteriorVehicleData), _)) .WillOnce(Return(true)); - // Act - std::shared_ptr - command = CreateRCCommand< - rc_rpc_plugin::commands::SetInteriorVehicleDataRequest>( - mobile_message); + auto command = CreateRCCommand(mobile_message); ASSERT_TRUE(command->Init()); command->Run(); + + EXPECT_FALSE(control_data.keyExists(kState)); + EXPECT_TRUE(control_data.keyExists(kRadioEnable)); } TEST_F( From 794597b6469711802915fb788ab9bb4fec9ae004 Mon Sep 17 00:00:00 2001 From: "Mykhailo Vorobiov (GitHub)" <61186891+mvorobio@users.noreply.github.com> Date: Thu, 16 Apr 2020 10:10:20 +0300 Subject: [PATCH 2/4] fixup! Update SetInteriorVehicleDataRequestTests --- .../set_interior_vehicle_data_request_test.cc | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc index 31dd4a479fd..65cf4929e21 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc @@ -157,20 +157,20 @@ class SetInteriorVehicleDataRequestTest TEST_F(SetInteriorVehicleDataRequestTest, Execute_ValidWithoutReadOnlyParams_ExpectResendToHMI) { + using namespace rc_rpc_plugin::message_params; + // Arrange - MessageSharedPtr mobile_message = CreateBasicMessage(); - ns_smart_device_link::ns_smart_objects::SmartObject& msg_params = + auto mobile_message = CreateBasicMessage(); + auto& msg_params = (*mobile_message)[application_manager::strings::msg_params]; - msg_params[message_params::kModuleData][message_params::kModuleType] = - mobile_apis::ModuleType::CLIMATE; - smart_objects::SmartObject climate_control_data(smart_objects::SmartType_Map); - climate_control_data[message_params::kFanSpeed] = 10; + msg_params[kModuleData][kModuleType] = mobile_apis::ModuleType::CLIMATE; + auto& control_data = msg_params[kModuleData][kClimateControlData]; + const uint64_t fan_speed = 10; + control_data[kFanSpeed] = fan_speed; - msg_params[message_params::kModuleData][message_params::kClimateControlData] = - climate_control_data; // Expectations EXPECT_CALL(mock_policy_handler_, CheckModule(kPolicyAppId, _)) - .WillOnce(Return(rc_rpc_plugin::TypeAccess::kAllowed)); + .WillOnce(Return(true)); EXPECT_CALL( mock_rpc_service_, @@ -178,11 +178,12 @@ TEST_F(SetInteriorVehicleDataRequestTest, HMIResultCodeIs(hmi_apis::FunctionID::RC_SetInteriorVehicleData), _)) .WillOnce(Return(true)); // Act - auto command = - CreateRCCommand( - mobile_message); + auto command = CreateRCCommand(mobile_message); ASSERT_TRUE(command->Init()); command->Run(); + + EXPECT_TRUE(control_data.keyExists(kFanSpeed) && + fan_speed == control_data[kFanSpeed].asUInt()); } TEST_F( @@ -190,19 +191,22 @@ TEST_F( Execute_ValidWithSettableAndReadOnlyParams_ExpectCutReadOnlyAndResendToHMI) { using namespace rc_rpc_plugin::message_params; + // Arrange auto mobile_message = CreateBasicMessage(); auto& msg_params = (*mobile_message)[application_manager::strings::msg_params]; msg_params[kModuleData][kModuleType] = mobile_apis::ModuleType::RADIO; auto& control_data = msg_params[kModuleData][kRadioControlData]; control_data[kState] = true; - control_data[kRadioEnable] = true; + const auto radio_enable = true; + control_data[kRadioEnable] = radio_enable; ON_CALL(mock_rc_capabilities_manager_, ControlDataForType(_, _)) .WillByDefault(ReturnRef(control_data)); ON_CALL(mock_rc_capabilities_manager_, AreReadOnlyParamsPresent(_, _, _)) .WillByDefault(Return(true)); + // Expectations EXPECT_CALL(mock_policy_handler_, CheckModule(kPolicyAppId, _)) .WillOnce(Return(true)); @@ -212,12 +216,14 @@ TEST_F( HMIResultCodeIs(hmi_apis::FunctionID::RC_SetInteriorVehicleData), _)) .WillOnce(Return(true)); + // Act auto command = CreateRCCommand(mobile_message); ASSERT_TRUE(command->Init()); command->Run(); EXPECT_FALSE(control_data.keyExists(kState)); - EXPECT_TRUE(control_data.keyExists(kRadioEnable)); + EXPECT_TRUE(control_data.keyExists(kRadioEnable) && + radio_enable == control_data[kRadioEnable].asBool()); } TEST_F( From 30f301a618a68f379d67d62adb12b354a002337f Mon Sep 17 00:00:00 2001 From: "Mykhailo Vorobiov (GitHub)" <61186891+mvorobio@users.noreply.github.com> Date: Wed, 22 Apr 2020 22:01:37 +0300 Subject: [PATCH 3/4] fixup! Update SetInteriorVehicleDataRequestTests --- .../commands/set_interior_vehicle_data_request_test.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc index 65cf4929e21..0e6cc2aaef6 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc @@ -165,7 +165,7 @@ TEST_F(SetInteriorVehicleDataRequestTest, (*mobile_message)[application_manager::strings::msg_params]; msg_params[kModuleData][kModuleType] = mobile_apis::ModuleType::CLIMATE; auto& control_data = msg_params[kModuleData][kClimateControlData]; - const uint64_t fan_speed = 10; + const uint64_t fan_speed = 10u; control_data[kFanSpeed] = fan_speed; // Expectations @@ -183,7 +183,7 @@ TEST_F(SetInteriorVehicleDataRequestTest, command->Run(); EXPECT_TRUE(control_data.keyExists(kFanSpeed) && - fan_speed == control_data[kFanSpeed].asUInt()); + control_data[kFanSpeed].asUInt() == fan_speed); } TEST_F( @@ -198,7 +198,7 @@ TEST_F( msg_params[kModuleData][kModuleType] = mobile_apis::ModuleType::RADIO; auto& control_data = msg_params[kModuleData][kRadioControlData]; control_data[kState] = true; - const auto radio_enable = true; + const bool radio_enable = true; control_data[kRadioEnable] = radio_enable; ON_CALL(mock_rc_capabilities_manager_, ControlDataForType(_, _)) @@ -223,7 +223,7 @@ TEST_F( EXPECT_FALSE(control_data.keyExists(kState)); EXPECT_TRUE(control_data.keyExists(kRadioEnable) && - radio_enable == control_data[kRadioEnable].asBool()); + control_data[kRadioEnable].asBool() == radio_enable); } TEST_F( From 715f26ad5f324d425b8a176cdb6d1c4b9f89a496 Mon Sep 17 00:00:00 2001 From: "Mykhailo Vorobiov (GitHub)" <61186891+mvorobio@users.noreply.github.com> Date: Tue, 28 Apr 2020 08:14:22 +0300 Subject: [PATCH 4/4] fixup! Update SetInteriorVehicleDataRequestTests --- .../test/commands/set_interior_vehicle_data_request_test.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc index 0e6cc2aaef6..b3c8eab4976 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc @@ -178,7 +178,8 @@ TEST_F(SetInteriorVehicleDataRequestTest, HMIResultCodeIs(hmi_apis::FunctionID::RC_SetInteriorVehicleData), _)) .WillOnce(Return(true)); // Act - auto command = CreateRCCommand(mobile_message); + const auto command = + CreateRCCommand(mobile_message); ASSERT_TRUE(command->Init()); command->Run(); @@ -217,7 +218,8 @@ TEST_F( .WillOnce(Return(true)); // Act - auto command = CreateRCCommand(mobile_message); + const auto command = + CreateRCCommand(mobile_message); ASSERT_TRUE(command->Init()); command->Run();