From dc867b0a5588decaf4a4f9ba6c8db720cc68aa73 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Mon, 14 Dec 2020 16:29:29 -0500 Subject: Fix unit tests in hmi_notifications_test --- .../rpc_plugins/sdl_rpc_plugin/test/CMakeLists.txt | 1 + .../test/commands/hmi/hmi_notifications_test.cc | 17 ++++++++++++++++- .../application_manager/mock_app_service_manager.h | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/CMakeLists.txt b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/CMakeLists.txt index b21ab9dca8..b5bb139377 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/CMakeLists.txt +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/CMakeLists.txt @@ -24,6 +24,7 @@ file(GLOB SOURCES set(LIBRARIES sdl_rpc_plugin_static + Resumption gmock ) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/hmi_notifications_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/hmi_notifications_test.cc index 400481f506..5487da51a3 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/hmi_notifications_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/hmi_notifications_test.cc @@ -92,6 +92,7 @@ #include "utils/signals.h" #include "application_manager/hmi_capabilities_impl.h" +#include "application_manager/mock_app_service_manager.h" #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" #include "application_manager/mock_event_dispatcher.h" @@ -106,6 +107,8 @@ #include "connection_handler/mock_connection_handler.h" #include "connection_handler/mock_connection_handler_settings.h" #include "protocol_handler/mock_session_observer.h" +#include "resumption/last_state_wrapper_impl.h" +#include "resumption/mock_last_state.h" #include "smart_objects/smart_object.h" #include "test/application_manager/mock_application_manager_settings.h" #include "transport_manager/mock_transport_manager.h" @@ -127,6 +130,7 @@ using ::test::components::application_manager_test::MockApplication; using ::test::components::application_manager_test::MockApplicationManager; using ::test::components::application_manager_test:: MockApplicationManagerSettings; +using ::test::components::application_manager_test::MockAppServiceManager; using ::test::components::event_engine_test::MockEventDispatcher; using ::testing::_; using ::testing::InSequence; @@ -216,7 +220,11 @@ class HMICommandsNotificationsTest HMICommandsNotificationsTest() : applications_lock_(std::make_shared()) , applications_(application_set_, applications_lock_) - , app_ptr_(NULL) {} + , app_ptr_(NULL) + , mock_last_state_(std::make_shared()) + , last_state_wrapper_(std::make_shared( + mock_last_state_)) + , mock_app_service_manager_(app_mngr_, last_state_wrapper_) {} ~HMICommandsNotificationsTest() { // Fix DataAccessor release and WinQt crash @@ -244,6 +252,9 @@ class HMICommandsNotificationsTest MockConnectionHandler mock_connection_handler_; MockSessionObserver mock_session_observer_; + std::shared_ptr mock_last_state_; + resumption::LastStateWrapperPtr last_state_wrapper_; + MockAppServiceManager mock_app_service_manager_; void InitCommand(const uint32_t& default_timeout) OVERRIDE { app_ = ConfigureApp(&app_ptr_, kAppId_, NOT_MEDIA, NOT_NAVI, NOT_VC); @@ -256,6 +267,8 @@ class HMICommandsNotificationsTest ON_CALL(app_mngr_, application_by_hmi_app(_)).WillByDefault(Return(app_)); ON_CALL(*app_ptr_, app_id()).WillByDefault(Return(kAppId_)); ON_CALL(app_mngr_, application(kConnectionKey)).WillByDefault(Return(app_)); + ON_CALL(app_mngr_, GetAppServiceManager()) + .WillByDefault(ReturnRef(mock_app_service_manager_)); ON_CALL(app_mngr_, connection_handler()) .WillByDefault(ReturnRef(mock_connection_handler_)); } @@ -428,6 +441,8 @@ TEST_F(HMICommandsNotificationsTest, MessageSharedPtr message = CreateMessage(); std::shared_ptr command = CreateCommand(message); + EXPECT_CALL(mock_app_service_manager_, FindWayPointsHandler()) + .WillOnce(Return(nullptr)); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, Command::CommandSource::SOURCE_SDL)); command->Run(); diff --git a/src/components/application_manager/test/include/application_manager/mock_app_service_manager.h b/src/components/application_manager/test/include/application_manager/mock_app_service_manager.h index 60d2f90297..e3a47f412a 100644 --- a/src/components/application_manager/test/include/application_manager/mock_app_service_manager.h +++ b/src/components/application_manager/test/include/application_manager/mock_app_service_manager.h @@ -87,6 +87,7 @@ class MockAppServiceManager : public application_manager::AppServiceManager { const bool service_published)); MOCK_METHOD1(UpdateNavigationCapabilities, bool(smart_objects::SmartObject& out_params)); + MOCK_METHOD0(FindWayPointsHandler, application_manager::AppService*()); MOCK_METHOD0(GetRPCPassingHandler, application_manager::RPCPassingHandler&()); }; -- cgit v1.2.1