Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update SetInteriorVehicleDataRequestTests #2

Closed

Conversation

mvorobio
Copy link
Owner

@mvorobio mvorobio commented Apr 10, 2020

This PR is not ready for review.

Risk

This PR makes no API changes.

Summary

The PR adds a check whether read only parameters are cut off before sending a message to
HMI in unit tests for SetInteriorVehicleDataRequest.

Tasks Remaining:

  • Add test cases for all RC modules
  • Add test cases for all flows

CLA

Check if read only parameters are cut off before sending a message to
HMI.
@@ -186,38 +188,36 @@ TEST_F(SetInteriorVehicleDataRequestTest,
TEST_F(
SetInteriorVehicleDataRequestTest,
Execute_ValidWithSettableAndReadOnlyParams_ExpectCutReadOnlyAndResendToHMI) {
// Arrange

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mvorobio What is the reason to remove such comments?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AByzhynar These comments are useless enough, because a pattern they introduce is sometimes difficult to follow. E.g. expectations from the ASSERT section could be placed around the ACT section.
In other words, such comments rarely give useful info but add unnecessary lines of code and sometimes even confuse.
But it's my personal opinion only. I wouldn't argue if these comments are required by some reasons.

Copy link

@AByzhynar AByzhynar Apr 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mvorobio Please return them back. It is the full responsibility of the developer to put the code to the right section.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AByzhynar please check 794597b


// Expectations

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mvorobio What is the reason to remove such comments?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AByzhynar please check 794597b


EXPECT_CALL(
mock_rpc_service_,
ManageHMICommand(
HMIResultCodeIs(hmi_apis::FunctionID::RC_SetInteriorVehicleData), _))
.WillOnce(Return(true));

// Act

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mvorobio What is the reason to remove such comments?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AByzhynar please check 794597b


EXPECT_CALL(app_mngr_, RemoveHMIFakeParameters(_, _));
EXPECT_CALL(mock_policy_handler_, CheckModule(kPolicyAppId, _))
.WillOnce(Return(true));

EXPECT_CALL(
mock_rpc_service_,
ManageHMICommand(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mvorobio Do we also need to check what is contained inside message?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ydementieiev please check 794597b

@@ -186,38 +188,36 @@ TEST_F(SetInteriorVehicleDataRequestTest,
TEST_F(
SetInteriorVehicleDataRequestTest,
Execute_ValidWithSettableAndReadOnlyParams_ExpectCutReadOnlyAndResendToHMI) {
// Arrange
Copy link

@AByzhynar AByzhynar Apr 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mvorobio Please return them back. It is the full responsibility of the developer to put the code to the right section.

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;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mvorobio Don't use implicit conversions. Please add postfix u to the number.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AByzhynar please check 30f301a
I'd prefer const auto fan_speed = static_cast<uint64_t>(10);

ASSERT_TRUE(command->Init());
command->Run();

EXPECT_TRUE(control_data.keyExists(kFanSpeed) &&

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mvorobio please transform this expression to 2 separate expectations.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AByzhynar this is a single expectation - just ensures that a key exists prior an attempt to retrieve a value.

ASSERT_TRUE(command->Init());
command->Run();

EXPECT_TRUE(control_data.keyExists(kFanSpeed) &&
fan_speed == control_data[kFanSpeed].asUInt());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mvorobio switch comparables please

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AByzhynar please check 30f301a
I think it doesn't matter due to fan_speed is constant.

msg_params[kModuleData][kModuleType] = mobile_apis::ModuleType::RADIO;
auto& control_data = msg_params[kModuleData][kRadioControlData];
control_data[kState] = true;
const auto radio_enable = true;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mvorobio can't see any reason to use auto for explicit bool value.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AByzhynar please check 30f301a
There is no obvious benefit of auto instead of explicit bool in this case. But I think use of auto where it is possible at least helps think about objects not their types.

ASSERT_TRUE(command->Init());
command->Run();

EXPECT_FALSE(control_data.keyExists(kState));
EXPECT_TRUE(control_data.keyExists(kRadioEnable) &&

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mvorobio please transform this expression to 2 separate expectations.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AByzhynar please see above.

@mvorobio
Copy link
Owner Author

The changes moved to LuxoftSDL#19

@mvorobio mvorobio closed this Apr 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants