Skip to content

Commit

Permalink
Fix/fix rai default timeout (#108)
Browse files Browse the repository at this point in the history
Fix RAI default timeout

As RAI request does not depend on any HMI response
there is no need to track any timeout for it. RAI
request will be removed from/ RequestController
queue upon RAI response which will be sent anyway
Update UT
  • Loading branch information
AKalinich-Luxoft authored Aug 14, 2020
1 parent 7a433a3 commit 746f855
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,19 @@ class RegisterAppInterfaceRequest
/**
* @brief RegisterAppInterfaceRequest class destructor
**/
virtual ~RegisterAppInterfaceRequest();
~RegisterAppInterfaceRequest();

/**
* @brief Init required by command resources
**/
virtual bool Init();
bool Init() FINAL;

/**
* @brief Execute command
**/
virtual void Run();
void Run() FINAL;

uint32_t default_timeout() const FINAL;

private:
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,13 @@ bool RegisterAppInterfaceRequest::Init() {
return true;
}

uint32_t RegisterAppInterfaceRequest::default_timeout() const {
// As RAI request does not depend on any HMI response there is no need to
// track any timeout for it. RAI request will be removed from
// RequestController queue upon RAI response which will be sent anyway
return 0;
}

void RegisterAppInterfaceRequest::WaitForHMIIsReady() {
while (!application_manager_.IsStopping() &&
!application_manager_.IsHMICooperating()) {
Expand All @@ -208,8 +215,6 @@ void RegisterAppInterfaceRequest::WaitForHMIIsReady() {
<< ", correlation_id=" << correlation_id()
<< ", default_timeout=" << default_timeout()
<< ", thread=" << pthread_self());
application_manager_.updateRequestTimeout(
connection_key(), correlation_id(), default_timeout());
sleep(1);
// TODO(DK): timer_->StartWait(1);
}
Expand Down Expand Up @@ -767,9 +772,6 @@ void RegisterAppInterfaceRequest::Run() {
application_manager_.ApplyFunctorForEachPlugin(on_app_registered);

if (is_resumption_required) {
application_manager_.updateRequestTimeout(
connection_key(), correlation_id(), 0);

const auto& msg_params = (*message_)[strings::msg_params];
const auto& hash_id = msg_params[strings::hash_id].asString();
LOG4CXX_WARN(logger_, "Start Data Resumption");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ using sdl_rpc_plugin::commands::RegisterAppInterfaceRequest;
namespace {
const uint32_t kConnectionKey = 1u;
const uint32_t kConnectionKey2 = 2u;
const uint32_t kDefaultTimeout = 0u;
const connection_handler::DeviceHandle kDeviceHandle = 3u;
const hmi_apis::Common_Language::eType kHmiLanguage =
hmi_apis::Common_Language::EN_US;
Expand Down Expand Up @@ -348,6 +349,11 @@ TEST_F(RegisterAppInterfaceRequestTest, Init_SUCCESS) {
EXPECT_TRUE(command_->Init());
}

TEST_F(RegisterAppInterfaceRequestTest, DefaultTimeout_CheckIfZero_SUCCESS) {
command_->Init();
EXPECT_EQ(command_->default_timeout(), kDefaultTimeout);
}

TEST_F(RegisterAppInterfaceRequestTest, Run_MinimalData_SUCCESS) {
InitBasicMessage();
(*msg_)[am::strings::msg_params][am::strings::hash_id] = kAppId1;
Expand All @@ -356,7 +362,6 @@ TEST_F(RegisterAppInterfaceRequestTest, Run_MinimalData_SUCCESS) {
.WillOnce(Return(true))
.WillOnce(Return(false));
ON_CALL(app_mngr_, IsHMICooperating()).WillByDefault(Return(false));
EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _));
EXPECT_CALL(app_mngr_, IsApplicationForbidden(_, _)).WillOnce(Return(false));

connection_handler::DeviceHandle handle = 1;
Expand Down Expand Up @@ -448,7 +453,6 @@ TEST_F(RegisterAppInterfaceRequestTest,
.WillOnce(Return(true))
.WillOnce(Return(false));
ON_CALL(app_mngr_, IsHMICooperating()).WillByDefault(Return(false));
EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _));
EXPECT_CALL(app_mngr_, IsApplicationForbidden(_, _)).WillOnce(Return(false));

connection_handler::DeviceHandle handle = 1;
Expand Down Expand Up @@ -756,7 +760,6 @@ TEST_F(RegisterAppInterfaceRequestTest,
.WillOnce(Return(true))
.WillOnce(Return(false));
ON_CALL(app_mngr_, IsHMICooperating()).WillByDefault(Return(false));
EXPECT_CALL(app_mngr_, updateRequestTimeout(kConnectionKey2, _, _));
EXPECT_CALL(app_mngr_, IsApplicationForbidden(kConnectionKey2, kAppId1))
.WillOnce(Return(false));

Expand Down

0 comments on commit 746f855

Please sign in to comment.