summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShobhitAd <adlakhashobhit@gmail.com>2020-09-17 12:08:27 -0400
committerShobhitAd <adlakhashobhit@gmail.com>2020-09-17 12:08:27 -0400
commit6b72fbf8dab880467e2278e0bfdbda0b855b3b97 (patch)
treefc163929cd052af821daa558aa18f4dc970ba2ac
parentb15dbc9d10238c153beb6e23108eb04410fc9672 (diff)
downloadsdl_core-6b72fbf8dab880467e2278e0bfdbda0b855b3b97.tar.gz
Add mock functions
-rw-r--r--src/components/application_manager/src/state_controller_impl.cc16
-rw-r--r--src/components/application_manager/test/include/application_manager/mock_application.h3
2 files changed, 16 insertions, 3 deletions
diff --git a/src/components/application_manager/src/state_controller_impl.cc b/src/components/application_manager/src/state_controller_impl.cc
index be72ec1cd7..47876f9bb6 100644
--- a/src/components/application_manager/src/state_controller_impl.cc
+++ b/src/components/application_manager/src/state_controller_impl.cc
@@ -722,17 +722,29 @@ void StateControllerImpl::on_event(const event_engine::MobileEvent& event) {
switch (event.id()) {
case FunctionID::RegisterAppInterfaceID: {
uint32_t connection_key =
- event.smart_object()[strings::connection_key].asUInt();
+ event.smart_object()[strings::params][strings::connection_key]
+ .asUInt();
ApplicationSharedPtr app = app_mngr_.application(connection_key);
if (app.use_count() == 0) {
- SDL_LOG_ERROR("OnHMIStatusNotification application doesn't exist");
+ SDL_LOG_WARN("Application doesn't exist");
+ return;
+ }
+
+ auto it = pending_hmistatus_notification_apps_.find(app->app_id());
+ if (it == pending_hmistatus_notification_apps_.end()) {
+ SDL_LOG_WARN("Application does not have a pending OnHMIStatus");
return;
}
auto notification = MessageHelper::CreateHMIStatusNotification(app, 0);
app_mngr_.GetRPCService().ManageMobileCommand(
notification, commands::Command::SOURCE_SDL);
+ pending_hmistatus_notification_apps_.erase(app->app_id());
+ if (pending_hmistatus_notification_apps_.empty()) {
+ unsubscribe_from_event(FunctionID::RegisterAppInterfaceID);
+ }
+
} break;
default:
diff --git a/src/components/application_manager/test/include/application_manager/mock_application.h b/src/components/application_manager/test/include/application_manager/mock_application.h
index 36004f3a1d..3c1ddca125 100644
--- a/src/components/application_manager/test/include/application_manager/mock_application.h
+++ b/src/components/application_manager/test/include/application_manager/mock_application.h
@@ -96,8 +96,9 @@ class MockApplication : public ::application_manager::Application {
void(bool is_voice_communication_supported));
MOCK_CONST_METHOD0(app_allowed, bool());
MOCK_CONST_METHOD0(has_been_activated, bool());
- MOCK_CONST_METHOD0(is_ready, bool());
MOCK_METHOD1(set_activated, bool(bool is_active));
+ MOCK_CONST_METHOD0(is_ready, bool());
+ MOCK_METHOD1(set_is_ready, bool(bool is_active));
MOCK_CONST_METHOD0(version, const ::application_manager::Version&());
MOCK_METHOD1(set_hmi_application_id, void(uint32_t hmi_app_id));
MOCK_CONST_METHOD0(hmi_app_id, uint32_t());