From 2209cb392b84215398a929f0f4be5cb7d470684d Mon Sep 17 00:00:00 2001 From: JackLivio Date: Thu, 14 Mar 2019 17:00:52 -0400 Subject: OnAppServiceDataTests --- .../application_manager/app_service_manager.h | 2 +- .../application_manager/application_manager_impl.h | 3 +- .../application_manager/commands/command_impl.h | 1 + .../application_manager/rpc_passing_handler.h | 1 + .../app_service_rpc_plugin/CMakeLists.txt | 2 +- .../app_service_rpc_plugin/test/CMakeLists.txt | 72 +++++++ .../on_app_service_data_notification_test.cc | 217 +++++++++++++++++++++ .../application_manager/src/app_service_manager.cc | 3 +- .../application_manager/mock_app_service_manager.h | 11 +- 9 files changed, 303 insertions(+), 9 deletions(-) create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/CMakeLists.txt create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/mobile/on_app_service_data_notification_test.cc diff --git a/src/components/application_manager/include/application_manager/app_service_manager.h b/src/components/application_manager/include/application_manager/app_service_manager.h index 7f8d305edd..973c5054b4 100644 --- a/src/components/application_manager/include/application_manager/app_service_manager.h +++ b/src/components/application_manager/include/application_manager/app_service_manager.h @@ -142,7 +142,7 @@ class AppServiceManager { AppService* FindServiceByName(const std::string name); - AppService* FindServiceByID(const std::string service_id); + virtual AppService* FindServiceByID(const std::string service_id); std::string DefaultServiceByType(const std::string service_type); diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h index 2d2eff7bd3..f20ed982e9 100644 --- a/src/components/application_manager/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/include/application_manager/application_manager_impl.h @@ -1586,8 +1586,7 @@ class ApplicationManagerImpl plugin_manager_.reset(plugin_manager.release()); } - virtual void SetAppServiceManager( - AppServiceManager* app_service_manager) { + virtual void SetAppServiceManager(AppServiceManager* app_service_manager) { app_service_manager_.reset(app_service_manager); } diff --git a/src/components/application_manager/include/application_manager/commands/command_impl.h b/src/components/application_manager/include/application_manager/commands/command_impl.h index 4859f73a55..dd1592c4aa 100644 --- a/src/components/application_manager/include/application_manager/commands/command_impl.h +++ b/src/components/application_manager/include/application_manager/commands/command_impl.h @@ -37,6 +37,7 @@ #include "application_manager/event_engine/event_observer.h" #include "application_manager/application_manager.h" #include "application_manager/smart_object_keys.h" +#include "policy/policy_types.h" #include "utils/logger.h" namespace application_manager { diff --git a/src/components/application_manager/include/application_manager/rpc_passing_handler.h b/src/components/application_manager/include/application_manager/rpc_passing_handler.h index 3ed10ff1e6..ce41b5a597 100644 --- a/src/components/application_manager/include/application_manager/rpc_passing_handler.h +++ b/src/components/application_manager/include/application_manager/rpc_passing_handler.h @@ -39,6 +39,7 @@ #include "application_manager/app_service_manager.h" #include #include "utils/timer.h" +#include "application_manager/commands/command.h" namespace application_manager { diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/CMakeLists.txt b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/CMakeLists.txt index 2bdc150906..1e23aac8ee 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/CMakeLists.txt +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/CMakeLists.txt @@ -80,5 +80,5 @@ install(TARGETS app_service_rpc_plugin ) if(BUILD_TESTS) - # add_subdirectory(test) + add_subdirectory(test) endif() diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/CMakeLists.txt b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/CMakeLists.txt new file mode 100644 index 0000000000..02fb4fe4ec --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/CMakeLists.txt @@ -0,0 +1,72 @@ +# Copyright (c) 2019, Livio +# All rights reserved. + +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: + +# Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. + +# Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following +# disclaimer in the documentation and/or other materials provided with the +# distribution. + +# Neither the name of the copyright holders nor the names of their contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. + +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + +include(${CMAKE_SOURCE_DIR}/tools/cmake/helpers/sources.cmake) + +include_directories ( + ${GMOCK_INCLUDE_DIRECTORY} + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${COMPONENTS_DIR}/application_manager/test/include + ${COMPONENTS_DIR}/include/test/application_manager/ + ${COMPONENTS_DIR}/resumption/include + ) + +set(APP_SERVICE_COMMANDS_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/commands) + +file(GLOB SOURCES + ${COMPONENTS_DIR}/application_manager/test/mock_message_helper.cc + ${APP_SERVICE_COMMANDS_TEST_DIR}/* + ${APP_SERVICE_COMMANDS_TEST_DIR}/mobile/* +) + +set(LIBRARIES + AppServiceRpcPluginStaticLib + ApplicationManager + connectionHandler + SmartObjects + ProtocolHandler + MessageHelper + connectionHandler + Utils + jsoncpp + gmock_main + dl + Resumption +) + +if(ENABLE_LOG) + list(APPEND LIBRARIES log4cxx -L${LOG4CXX_LIBS_DIRECTORY}) + list(APPEND LIBRARIES apr-1 -L${APR_LIBS_DIRECTORY}) + list(APPEND LIBRARIES aprutil-1 -L${APR_UTIL_LIBS_DIRECTORY}) + list(APPEND LIBRARIES expat -L${EXPAT_LIBS_DIRECTORY}) +endif() + +create_test("app_service_commands_test" "${SOURCES}" "${LIBRARIES}" ) + diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/mobile/on_app_service_data_notification_test.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/mobile/on_app_service_data_notification_test.cc new file mode 100644 index 0000000000..d501ea08ea --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/mobile/on_app_service_data_notification_test.cc @@ -0,0 +1,217 @@ +/* + * Copyright (c) 2018, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "application_manager/application.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_app_service_manager.h" +#include "application_manager/commands/commands_test.h" +#include "app_service_rpc_plugin/commands/mobile/on_app_service_data_notification.h" +#include "app_service_rpc_plugin/app_service_rpc_plugin.h" +#include "app_service_rpc_plugin/app_service_app_extension.h" +#include "gtest/gtest.h" +#include "interfaces/MOBILE_API.h" +#include "application_manager/commands/command_impl.h" +#include "resumption/last_state_impl.h" + +namespace am = application_manager; +using ::testing::_; +using ::testing::Return; +using ::testing::ReturnRef; +using ::testing::ReturnNull; +using ::testing::NiceMock; +using ::testing::SaveArg; +using ::testing::Mock; +using am::ApplicationSet; +using am::commands::MessageSharedPtr; +using test::components::application_manager_test::MockApplication; +using test::components::application_manager_test::MockApplicationManager; +using test::components::application_manager_test::MockAppServiceManager; +using test::components::commands_test::CommandsTest; +using test::components::commands_test::CommandsTestMocks; +using app_service_rpc_plugin::commands::OnAppServiceDataNotification; + +namespace { +const uint32_t kAppId = 0u; +const uint32_t kConnectionKey = 1u; +const std::string kPolicyAppId = "Test"; +const int kModuleId = 153u; +} + +namespace app_service_plugin_test { +using namespace app_service_rpc_plugin; +using application_manager::ApplicationSet; + +class OnAppServiceDatanotificationTest + : public CommandsTest { + public: + OnAppServiceDatanotificationTest() + : mock_app_(std::make_shared >()) + , app_service_app_extension_( + std::make_shared( + app_service_plugin_, *mock_app_)) + , apps_lock_(std::make_shared()) + , apps_da_(apps_, apps_lock_) + , last_state_("app_storage_folder", "app_info_storage") + , app_service_manager_(app_mngr_, last_state_) { + ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kAppId)); + ON_CALL(*mock_app_, is_remote_control_supported()) + .WillByDefault(Return(true)); + ON_CALL(*mock_app_, QueryInterface(_)) + .WillByDefault(Return(app_service_app_extension_)); + } + + MessageSharedPtr CreateBasicMessage() { + MessageSharedPtr message = CreateMessage(); + (*message)[application_manager::strings::params] + [application_manager::strings::function_id] = + mobile_apis::FunctionID::OnAppServiceDataID; + (*message)[application_manager::strings::params] + [application_manager::strings::connection_key] = kConnectionKey; + (*message)[application_manager::strings::params] + [application_manager::strings::app_id] = kAppId; + + return message; + } + + protected: + std::shared_ptr mock_app_; + std::shared_ptr app_service_app_extension_; + app_service_rpc_plugin::AppServiceRpcPlugin app_service_plugin_; + application_manager::ApplicationSet apps_; + const std::shared_ptr apps_lock_; + DataAccessor apps_da_; + resumption::LastStateImpl last_state_; + MockAppServiceManager app_service_manager_; +}; + +TEST_F(OnAppServiceDatanotificationTest, Run_SendMessageToMobile_Notification) { + MessageSharedPtr mobile_message = CreateBasicMessage(); + + (*mobile_message)[am::strings::msg_params][am::strings::service_data] + [am::strings::service_type] = "MEDIA"; + (*mobile_message)[am::strings::msg_params][am::strings::service_data] + [am::strings::service_id] = "mediaid1234"; + (*mobile_message)[am::strings::msg_params][am::strings::service_data] + ["mediaServiceData"]["mediaTitle"] = "media title"; + + apps_.insert(mock_app_); + app_service_app_extension_->SubscribeToAppService("MEDIA"); + ON_CALL(app_mngr_, applications()).WillByDefault(Return(apps_da_)); + + am::AppService service; + service.connection_key = 1; + service.mobile_service = true; + service + .record[am::strings::service_manifest][am::strings::allow_app_consumers] = + true; + EXPECT_CALL(app_service_manager_, FindServiceByID(_)) + .WillOnce(Return(&service)); + + EXPECT_CALL(app_mngr_, GetAppServiceManager()) + .WillRepeatedly(ReturnRef(app_service_manager_)); + + std::shared_ptr command = + CreateCommand(mobile_message); + + EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(_, false)) + .WillOnce(SaveArg<0>(&mobile_message)); + // Act + command->Run(); + + // Assertions + ASSERT_TRUE(mobile_message.get()); + Mock::VerifyAndClearExpectations(&app_mngr_); +} + +TEST_F(OnAppServiceDatanotificationTest, Run_NoService) { + MessageSharedPtr mobile_message = CreateBasicMessage(); + + (*mobile_message)[am::strings::msg_params][am::strings::service_data] + [am::strings::service_type] = "MEDIA"; + (*mobile_message)[am::strings::msg_params][am::strings::service_data] + [am::strings::service_id] = "mediaid1234"; + (*mobile_message)[am::strings::msg_params][am::strings::service_data] + ["mediaServiceData"]["mediaTitle"] = "media title"; + + apps_.insert(mock_app_); + app_service_app_extension_->SubscribeToAppService("MEDIA"); + ON_CALL(app_mngr_, applications()).WillByDefault(Return(apps_da_)); + + EXPECT_CALL(app_service_manager_, FindServiceByID(_)).WillOnce(ReturnNull()); + + EXPECT_CALL(app_mngr_, GetAppServiceManager()) + .WillRepeatedly(ReturnRef(app_service_manager_)); + + std::shared_ptr command = + CreateCommand(mobile_message); + + EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(_, false)).Times(0); + command->Run(); + + Mock::VerifyAndClearExpectations(&app_mngr_); +} + +TEST_F(OnAppServiceDatanotificationTest, Run_NoSubscribedApps) { + MessageSharedPtr mobile_message = CreateBasicMessage(); + + (*mobile_message)[am::strings::msg_params][am::strings::service_data] + [am::strings::service_type] = "MEDIA"; + (*mobile_message)[am::strings::msg_params][am::strings::service_data] + [am::strings::service_id] = "mediaid1234"; + (*mobile_message)[am::strings::msg_params][am::strings::service_data] + ["mediaServiceData"]["mediaTitle"] = "media title"; + + apps_.insert(mock_app_); + ON_CALL(app_mngr_, applications()).WillByDefault(Return(apps_da_)); + + am::AppService service; + service.connection_key = 1; + service.mobile_service = true; + service + .record[am::strings::service_manifest][am::strings::allow_app_consumers] = + true; + EXPECT_CALL(app_service_manager_, FindServiceByID(_)) + .WillOnce(Return(&service)); + + EXPECT_CALL(app_mngr_, GetAppServiceManager()) + .WillRepeatedly(ReturnRef(app_service_manager_)); + + std::shared_ptr command = + CreateCommand(mobile_message); + + EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(_, false)).Times(0); + command->Run(); + + Mock::VerifyAndClearExpectations(&app_mngr_); +} + +} // namespace rc_rpc_plugin_test diff --git a/src/components/application_manager/src/app_service_manager.cc b/src/components/application_manager/src/app_service_manager.cc index c2f647f567..36d5307a41 100644 --- a/src/components/application_manager/src/app_service_manager.cc +++ b/src/components/application_manager/src/app_service_manager.cc @@ -189,7 +189,8 @@ void AppServiceManager::OnAppActivated(ApplicationConstSharedPtr app) { } } -std::vector AppServiceManager::GetAllServiceRecords() { +std::vector +AppServiceManager::GetAllServiceRecords() { LOG4CXX_AUTO_TRACE(logger_); std::vector services; sync_primitives::AutoLock lock(published_services_lock_); 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 030c130cbc..cad71f98ab 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 @@ -35,6 +35,8 @@ #include #include "application_manager/app_service_manager.h" +#include "application_manager/commands/command.h" +#include "application_manager/commands/command_impl.h" namespace test { namespace components { @@ -45,10 +47,11 @@ class MockAppServiceManager : public application_manager::AppServiceManager { MockAppServiceManager(application_manager::ApplicationManager& app_manager, resumption::LastState& last_state) : application_manager::AppServiceManager(app_manager, last_state) {} - MOCK_METHOD3(PublishAppService, smart_objects::SmartObject( - const smart_objects::SmartObject& manifest, - const bool mobile_service, - const uint32_t connection_key)); + MOCK_METHOD3( + PublishAppService, + smart_objects::SmartObject(const smart_objects::SmartObject& manifest, + const bool mobile_service, + const uint32_t connection_key)); MOCK_METHOD1(UnpublishAppService, bool(const std::string service_id)); MOCK_METHOD1(UnpublishServices, void(const uint32_t connection_key)); MOCK_METHOD1(OnAppActivated, -- cgit v1.2.1 From 592876079697e75765ef0ce95ce232d173e4a7c8 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Fri, 15 Mar 2019 14:35:20 -0400 Subject: CommandRequestTest SendProviderRequest Tests --- .../application_manager/app_service_manager.h | 18 ++--- .../test/commands/CMakeLists.txt | 1 + .../test/commands/command_request_impl_test.cc | 86 ++++++++++++++++++++++ 3 files changed, 96 insertions(+), 9 deletions(-) diff --git a/src/components/application_manager/include/application_manager/app_service_manager.h b/src/components/application_manager/include/application_manager/app_service_manager.h index 973c5054b4..e8d7b6a91e 100644 --- a/src/components/application_manager/include/application_manager/app_service_manager.h +++ b/src/components/application_manager/include/application_manager/app_service_manager.h @@ -126,15 +126,15 @@ class AppServiceManager { std::vector GetAllServiceRecords(); std::vector > GetActiveServices(); - void GetProviderByType(const std::string& service_type, - const bool mobile_consumer, - ApplicationSharedPtr& app, - bool& hmi_service); - - void GetProviderByID(const std::string& service_id, - const bool mobile_consumer, - ApplicationSharedPtr& app, - bool& hmi_service); + virtual void GetProviderByType(const std::string& service_type, + const bool mobile_consumer, + ApplicationSharedPtr& app, + bool& hmi_service); + + virtual void GetProviderByID(const std::string& service_id, + const bool mobile_consumer, + ApplicationSharedPtr& app, + bool& hmi_service); AppService* ActiveServiceForType(const std::string service_type); diff --git a/src/components/application_manager/test/commands/CMakeLists.txt b/src/components/application_manager/test/commands/CMakeLists.txt index 33258e60db..556f3a5032 100644 --- a/src/components/application_manager/test/commands/CMakeLists.txt +++ b/src/components/application_manager/test/commands/CMakeLists.txt @@ -59,6 +59,7 @@ set(LIBRARIES ApplicationManager jsoncpp Policy + Resumption ) create_test("commands_test" "${SOURCES}" "${LIBRARIES}") diff --git a/src/components/application_manager/test/commands/command_request_impl_test.cc b/src/components/application_manager/test/commands/command_request_impl_test.cc index d4a62d069f..6d80a11440 100644 --- a/src/components/application_manager/test/commands/command_request_impl_test.cc +++ b/src/components/application_manager/test/commands/command_request_impl_test.cc @@ -51,6 +51,9 @@ #include "application_manager/mock_hmi_interface.h" #include "interfaces/MOBILE_API.h" +#include "application_manager/mock_app_service_manager.h" +#include "resumption/last_state_impl.h" + namespace test { namespace components { namespace commands_test { @@ -64,6 +67,7 @@ using ::testing::_; using ::testing::Return; using ::testing::SaveArg; using ::testing::DoAll; +using ::testing::SetArgReferee; using am::commands::MessageSharedPtr; using am::CommandParametersPermissions; @@ -74,6 +78,7 @@ using am::ApplicationManager; using am::ApplicationSet; using am::RPCParams; using am::MockHmiInterfaces; +using test::components::application_manager_test::MockAppServiceManager; typedef am::commands::CommandRequestImpl::RequestState RequestState; @@ -585,6 +590,87 @@ TEST_F(CommandRequestImplTest, AppNotFound_HashUpdateNotExpected) { command.reset(); } +TEST_F(CommandRequestImplTest, SendProviderRequest_ByServiceType) { + resumption::LastStateImpl last_state("app_storage_folder", + "app_info_storage"); + MockAppServiceManager app_service_manager(app_mngr_, last_state); + MockAppPtr mock_app = CreateMockApp(); + EXPECT_CALL(app_mngr_, GetAppServiceManager()) + .WillRepeatedly(ReturnRef(app_service_manager)); + EXPECT_CALL(app_service_manager, GetProviderByType("MEDIA", _, _, _)) + .WillOnce(DoAll(SetArgReferee<2>(mock_app), SetArgReferee<3>(false))); + + MessageSharedPtr result; + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)) + .WillOnce(DoAll(SaveArg<0>(&result), Return(true))); + + MessageSharedPtr msg = CreateMessage(); + (*msg)[strings::params][strings::function_id] = + mobile_apis::FunctionID::GetAppServiceDataID; + (*msg)[strings::msg_params][strings::service_type] = "MEDIA"; + + CommandPtr command = CreateCommand(msg); + command->SendProviderRequest( + mobile_apis::FunctionID::GetAppServiceDataID, + hmi_apis::FunctionID::AppService_GetAppServiceData, + &(*msg), + true); +} + +TEST_F(CommandRequestImplTest, SendProviderRequest_ByProviderID) { + resumption::LastStateImpl last_state("app_storage_folder", + "app_info_storage"); + MockAppServiceManager app_service_manager(app_mngr_, last_state); + MockAppPtr mock_app = CreateMockApp(); + EXPECT_CALL(app_mngr_, GetAppServiceManager()) + .WillRepeatedly(ReturnRef(app_service_manager)); + EXPECT_CALL(app_service_manager, GetProviderByID("serviceid12345", _, _, _)) + .WillOnce(DoAll(SetArgReferee<2>(mock_app), SetArgReferee<3>(false))); + + MessageSharedPtr result; + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)) + .WillOnce(DoAll(SaveArg<0>(&result), Return(true))); + + MessageSharedPtr msg = CreateMessage(); + (*msg)[strings::params][strings::function_id] = + mobile_apis::FunctionID::GetAppServiceDataID; + (*msg)[strings::msg_params][strings::service_id] = "serviceid12345"; + + CommandPtr command = CreateCommand(msg); + command->SendProviderRequest( + mobile_apis::FunctionID::GetAppServiceDataID, + hmi_apis::FunctionID::AppService_GetAppServiceData, + &(*msg), + true); +} + +TEST_F(CommandRequestImplTest, SendProviderRequestToHMI_ByProviderID) { + resumption::LastStateImpl last_state("app_storage_folder", + "app_info_storage"); + MockAppServiceManager app_service_manager(app_mngr_, last_state); + MockAppPtr mock_app = CreateMockApp(); + EXPECT_CALL(app_mngr_, GetAppServiceManager()) + .WillRepeatedly(ReturnRef(app_service_manager)); + EXPECT_CALL(app_service_manager, GetProviderByID("serviceid12345", _, _, _)) + .WillOnce(DoAll(SetArgReferee<2>(mock_app), SetArgReferee<3>(true))); + + MessageSharedPtr result; + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)) + .WillOnce(DoAll(SaveArg<0>(&result), Return(true))); + + MessageSharedPtr msg = CreateMessage(); + (*msg)[strings::params][strings::function_id] = + mobile_apis::FunctionID::GetAppServiceDataID; + (*msg)[strings::msg_params][strings::service_id] = "serviceid12345"; + + CommandPtr command = CreateCommand(msg); + command->SendProviderRequest( + mobile_apis::FunctionID::GetAppServiceDataID, + hmi_apis::FunctionID::AppService_GetAppServiceData, + &(*msg), + true); +} + } // namespace command_request_impl } // namespace commands_test } // namespace components -- cgit v1.2.1 From 36b383be1c8dd77218d0954e7851389c1de71f08 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Sun, 17 Mar 2019 15:15:16 -0400 Subject: Address comments --- .../include/application_manager/rpc_passing_handler.h | 1 - .../commands/mobile/on_app_service_data_notification_test.cc | 10 +++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/components/application_manager/include/application_manager/rpc_passing_handler.h b/src/components/application_manager/include/application_manager/rpc_passing_handler.h index cc0ac2979a..ab85b1374f 100644 --- a/src/components/application_manager/include/application_manager/rpc_passing_handler.h +++ b/src/components/application_manager/include/application_manager/rpc_passing_handler.h @@ -39,7 +39,6 @@ #include "interfaces/MOBILE_API.h" #include "smart_objects/smart_object.h" #include "utils/timer.h" -#include "application_manager/commands/command.h" namespace application_manager { diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/mobile/on_app_service_data_notification_test.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/mobile/on_app_service_data_notification_test.cc index d501ea08ea..47358ef631 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/mobile/on_app_service_data_notification_test.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/mobile/on_app_service_data_notification_test.cc @@ -70,10 +70,10 @@ namespace app_service_plugin_test { using namespace app_service_rpc_plugin; using application_manager::ApplicationSet; -class OnAppServiceDatanotificationTest +class OnAppServiceDataNotificationTest : public CommandsTest { public: - OnAppServiceDatanotificationTest() + OnAppServiceDataNotificationTest() : mock_app_(std::make_shared >()) , app_service_app_extension_( std::make_shared( @@ -113,7 +113,7 @@ class OnAppServiceDatanotificationTest MockAppServiceManager app_service_manager_; }; -TEST_F(OnAppServiceDatanotificationTest, Run_SendMessageToMobile_Notification) { +TEST_F(OnAppServiceDataNotificationTest, Run_SendMessageToMobile_Notification) { MessageSharedPtr mobile_message = CreateBasicMessage(); (*mobile_message)[am::strings::msg_params][am::strings::service_data] @@ -152,7 +152,7 @@ TEST_F(OnAppServiceDatanotificationTest, Run_SendMessageToMobile_Notification) { Mock::VerifyAndClearExpectations(&app_mngr_); } -TEST_F(OnAppServiceDatanotificationTest, Run_NoService) { +TEST_F(OnAppServiceDataNotificationTest, Run_NoService) { MessageSharedPtr mobile_message = CreateBasicMessage(); (*mobile_message)[am::strings::msg_params][am::strings::service_data] @@ -180,7 +180,7 @@ TEST_F(OnAppServiceDatanotificationTest, Run_NoService) { Mock::VerifyAndClearExpectations(&app_mngr_); } -TEST_F(OnAppServiceDatanotificationTest, Run_NoSubscribedApps) { +TEST_F(OnAppServiceDataNotificationTest, Run_NoSubscribedApps) { MessageSharedPtr mobile_message = CreateBasicMessage(); (*mobile_message)[am::strings::msg_params][am::strings::service_data] -- cgit v1.2.1