summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Gapchuk <igapchuck@luxoft.com>2020-06-18 15:25:32 +0300
committersniukalov <sniukaov@luxoft.com>2020-07-03 11:57:12 +0300
commitad6a2cb0110114e0a158ed9bd7765da0eed2ad1f (patch)
treeead0fa3d49929275eac3803de2200252280d8f6d
parent36834e171466c6605b3c47ab8b17a30d78a8b382 (diff)
downloadsdl_core-ad6a2cb0110114e0a158ed9bd7765da0eed2ad1f.tar.gz
Update Unit tests related to app registration
Add the new one case to check app registration with AppHMItype WEB_VIEW Update existing Application Manager UTs with the new methods for WEB_VIEW Update Application Mock
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc70
-rw-r--r--src/components/application_manager/test/application_impl_test.cc74
-rw-r--r--src/components/application_manager/test/include/application_manager/mock_application.h2
3 files changed, 146 insertions, 0 deletions
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc
index 6376570106..8b09e88ce7 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc
@@ -283,6 +283,42 @@ class RegisterAppInterfaceRequestTest
mock_app)));
}
+ void SetCommonPreconditionsToRegisterApplication() {
+ ON_CALL(app_mngr_, IsApplicationForbidden(_, _))
+ .WillByDefault(Return(false));
+ ON_CALL(mock_connection_handler_,
+ GetDataOnSessionKey(kConnectionKey, _, _, _))
+ .WillByDefault(DoAll(SetArgPointee<3>(kDeviceHandle), Return(0)));
+ ON_CALL(mock_session_observer_,
+ GetDataOnDeviceID(kDeviceHandle, _, _, _, _))
+ .WillByDefault(DoAll(SetArgPointee<3>(kMacAddress1), Return(0)));
+ ON_CALL(app_mngr_, reregister_application_by_policy_id(kAppId1))
+ .WillByDefault(Return(ApplicationSharedPtr()));
+ ON_CALL(app_mngr_, application(kMacAddress1, kAppId1))
+ .WillByDefault(Return(ApplicationSharedPtr()));
+ ON_CALL(app_mngr_, applications())
+ .WillByDefault(
+ Return(DataAccessor<am::ApplicationSet>(app_set_, lock_ptr_)));
+ ON_CALL(app_mngr_, pending_applications())
+ .WillByDefault(Return(DataAccessor<am::AppsWaitRegistrationSet>(
+ pending_app_set_, pending_lock_ptr_)));
+ ON_CALL(mock_policy_handler_, PolicyEnabled()).WillByDefault(Return(true));
+ ON_CALL(mock_policy_handler_, GetInitialAppData(kAppId1, _, _))
+ .WillByDefault(Return(true));
+ ON_CALL(mock_rpc_service_,
+ ManageHMICommand(
+ HMIResultCodeIs(
+ hmi_apis::FunctionID::BasicCommunication_OnAppRegistered),
+ _))
+ .WillByDefault(Return(true));
+ ON_CALL(
+ mock_rpc_service_,
+ ManageHMICommand(
+ HMIResultCodeIs(hmi_apis::FunctionID::Buttons_OnButtonSubscription),
+ _))
+ .WillByDefault(Return(true));
+ }
+
MessageSharedPtr msg_;
std::shared_ptr<RegisterAppInterfaceRequest> command_;
@@ -789,6 +825,40 @@ TEST_F(RegisterAppInterfaceRequestTest,
command_->Run();
}
+TEST_F(RegisterAppInterfaceRequestTest,
+ RegisterAppWith_WEB_VIEW_HMITypeSuccess) {
+ SetCommonPreconditionsToRegisterApplication();
+
+ InitBasicMessage();
+ (*msg_)[am::strings::msg_params][am::strings::app_hmi_type][0] =
+ mobile_apis::AppHMIType::WEB_VIEW;
+
+ MockAppPtr mock_app = CreateBasicMockedApp();
+ ON_CALL(app_mngr_, application(kConnectionKey))
+ .WillByDefault(Return(mock_app));
+ ON_CALL(app_mngr_, RegisterApplication(msg_)).WillByDefault(Return(mock_app));
+
+ policy::StatusNotifier notify_upd_manager =
+ std::make_shared<utils::CallNothing>();
+ ON_CALL(mock_policy_handler_, AddApplication(kMacAddress1, kAppId1, _))
+ .WillByDefault(Return(notify_upd_manager));
+
+ auto app =
+ std::static_pointer_cast<application_manager::Application>(mock_app);
+
+ EXPECT_CALL(*mock_app, set_webengine_projection_enabled(true));
+ EXPECT_CALL(app_mngr_, OnApplicationRegistered(app));
+ EXPECT_CALL(mock_policy_handler_,
+ OnAppRegisteredOnMobile(kMacAddress1, kAppId1));
+ EXPECT_CALL(mock_rpc_service_,
+ ManageMobileCommand(_, am::commands::Command::SOURCE_SDL))
+ .Times(2);
+ EXPECT_CALL(app_mngr_, SendDriverDistractionState(app));
+
+ ASSERT_TRUE(command_->Init());
+ command_->Run();
+}
+
} // namespace register_app_interface_request
} // namespace mobile_commands_test
} // namespace commands_test
diff --git a/src/components/application_manager/test/application_impl_test.cc b/src/components/application_manager/test/application_impl_test.cc
index 11578f19d6..a3c14d09b0 100644
--- a/src/components/application_manager/test/application_impl_test.cc
+++ b/src/components/application_manager/test/application_impl_test.cc
@@ -597,6 +597,7 @@ TEST_F(ApplicationImplTest, ChangeSupportingAppHMIType_TypeNotNaviNotVoice) {
EXPECT_FALSE(app_impl->is_navi());
EXPECT_FALSE(app_impl->is_voice_communication_supported());
EXPECT_FALSE(app_impl->mobile_projection_enabled());
+ EXPECT_FALSE(app_impl->webengine_projection_enabled());
app_impl->set_app_types(type_media);
app_impl->ChangeSupportingAppHMIType();
@@ -604,6 +605,7 @@ TEST_F(ApplicationImplTest, ChangeSupportingAppHMIType_TypeNotNaviNotVoice) {
EXPECT_FALSE(app_impl->is_navi());
EXPECT_FALSE(app_impl->is_voice_communication_supported());
EXPECT_FALSE(app_impl->mobile_projection_enabled());
+ EXPECT_FALSE(app_impl->webengine_projection_enabled());
}
TEST_F(ApplicationImplTest, ChangeSupportingAppHMIType_TypeIsVoice) {
@@ -613,6 +615,7 @@ TEST_F(ApplicationImplTest, ChangeSupportingAppHMIType_TypeIsVoice) {
EXPECT_FALSE(app_impl->is_navi());
EXPECT_FALSE(app_impl->is_voice_communication_supported());
EXPECT_FALSE(app_impl->mobile_projection_enabled());
+ EXPECT_FALSE(app_impl->webengine_projection_enabled());
app_impl->set_app_types(type_comm);
app_impl->ChangeSupportingAppHMIType();
@@ -620,6 +623,7 @@ TEST_F(ApplicationImplTest, ChangeSupportingAppHMIType_TypeIsVoice) {
EXPECT_FALSE(app_impl->is_navi());
EXPECT_TRUE(app_impl->is_voice_communication_supported());
EXPECT_FALSE(app_impl->mobile_projection_enabled());
+ EXPECT_FALSE(app_impl->webengine_projection_enabled());
}
TEST_F(ApplicationImplTest, ChangeSupportingAppHMIType_TypeIsNavi) {
@@ -629,6 +633,7 @@ TEST_F(ApplicationImplTest, ChangeSupportingAppHMIType_TypeIsNavi) {
EXPECT_FALSE(app_impl->is_navi());
EXPECT_FALSE(app_impl->is_voice_communication_supported());
EXPECT_FALSE(app_impl->mobile_projection_enabled());
+ EXPECT_FALSE(app_impl->webengine_projection_enabled());
app_impl->set_app_types(type_navi);
app_impl->ChangeSupportingAppHMIType();
@@ -636,6 +641,71 @@ TEST_F(ApplicationImplTest, ChangeSupportingAppHMIType_TypeIsNavi) {
EXPECT_TRUE(app_impl->is_navi());
EXPECT_FALSE(app_impl->is_voice_communication_supported());
EXPECT_FALSE(app_impl->mobile_projection_enabled());
+ EXPECT_FALSE(app_impl->webengine_projection_enabled());
+}
+
+TEST_F(ApplicationImplTest, ChangeSupportingAppHMIType_TypeIsWebView) {
+ smart_objects::SmartObject app_types;
+ app_types[0] = mobile_apis::AppHMIType::WEB_VIEW;
+
+ EXPECT_FALSE(app_impl->is_navi());
+ EXPECT_FALSE(app_impl->is_voice_communication_supported());
+ EXPECT_FALSE(app_impl->mobile_projection_enabled());
+ EXPECT_FALSE(app_impl->webengine_projection_enabled());
+
+ app_impl->set_app_types(app_types);
+ app_impl->ChangeSupportingAppHMIType();
+
+ EXPECT_FALSE(app_impl->is_navi());
+ EXPECT_FALSE(app_impl->is_voice_communication_supported());
+ EXPECT_FALSE(app_impl->mobile_projection_enabled());
+ EXPECT_TRUE(app_impl->webengine_projection_enabled());
+}
+
+TEST_F(ApplicationImplTest,
+ ChangeSupportingAppHMIType_TypeFromWebViewToProjection) {
+ smart_objects::SmartObject app_types;
+ app_types[0] = mobile_apis::AppHMIType::WEB_VIEW;
+
+ EXPECT_FALSE(app_impl->mobile_projection_enabled());
+ EXPECT_FALSE(app_impl->webengine_projection_enabled());
+
+ app_impl->set_app_types(app_types);
+ app_impl->ChangeSupportingAppHMIType();
+
+ EXPECT_FALSE(app_impl->mobile_projection_enabled());
+ EXPECT_TRUE(app_impl->webengine_projection_enabled());
+
+ app_types[0] = mobile_apis::AppHMIType::PROJECTION;
+
+ app_impl->set_app_types(app_types);
+ app_impl->ChangeSupportingAppHMIType();
+
+ EXPECT_FALSE(app_impl->webengine_projection_enabled());
+ EXPECT_TRUE(app_impl->mobile_projection_enabled());
+}
+
+TEST_F(ApplicationImplTest,
+ ChangeSupportingAppHMIType_TypeFromProjectionToWebView) {
+ smart_objects::SmartObject app_types;
+ app_types[0] = mobile_apis::AppHMIType::PROJECTION;
+
+ EXPECT_FALSE(app_impl->mobile_projection_enabled());
+ EXPECT_FALSE(app_impl->webengine_projection_enabled());
+
+ app_impl->set_app_types(app_types);
+ app_impl->ChangeSupportingAppHMIType();
+
+ EXPECT_FALSE(app_impl->webengine_projection_enabled());
+ EXPECT_TRUE(app_impl->mobile_projection_enabled());
+
+ app_types[0] = mobile_apis::AppHMIType::WEB_VIEW;
+
+ app_impl->set_app_types(app_types);
+ app_impl->ChangeSupportingAppHMIType();
+
+ EXPECT_FALSE(app_impl->mobile_projection_enabled());
+ EXPECT_TRUE(app_impl->webengine_projection_enabled());
}
TEST_F(ApplicationImplTest, ChangeSupportingAppHMIType_TypeIsNaviAndVoice) {
@@ -647,6 +717,7 @@ TEST_F(ApplicationImplTest, ChangeSupportingAppHMIType_TypeIsNaviAndVoice) {
EXPECT_FALSE(app_impl->is_navi());
EXPECT_FALSE(app_impl->is_voice_communication_supported());
EXPECT_FALSE(app_impl->mobile_projection_enabled());
+ EXPECT_FALSE(app_impl->webengine_projection_enabled());
app_impl->set_app_types(app_types);
app_impl->ChangeSupportingAppHMIType();
@@ -654,6 +725,7 @@ TEST_F(ApplicationImplTest, ChangeSupportingAppHMIType_TypeIsNaviAndVoice) {
EXPECT_TRUE(app_impl->is_navi());
EXPECT_TRUE(app_impl->is_voice_communication_supported());
EXPECT_FALSE(app_impl->mobile_projection_enabled());
+ EXPECT_FALSE(app_impl->webengine_projection_enabled());
}
TEST_F(ApplicationImplTest,
@@ -667,6 +739,7 @@ TEST_F(ApplicationImplTest,
EXPECT_FALSE(app_impl->is_navi());
EXPECT_FALSE(app_impl->is_voice_communication_supported());
EXPECT_FALSE(app_impl->mobile_projection_enabled());
+ EXPECT_FALSE(app_impl->webengine_projection_enabled());
app_impl->set_app_types(app_types);
app_impl->ChangeSupportingAppHMIType();
@@ -674,6 +747,7 @@ TEST_F(ApplicationImplTest,
EXPECT_TRUE(app_impl->is_navi());
EXPECT_TRUE(app_impl->is_voice_communication_supported());
EXPECT_TRUE(app_impl->mobile_projection_enabled());
+ EXPECT_FALSE(app_impl->webengine_projection_enabled());
}
TEST_F(ApplicationImplTest, UpdateHash_AppMngrNotSuspended) {
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 362dda4efb..389830dd3b 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
@@ -67,6 +67,8 @@ class MockApplication : public ::application_manager::Application {
MOCK_METHOD1(set_is_navi, void(bool allow));
MOCK_CONST_METHOD0(mobile_projection_enabled, bool());
MOCK_METHOD1(set_mobile_projection_enabled, void(bool allow));
+ MOCK_CONST_METHOD0(webengine_projection_enabled, bool());
+ MOCK_METHOD1(set_webengine_projection_enabled, void(const bool allow));
MOCK_CONST_METHOD0(video_streaming_approved, bool());
MOCK_METHOD1(set_video_streaming_approved, void(bool state));
MOCK_CONST_METHOD0(audio_streaming_approved, bool());