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

Add RPCService unit tests #3250

Conversation

ychernysheva
Copy link
Contributor

@ychernysheva ychernysheva commented Feb 20, 2020

Fixes #2449

This PR is [ready] for review.

Risk

This PR makes [no] API changes.

Summary

Add RPCService unit tests to improve unit tests coverage (from 59.1% to 95.5% (by functions) and from 27.9% to 69.8% (by lines)).

CLA

@ychernysheva ychernysheva marked this pull request as ready for review February 21, 2020 08:30
@ychernysheva ychernysheva force-pushed the feature/rpc_service_impl_uts_coverage branch 2 times, most recently from 42f6d01 to af9f896 Compare February 21, 2020 15:42
*/

#include <gmock/gmock.h>
#include <string>
Copy link
Contributor

Choose a reason for hiding this comment

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

@ychernysheva reorder includes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in commit 09fa0bd

#include "application_manager/request_controller.h"
#include "hmi_message_handler/mock_hmi_message_handler.h"
#include "include/test/protocol_handler/mock_protocol_handler.h"
#include "resumption/last_state_impl.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

Check that all includes are actually required

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in commit 09fa0bd

@@ -17,7 +17,7 @@ rm -rf $COVERAGE_DIR
rm -rf $REPORTS_DIR -

mkdir $COVERAGE_DIR
lcov --quiet --capture --directory . --output-file $COVERAGE_DIR/full_report.info
lcov --quiet --capture --directory $BUILD_DIR --output-file $COVERAGE_DIR/full_report.info
Copy link
Contributor

Choose a reason for hiding this comment

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

This change is not related to your current PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is no such file in this pull request

const uint32_t kCorrelationId = 1u;
const uint32_t kFunctionId = 1u;
const uint32_t kAppId = 1u;
const int32_t hmi_protocol_type_ = 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

Not used variable - please delete

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in commit d5ec824

const uint32_t kFunctionId = 1u;
const uint32_t kAppId = 1u;
const int32_t hmi_protocol_type_ = 1;
const int32_t mobile_protocol_type_ = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Wrong naming, please take a look at constants names above as an example

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in commit d5ec824

am::CommandHolder::CommandType::kHmiCommand,
source,
message))
.WillOnce(Return());
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you run check_style script?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, and I get such result, I need to edit it manually in addition?

Copy link
Contributor

Choose a reason for hiding this comment

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

@ychernysheva no. If script did this then this is the way.

new_function_id, message_type, members);
CSmartSchema updated_schema;
extended_mobile_api.GetSchema(new_function_id, message_type, updated_schema);
// Check that schema is changed
Copy link
Contributor

Choose a reason for hiding this comment

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

Place this comment closer to line of code it is related to.
Please check all similar places in file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in commit d5ec824

(*message)[jhs::S_PARAMS][jhs::S_MESSAGE_TYPE] =
mobile_apis::messageType::request;
(*message)[jhs::S_PARAMS][jhs::S_PROTOCOL_TYPE] = mobile_protocol_type_;
(*message)[jhs::S_PARAMS][jhs::S_PROTOCOL_VERSION] = 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't use 'magic numbers', use a constant here and declare it in anonymous namespace at the top of file.
Please check all similar places across file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in commit d5ec824

message_to_send->set_connection_key(kConnectionKey);
message_to_send->set_correlation_id(kCorrelationId);
message_to_send->set_function_id(kFunctionId);
message_to_send->set_message_type(static_cast<am::MessageType>(2));
Copy link
Contributor

Choose a reason for hiding this comment

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

Magic number. Please provide concrete enum value or make an appropriate constant.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in commit d5ec824

@ychernysheva ychernysheva force-pushed the feature/rpc_service_impl_uts_coverage branch from d5ec824 to 4d2aae7 Compare April 23, 2020 10:27
@ychernysheva
Copy link
Contributor Author

Rebased on current release branch

@ychernysheva
Copy link
Contributor Author

@theresalech this PR is ready for review. Please notice, that this is not a regression issue, so please check it if time allows. Also notice, that this branch was rebased on release/6.1.0 branch, but develop branch is a target for merging.
Thank you.

@Jack-Byrne Jack-Byrne self-assigned this May 18, 2020
@Jack-Byrne Jack-Byrne merged commit 99e8ddc into smartdevicelink:develop May 18, 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