From ce4caa13d119014551e7525de669ce78a87c50c3 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Thu, 17 Feb 2022 09:15:23 +0900 Subject: [PATCH 01/16] Fix static analysis issue - Initialize member variables Change-Id: I1a67151aa828d73c204c21ca4692a679eda8982a Signed-off-by: Hwankyu Jhun --- src/base/widget_base.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/base/widget_base.cc b/src/base/widget_base.cc index 45ec082..24f54cd 100644 --- a/src/base/widget_base.cc +++ b/src/base/widget_base.cc @@ -160,9 +160,9 @@ class WidgetContext::Impl { std::unique_ptr args_; std::string content_; - double period_; + double period_ = 0.0f; guint periodic_timer_ = 0; - bool pending_update_; + bool pending_update_ = false; std::string pending_content_; }; -- 2.7.4 From a8a19e8519d36a0702847e1eba55db9a95aaa473 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Thu, 17 Feb 2022 10:07:11 +0900 Subject: [PATCH 02/16] Release version 1.4.2 Changes: - Fix static analysis issue Change-Id: I03e09a9fa3d75d2010ba588c6274873240825613 Signed-off-by: Hwankyu Jhun --- packaging/appcore-widget.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/appcore-widget.spec b/packaging/appcore-widget.spec index 861498f..42ac64c 100644 --- a/packaging/appcore-widget.spec +++ b/packaging/appcore-widget.spec @@ -1,6 +1,6 @@ Name: appcore-widget Summary: Widget Application -Version: 1.4.1 +Version: 1.4.2 Release: 1 Group: Application Framework/Libraries License: Apache-2.0 -- 2.7.4 From d6a6581a65a38f41e87b84880671e9db66abc504 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Tue, 8 Mar 2022 14:35:27 +0900 Subject: [PATCH 03/16] Fix crash issue While creating tizen_base::Bundle() with the content info that is a string, the constructor throws an exception. Because, it's not an encoded bundle raw. This patch adds an encoding step and exception handlings to prevent crash issues. Change-Id: I58d7eacafde020496ed087d770cffd953b26f7e3 Signed-off-by: Hwankyu Jhun --- src/base/widget_base.cc | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/base/widget_base.cc b/src/base/widget_base.cc index 24f54cd..ddb2b33 100644 --- a/src/base/widget_base.cc +++ b/src/base/widget_base.cc @@ -662,6 +662,15 @@ int WidgetContext::SetContents(const tizen_base::Bundle& contents) { return WIDGET_ERROR_FAULT; } + try { + auto contents_raw = const_cast(contents).ToRaw(); + impl_->content_ = std::string( + reinterpret_cast(contents_raw.first.get())); + } catch (const std::bad_alloc& e) { + impl_->content_ = ""; + _E("Exception(%s) occurs", e.what()); + } + return WIDGET_ERROR_NONE; } @@ -756,8 +765,13 @@ void WidgetContext::OnTerminate() { reason = DestroyType::PERMANENT; } - tizen_base::Bundle content_info = impl_->content_.empty() ? - tizen_base::Bundle() : tizen_base::Bundle(impl_->content_); + tizen_base::Bundle content_info; + try { + if (!impl_->content_.empty()) + content_info = tizen_base::Bundle(impl_->content_); + } catch (const std::bad_alloc& e) { + _E("Exception(%s) occurs", e.what()); + } OnDestroy(reason, content_info); -- 2.7.4 From 8ddc029e16674dd8cdb8b465fb56512bb042e899 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Tue, 8 Mar 2022 14:49:41 +0900 Subject: [PATCH 04/16] Release version 1.4.3 Changes: - Fix crash issue Change-Id: I0b54296f0c4439965d392c887de27e4cec70a199 Signed-off-by: Hwankyu Jhun --- packaging/appcore-widget.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/appcore-widget.spec b/packaging/appcore-widget.spec index 42ac64c..65d4319 100644 --- a/packaging/appcore-widget.spec +++ b/packaging/appcore-widget.spec @@ -1,6 +1,6 @@ Name: appcore-widget Summary: Widget Application -Version: 1.4.2 +Version: 1.4.3 Release: 1 Group: Application Framework/Libraries License: Apache-2.0 -- 2.7.4 From e1b65899175bfe60c61d429fe14e348e17dad5d1 Mon Sep 17 00:00:00 2001 From: Changgyu Choi Date: Wed, 21 Dec 2022 14:26:15 +0900 Subject: [PATCH 05/16] Modify gcov installation directory Change-Id: I8d4a9e8ba94007f8682a55109e3beae71578bbb7 Signed-off-by: Changgyu Choi --- CMakeLists.txt | 2 +- packaging/appcore-widget.spec | 48 +++++++++++++++++++++++++++++++++--------- test/unit_tests/CMakeLists.txt | 2 ++ 3 files changed, 41 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a35ef8d..de092fa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,7 +23,7 @@ SET(TARGET_WIDGET_BASE "appcore-widget-base") SET(TARGET_WIDGET_APPLICATION "capi-appfw-widget-application") ENABLE_TESTING() -SET(TARGET_WIDGET_APPLICATION_UNIT_TEST "appcore-widget-unit-test") +SET(TARGET_WIDGET_APPLICATION_UNIT_TEST "appcore-widget-unittest") INCLUDE(FindPkgConfig) INCLUDE(ApplyPkgConfig) diff --git a/packaging/appcore-widget.spec b/packaging/appcore-widget.spec index 65d4319..d60c6fc 100644 --- a/packaging/appcore-widget.spec +++ b/packaging/appcore-widget.spec @@ -85,23 +85,47 @@ export LDFLAGS+=" -lgcov" export CFLAGS+=" -DEFL_BETA_API_SUPPORT " MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` -%cmake . -DFULLVER=%{version} -DMAJORVER=${MAJORVER} +%cmake . -DFULLVER=%{version} -DMAJORVER=${MAJORVER} -DBIN_INSTALL_DIR:PATH=%{_bindir} %__make %{?jobs:-j%jobs} -%if 0%{?gcov:1} -mkdir -p gcov-obj -find . -name '*.gcno' -exec cp '{}' gcov-obj ';' -%endif - %install rm -rf %{buildroot} %make_install %if 0%{?gcov:1} -mkdir -p %{buildroot}%{_datadir}/gcov/obj/%{name} -install -m 0644 gcov-obj/* %{buildroot}%{_datadir}/gcov/obj/%{name} +builddir=$(basename $PWD) +gcno_obj_dir=%{buildroot}%{_datadir}/gcov/obj/%{name}/"$builddir" +mkdir -p "$gcno_obj_dir" +find . -name '*.gcno' -exec cp --parents '{}' "$gcno_obj_dir" ';' %endif +cat << EOF > run-unittest.sh +#!/bin/sh +setup() { + echo "setup start" +} + +test_main() { + echo "test_main start" + /usr/bin/appcore-widget-unittest +} + +teardown() { + echo "teardown start" +} + +main() { + setup + test_main + teardown +} + +main "\$*" +EOF + +mkdir -p %{buildroot}%{_bindir}/tizen-unittests/%{name} +install -m 0755 run-unittest.sh %{buildroot}%{_bindir}/tizen-unittests/%{name}/ + %check export LD_LIBRARY_PATH=../../src/base:../../src/efl_base ctest -V @@ -109,7 +133,7 @@ ctest -V lcov -c --ignore-errors graph --no-external -q -d . -o appcore-widget.info genhtml appcore-widget.info -o appcore-widget.out zip -r appcore-widget.zip appcore-widget.out -install -m 0644 appcore-widget.zip %{buildroot}%{_datadir}/gcov/ +install -m 0644 appcore-widget.zip %{buildroot}%{_datadir}/gcov/obj/ %endif %post -p /sbin/ldconfig @@ -142,7 +166,11 @@ install -m 0644 appcore-widget.zip %{buildroot}%{_datadir}/gcov/ %{_libdir}/pkgconfig/capi-appfw-widget-application.pc %{_libdir}/libcapi-appfw-widget-application.so +%files -n appcore_widget_unittests +%{_bindir}/appcore-widget-unittest +%{_bindir}/tizen-unittests/%{name}/run-unittest.sh + %if 0%{?gcov:1} %files gcov -%{_datadir}/gcov/* +%{_datadir}/gcov/obj/* %endif diff --git a/test/unit_tests/CMakeLists.txt b/test/unit_tests/CMakeLists.txt index 7a2beb7..af79f85 100644 --- a/test/unit_tests/CMakeLists.txt +++ b/test/unit_tests/CMakeLists.txt @@ -40,3 +40,5 @@ ADD_TEST( NAME ${TARGET_WIDGET_APPLICATION_UNIT_TEST} COMMAND ${TARGET_WIDGET_APPLICATION_UNIT_TEST} ) + +INSTALL (PROGRAMS ${TARGET_WIDGET_APPLICATION_UNIT_TEST} DESTINATION ${BIN_INSTALL_DIR}) -- 2.7.4 From 91aa29be4b1d04e27f0c95685287758f2d2f2631 Mon Sep 17 00:00:00 2001 From: Changgyu Choi Date: Wed, 21 Dec 2022 16:20:59 +0900 Subject: [PATCH 06/16] Release version 1.4.4 Changes: - Modify gcov installation directory Change-Id: Ia8ab4f4421bbbd4c8fa8ea12fdb5d513a5ba70a9 Signed-off-by: Changgyu Choi --- packaging/appcore-widget.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/appcore-widget.spec b/packaging/appcore-widget.spec index d60c6fc..0e6b86b 100644 --- a/packaging/appcore-widget.spec +++ b/packaging/appcore-widget.spec @@ -1,6 +1,6 @@ Name: appcore-widget Summary: Widget Application -Version: 1.4.3 +Version: 1.4.4 Release: 1 Group: Application Framework/Libraries License: Apache-2.0 -- 2.7.4 From 74ed79435e2b00b206ae8c874484b57513c23ba0 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Fri, 21 Apr 2023 00:50:59 +0000 Subject: [PATCH 07/16] Fix build error for gcc 12.2.0 - Add missing header inclusion Change-Id: I0e64278b6a495d00ca79debf83ec8e200b85260a Signed-off-by: Hwankyu Jhun --- src/base/widget_base.cc | 2 ++ src/efl_base/widget_app.cc | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/base/widget_base.cc b/src/base/widget_base.cc index ddb2b33..26219b3 100644 --- a/src/base/widget_base.cc +++ b/src/base/widget_base.cc @@ -26,6 +26,8 @@ #include #include +#include + #include #include "common/log_private.hh" diff --git a/src/efl_base/widget_app.cc b/src/efl_base/widget_app.cc index 17cd02f..11da6d1 100644 --- a/src/efl_base/widget_app.cc +++ b/src/efl_base/widget_app.cc @@ -26,6 +26,8 @@ #include #include +#include + #include "common/export_private.hh" #include "common/log_private.hh" #include "include/widget_app.h" @@ -553,7 +555,7 @@ API widget_class_h widget_app_class_add(widget_class_h widget_class, __app_widget->AddContextFactory(std::move(factory), class_id); set_last_result(WIDGET_ERROR_NONE); - int dummy; + static int dummy = 1; widget_class_h cls = reinterpret_cast(&dummy); return cls; } -- 2.7.4 From d39ab78db28d81e3f08048ce7bfac5a762234e28 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Fri, 21 Apr 2023 04:46:02 +0000 Subject: [PATCH 08/16] Release version 1.4.5 Changes: - Fix build error for gcc 12.2.0 Change-Id: I4c5ec8eeaeb1e579941c74ed293ba1dff4bc0a60 Signed-off-by: Hwankyu Jhun --- packaging/appcore-widget.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/appcore-widget.spec b/packaging/appcore-widget.spec index 0e6b86b..11b8c77 100644 --- a/packaging/appcore-widget.spec +++ b/packaging/appcore-widget.spec @@ -1,6 +1,6 @@ Name: appcore-widget Summary: Widget Application -Version: 1.4.4 +Version: 1.4.5 Release: 1 Group: Application Framework/Libraries License: Apache-2.0 -- 2.7.4 From 9014f2f8b96dc55a8ee5cb9309e6d94a4325da86 Mon Sep 17 00:00:00 2001 From: Changgyu Choi Date: Thu, 7 Sep 2023 13:57:38 +0900 Subject: [PATCH 09/16] Modify widget_app event function To support timezone changed event, this patch modifies these functions. Change-Id: I8a0e0ae88c0303e5368361498517679ed58650e7 Signed-off-by: Changgyu Choi --- src/efl_base/widget_app.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/efl_base/widget_app.cc b/src/efl_base/widget_app.cc index 11da6d1..c35a6a1 100644 --- a/src/efl_base/widget_app.cc +++ b/src/efl_base/widget_app.cc @@ -40,7 +40,7 @@ namespace { constexpr const int kIconifyTimeout = 500; constexpr const char kFeatureShellAppWidget[] = "http://tizen.org/feature/shell.appwidget"; -constexpr int APP_EVENT_MAX = 7; +constexpr int APP_EVENT_MAX = static_cast(IAppCore::IEvent::Type::END); constexpr IAppCore::IEvent::Type __app_event_converter[APP_EVENT_MAX] = { [APP_EVENT_LOW_MEMORY] = IAppCore::IEvent::Type::LOW_MEMORY, [APP_EVENT_LOW_BATTERY] = IAppCore::IEvent::Type::LOW_BATTERY, @@ -50,6 +50,8 @@ constexpr IAppCore::IEvent::Type __app_event_converter[APP_EVENT_MAX] = { [APP_EVENT_REGION_FORMAT_CHANGED] = IAppCore::IEvent::Type::REGION_CHANGE, [APP_EVENT_SUSPENDED_STATE_CHANGED] = IAppCore::IEvent::Type::SUSPENDED_STATE_CHANGE, + [APP_EVENT_UPDATE_REQUESTED] = IAppCore::IEvent::Type::UPDATE_REQUESTED, + [APP_EVENT_TIME_ZONE_CHANGED] = IAppCore::IEvent::Type::TIME_ZONE_CHANGED, }; class AppWidget : public WidgetBase { @@ -384,7 +386,7 @@ API int widget_app_add_event_handler(app_event_handler_h* event_handler, return WIDGET_ERROR_INVALID_PARAMETER; if (event_type < APP_EVENT_LOW_MEMORY || - event_type > APP_EVENT_REGION_FORMAT_CHANGED) + event_type > APP_EVENT_TIME_ZONE_CHANGED) return WIDGET_ERROR_INVALID_PARAMETER; if (event_type == APP_EVENT_DEVICE_ORIENTATION_CHANGED) -- 2.7.4 From 8be33d737d3900364e90c9ac1fb4d662f8191090 Mon Sep 17 00:00:00 2001 From: Changgyu Choi Date: Thu, 7 Sep 2023 15:35:43 +0900 Subject: [PATCH 10/16] Release version 1.5.0 Changes: - Modify widget_app event function Change-Id: Ibafaa51e7daf17a69d1faaa1cf6fd30e87b6a99d Signed-off-by: Changgyu Choi --- packaging/appcore-widget.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/appcore-widget.spec b/packaging/appcore-widget.spec index 11b8c77..762694f 100644 --- a/packaging/appcore-widget.spec +++ b/packaging/appcore-widget.spec @@ -1,6 +1,6 @@ Name: appcore-widget Summary: Widget Application -Version: 1.4.5 +Version: 1.5.0 Release: 1 Group: Application Framework/Libraries License: Apache-2.0 -- 2.7.4 From 863b9dfaa17de81f10ed9465230b8cea3d3c5df6 Mon Sep 17 00:00:00 2001 From: Inkyun Kil Date: Thu, 21 Sep 2023 19:10:39 +0900 Subject: [PATCH 11/16] Change unittest package name and improves code coverage Change-Id: I72dd2629a553fa7b9c83433388061bd21f097ab1 Signed-off-by: Inkyun Kil --- include/widget_app.hpp | 2 + packaging/appcore-widget.spec | 6 +- src/base/widget_base.cc | 13 +++- src/base/widget_base_legacy.c | 4 +- src/efl_base/widget_app.cc | 121 +++++++++++++++++---------------- test/unit_tests/main.cc | 12 ++-- test/unit_tests/mock/ecore_wl2_mock.cc | 27 -------- test/unit_tests/mock/ecore_wl2_mock.h | 12 ---- test/unit_tests/mock/gio_mock.cc | 99 --------------------------- test/unit_tests/mock/gio_mock.h | 67 ------------------ test/unit_tests/test_widget_app.cc | 33 ++++++--- test/unit_tests/test_widget_app_cpp.cc | 23 ++++++- 12 files changed, 130 insertions(+), 289 deletions(-) delete mode 100644 test/unit_tests/mock/gio_mock.cc delete mode 100755 test/unit_tests/mock/gio_mock.h diff --git a/include/widget_app.hpp b/include/widget_app.hpp index fb9a05d..f0fc3c7 100644 --- a/include/widget_app.hpp +++ b/include/widget_app.hpp @@ -97,6 +97,7 @@ class WidgetAppBase : public app_common::AppBase< int Run(int argc, char** argv, std::unique_ptr factory) { factory_ = std::move(factory); +/* LCOV_EXCL_START */ widget_app_lifecycle_callback_s callback = { create : [](void *user_data) -> widget_class_h { WidgetAppBase* b = static_cast(user_data); @@ -170,6 +171,7 @@ class WidgetAppBase : public app_common::AppBase< b->OnTerminate(); } }; +/* LCOV_EXCL_STOP */ return widget_app_main(argc, argv, &callback, this); } diff --git a/packaging/appcore-widget.spec b/packaging/appcore-widget.spec index 762694f..b722455 100644 --- a/packaging/appcore-widget.spec +++ b/packaging/appcore-widget.spec @@ -55,10 +55,10 @@ Requires: %{name} = %{version}-%{release} %description -n capi-appfw-widget-application-devel widget application (development files) -%package -n appcore_widget_unittests +%package -n appcore-widget-unittests Summary: GTest for appcore-widget Group: Development/Libraries -%description -n appcore_widget_unittests +%description -n appcore-widget-unittests GTest for appcore-widget @@ -166,7 +166,7 @@ install -m 0644 appcore-widget.zip %{buildroot}%{_datadir}/gcov/obj/ %{_libdir}/pkgconfig/capi-appfw-widget-application.pc %{_libdir}/libcapi-appfw-widget-application.so -%files -n appcore_widget_unittests +%files -n appcore-widget-unittests %{_bindir}/appcore-widget-unittest %{_bindir}/tizen-unittests/%{name}/run-unittest.sh diff --git a/src/base/widget_base.cc b/src/base/widget_base.cc index 26219b3..20c10e1 100644 --- a/src/base/widget_base.cc +++ b/src/base/widget_base.cc @@ -45,9 +45,11 @@ class AppContext { app_id_ = app_id; } +/* LCOV_EXCL_START */ const std::string& GetAppId() const { return app_id_; } +/* LCOV_EXCL_STOP */ void SetPackageId(const std::string& package_id) { package_id_ = package_id; @@ -72,7 +74,7 @@ class AppContext { bool IsPermanent() const { return permanent_; } - +/* LCOV_EXCL_START */ void SetFgSignal(bool fg_signal) { fg_signal_ = fg_signal; } @@ -80,6 +82,7 @@ class AppContext { bool IsFgSignal() const { return fg_signal_; } +/* LCOV_EXCL_STOP */ int SendUpdateStatus(const std::string& class_id, const std::string& instance_id, int status, int err, @@ -499,6 +502,7 @@ int WidgetBase::OnControl(tizen_base::Bundle b) { return 0; } +/* LCOV_EXCL_START */ void WidgetContext::Impl::OnUpdate(bool force) { parent_->OnUpdate(pending_content_.empty() ? tizen_base::Bundle() : tizen_base::Bundle(pending_content_), force); @@ -509,6 +513,7 @@ void WidgetContext::Impl::OnUpdate(bool force) { WIDGET_INSTANCE_EVENT_UPDATE, 0, nullptr); _D("Updated: %s", id.c_str()); } +/* LCOV_EXCL_STOP */ void WidgetContext::Impl::UpdateProcess(const tizen_base::Bundle& b) { bool force; @@ -534,6 +539,7 @@ void WidgetContext::Impl::UpdateProcess(const tizen_base::Bundle& b) { } } +/* LCOV_EXCL_START */ void WidgetContext::Impl::SetPeriod(double period) { period_ = period; } @@ -548,6 +554,7 @@ void WidgetContext::Impl::SetPeriodicTimer() { TimedOutCb, parent_); } } +/* LCOV_EXCL_STOP */ void WidgetContext::Impl::UnsetPeriodicTimer() { if (periodic_timer_) { @@ -557,6 +564,7 @@ void WidgetContext::Impl::UnsetPeriodicTimer() { } } +/* LCOV_EXCL_START */ gboolean WidgetContext::Impl::TimedOutCb(gpointer user_data) { WidgetContext* wc = reinterpret_cast(user_data); if (wc->IsResumed()) { @@ -573,6 +581,7 @@ gboolean WidgetContext::Impl::TimedOutCb(gpointer user_data) { return G_SOURCE_CONTINUE; } +/* LCOV_EXCL_STOP */ WidgetContext::WidgetContext(std::string context_id, std::string inst_id, AppCoreMultiWindowBase* app) @@ -583,6 +592,7 @@ WidgetContext::WidgetContext(std::string context_id, std::string inst_id, WidgetContext::~WidgetContext() = default; +/* LCOV_EXCL_START */ void WidgetContext::OnPause() { std::string id = GetInstId(); _D("WidgetContext(%s) is paused", id.c_str()); @@ -617,6 +627,7 @@ void WidgetContext::OnResume() { __context.SetFgSignal(true); } } +/* LCOV_EXCL_STOP */ void WidgetContext::OnResize(int w, int h) { } diff --git a/src/base/widget_base_legacy.c b/src/base/widget_base_legacy.c index 40115b7..5e44d2c 100644 --- a/src/base/widget_base_legacy.c +++ b/src/base/widget_base_legacy.c @@ -98,6 +98,7 @@ static bool __is_permanent; static void __call_update_cb(const char *class_id, const char *id, int force, const char *content_raw); +/* LCOV_EXCL_START */ static gboolean __timeout_cb(gpointer user_data) { widget_base_instance_data *data = @@ -911,11 +912,9 @@ EXPORT_API int widget_base_context_set_content_info( free(raw); if (ret < 0) { - /* LCOV_EXCL_START */ LOGE("failed to send content info: %s of %s (%d)", id, class_id, ret); return WIDGET_BASE_ERROR_IO_ERROR; - /* LCOV_EXCL_STOP */ } return WIDGET_BASE_ERROR_NONE; @@ -1574,3 +1573,4 @@ EXPORT_API widget_base_class *widget_base_class_add(widget_base_class cls, return c; } +/* LCOV_EXCL_STOP */ \ No newline at end of file diff --git a/src/efl_base/widget_app.cc b/src/efl_base/widget_app.cc index c35a6a1..a97b2ea 100644 --- a/src/efl_base/widget_app.cc +++ b/src/efl_base/widget_app.cc @@ -87,7 +87,7 @@ class AppWidget : public WidgetBase { WidgetBase::OnTerminate(); return -1; } - +/* LCOV_EXCL_START */ void OnLoopInit(int argc, char** argv) override { elm_init(argc, argv); } @@ -99,17 +99,17 @@ class AppWidget : public WidgetBase { void OnLoopRun() override { elm_run(); } - +/* LCOV_EXCL_STOP */ void OnLoopExit() override { elm_exit(); } - +/* LCOV_EXCL_START */ int OnTrimMemory() override { _D("Trim memory"); elm_cache_all_flush(); return WidgetBase::OnTrimMemory(); } - +/* LCOV_EXCL_STOP */ private: widget_app_lifecycle_callback_s* callback_; void* user_data_; @@ -237,6 +237,7 @@ class AppWidgetContext : public WidgetContext { } private: +/* LCOV_EXCL_START */ void SetIconifyTimer() { if (iconify_timer_) return; @@ -256,7 +257,7 @@ class AppWidgetContext : public WidgetContext { return G_SOURCE_REMOVE; }, this); } - +/* LCOV_EXCL_STOP */ void UnsetIconifyTimer() { if (iconify_timer_) { g_source_remove(iconify_timer_); @@ -294,8 +295,8 @@ API int widget_app_main(int argc, char** argv, } if (callback->create == nullptr) { - _E("widget_app_create_cb() callback must be registered"); - return WIDGET_ERROR_INVALID_PARAMETER; + _E("widget_app_create_cb() callback must be registered");/* LCOV_EXCL_LINE */ + return WIDGET_ERROR_INVALID_PARAMETER;/* LCOV_EXCL_LINE */ } try { @@ -304,8 +305,8 @@ API int widget_app_main(int argc, char** argv, __app_widget->AddEvent(i); __app_widget->Run(argc, argv); - } catch (std::runtime_error& e) { - return WIDGET_ERROR_FAULT; + } catch (std::runtime_error& e) {/* LCOV_EXCL_LINE */ + return WIDGET_ERROR_FAULT;/* LCOV_EXCL_LINE */ } return WIDGET_ERROR_NONE; @@ -337,8 +338,8 @@ API int widget_app_terminate_context(widget_context_h context) { return WIDGET_ERROR_NOT_SUPPORTED; if (context == nullptr) { - _E("Invalid parameter"); - return WIDGET_ERROR_INVALID_PARAMETER; + _E("Invalid parameter");/* LCOV_EXCL_LINE */ + return WIDGET_ERROR_INVALID_PARAMETER;/* LCOV_EXCL_LINE */ } auto* cxt = reinterpret_cast(context); @@ -356,8 +357,8 @@ API int widget_app_foreach_context(widget_context_cb cb, void* data) { return WIDGET_ERROR_NOT_SUPPORTED; if (cb == nullptr) { - _E("Invalid parameter"); - return WIDGET_ERROR_INVALID_PARAMETER; + _E("Invalid parameter");/* LCOV_EXCL_LINE */ + return WIDGET_ERROR_INVALID_PARAMETER;/* LCOV_EXCL_LINE */ } if (__app_widget.get() == nullptr) @@ -395,15 +396,15 @@ API int widget_app_add_event_handler(app_event_handler_h* event_handler, auto* app_event = new (std::nothrow) AppEvent( ::__app_event_converter[event_type], callback, user_data); if (app_event == nullptr) { - _E("Out of memory"); - return WIDGET_ERROR_OUT_OF_MEMORY; + _E("Out of memory");/* LCOV_EXCL_LINE */ + return WIDGET_ERROR_OUT_OF_MEMORY;/* LCOV_EXCL_LINE */ } auto* h = new (std::nothrow) std::shared_ptr(app_event); if (h == nullptr) { - _E("Out of memory"); - delete app_event; - return WIDGET_ERROR_OUT_OF_MEMORY; + _E("Out of memory");/* LCOV_EXCL_LINE */ + delete app_event;/* LCOV_EXCL_LINE */ + return WIDGET_ERROR_OUT_OF_MEMORY;/* LCOV_EXCL_LINE */ } if (__app_widget.get() != nullptr) @@ -444,18 +445,18 @@ API const char* widget_app_get_id(widget_context_h context) { bool feature; int ret = system_info_get_platform_bool(kFeatureShellAppWidget, &feature); if (ret < 0) { - set_last_result(WIDGET_ERROR_FAULT); - return nullptr; + set_last_result(WIDGET_ERROR_FAULT);/* LCOV_EXCL_LINE */ + return nullptr;/* LCOV_EXCL_LINE */ } if (!feature) { - set_last_result(WIDGET_ERROR_NOT_SUPPORTED); - return nullptr; + set_last_result(WIDGET_ERROR_NOT_SUPPORTED);/* LCOV_EXCL_LINE */ + return nullptr;/* LCOV_EXCL_LINE */ } if (context == nullptr) { - set_last_result(WIDGET_ERROR_INVALID_PARAMETER); - return nullptr; + set_last_result(WIDGET_ERROR_INVALID_PARAMETER);/* LCOV_EXCL_LINE */ + return nullptr;/* LCOV_EXCL_LINE */ } auto* cxt = reinterpret_cast(context); @@ -474,8 +475,8 @@ API int widget_app_get_elm_win(widget_context_h context, Evas_Object** win) { return WIDGET_ERROR_NOT_SUPPORTED; if (context == nullptr || win == nullptr) { - _E("Invalid parameter"); - return WIDGET_ERROR_INVALID_PARAMETER; + _E("Invalid parameter");/* LCOV_EXCL_LINE */ + return WIDGET_ERROR_INVALID_PARAMETER;/* LCOV_EXCL_LINE */ } auto* cxt = reinterpret_cast(context); @@ -494,9 +495,9 @@ API int widget_app_get_elm_win(widget_context_h context, Evas_Object** win) { Ecore_Wl2_Window* wl_win = ecore_evas_wayland2_window_get( ecore_evas_ecore_evas_get(evas_object_evas_get(ret_win))); if (wl_win == nullptr) { - _E("Failed to get wayland window"); - evas_object_del(ret_win); - return WIDGET_ERROR_FAULT; + _E("Failed to get wayland window");/* LCOV_EXCL_LINE */ + evas_object_del(ret_win);/* LCOV_EXCL_LINE */ + return WIDGET_ERROR_FAULT;/* LCOV_EXCL_LINE */ } ecore_wl2_window_class_set(wl_win, id.c_str()); @@ -527,32 +528,32 @@ API widget_class_h widget_app_class_add(widget_class_h widget_class, bool feature; int ret = system_info_get_platform_bool(kFeatureShellAppWidget, &feature); if (ret < 0) { - set_last_result(WIDGET_ERROR_FAULT); - return nullptr; + set_last_result(WIDGET_ERROR_FAULT);/* LCOV_EXCL_LINE */ + return nullptr;/* LCOV_EXCL_LINE */ } if (!feature) { - set_last_result(WIDGET_ERROR_NOT_SUPPORTED); - return nullptr; + set_last_result(WIDGET_ERROR_NOT_SUPPORTED);/* LCOV_EXCL_LINE */ + return nullptr;/* LCOV_EXCL_LINE */ } if (class_id == nullptr || callback.create == nullptr) { - _E("Invalid parameter"); - set_last_result(WIDGET_ERROR_INVALID_PARAMETER); - return nullptr; + _E("Invalid parameter");/* LCOV_EXCL_LINE */ + set_last_result(WIDGET_ERROR_INVALID_PARAMETER);/* LCOV_EXCL_LINE */ + return nullptr;/* LCOV_EXCL_LINE */ } if (__app_widget.get() == nullptr) { - set_last_result(WIDGET_ERROR_FAULT); - return nullptr; + set_last_result(WIDGET_ERROR_FAULT);/* LCOV_EXCL_LINE */ + return nullptr;/* LCOV_EXCL_LINE */ } auto factory = std::shared_ptr( new (std::nothrow) AppWidgetContext::Factory( class_id, callback, user_data)); if (factory.get() == nullptr) { - set_last_result(WIDGET_ERROR_OUT_OF_MEMORY); - return nullptr; + set_last_result(WIDGET_ERROR_OUT_OF_MEMORY);/* LCOV_EXCL_LINE */ + return nullptr;/* LCOV_EXCL_LINE */ } __app_widget->AddContextFactory(std::move(factory), class_id); @@ -567,26 +568,26 @@ API widget_class_h widget_app_class_create( bool feature; int ret = system_info_get_platform_bool(kFeatureShellAppWidget, &feature); if (ret < 0) { - set_last_result(WIDGET_ERROR_FAULT); - return nullptr; + set_last_result(WIDGET_ERROR_FAULT);/* LCOV_EXCL_LINE */ + return nullptr;/* LCOV_EXCL_LINE */ } if (!feature) { - set_last_result(WIDGET_ERROR_NOT_SUPPORTED); - return nullptr; + set_last_result(WIDGET_ERROR_NOT_SUPPORTED);/* LCOV_EXCL_LINE */ + return nullptr;/* LCOV_EXCL_LINE */ } if (callback.create == nullptr) { - _E("Invalid parameter"); - set_last_result(WIDGET_ERROR_INVALID_PARAMETER); - return nullptr; + _E("Invalid parameter");/* LCOV_EXCL_LINE */ + set_last_result(WIDGET_ERROR_INVALID_PARAMETER);/* LCOV_EXCL_LINE */ + return nullptr;/* LCOV_EXCL_LINE */ } char* appid = nullptr; app_get_id(&appid); if (appid == nullptr) { - LOGE("app_get_id() is failed"); - return nullptr; + LOGE("app_get_id() is failed");/* LCOV_EXCL_LINE */ + return nullptr;/* LCOV_EXCL_LINE */ } std::unique_ptr ptr(appid, std::free); @@ -604,8 +605,8 @@ API int widget_app_context_set_tag(widget_context_h context, void* tag) { return WIDGET_ERROR_NOT_SUPPORTED; if (context == nullptr) { - _E("Invalid parameter"); - return WIDGET_ERROR_INVALID_PARAMETER; + _E("Invalid parameter");/* LCOV_EXCL_LINE */ + return WIDGET_ERROR_INVALID_PARAMETER;/* LCOV_EXCL_LINE */ } auto* cxt = reinterpret_cast(context); @@ -623,8 +624,8 @@ API int widget_app_context_get_tag(widget_context_h context, void** tag) { return WIDGET_ERROR_NOT_SUPPORTED; if (context == nullptr || tag == nullptr) { - _E("Invalid parameter"); - return WIDGET_ERROR_INVALID_PARAMETER; + _E("Invalid parameter");/* LCOV_EXCL_LINE */ + return WIDGET_ERROR_INVALID_PARAMETER;/* LCOV_EXCL_LINE */ } auto* cxt = reinterpret_cast(context); @@ -643,15 +644,15 @@ API int widget_app_context_set_content_info(widget_context_h context, return WIDGET_ERROR_NOT_SUPPORTED; if (context == nullptr || content_info == nullptr) { - _E("Invalid parameter"); - return WIDGET_ERROR_INVALID_PARAMETER; + _E("Invalid parameter");/* LCOV_EXCL_LINE */ + return WIDGET_ERROR_INVALID_PARAMETER;/* LCOV_EXCL_LINE */ } auto* cxt = reinterpret_cast(context); ret = cxt->SetContents(tizen_base::Bundle(content_info)); if (ret != WIDGET_ERROR_NONE) { - _E("Failed to set content"); - return static_cast(ret); + _E("Failed to set content");/* LCOV_EXCL_LINE */ + return static_cast(ret);/* LCOV_EXCL_LINE */ } return WIDGET_ERROR_NONE; @@ -668,13 +669,13 @@ API int widget_app_context_set_title(widget_context_h context, return WIDGET_ERROR_NOT_SUPPORTED; if (context == nullptr || title == nullptr) { - _E("Invalid parameter"); - return WIDGET_ERROR_INVALID_PARAMETER; + _E("Invalid parameter");/* LCOV_EXCL_LINE */ + return WIDGET_ERROR_INVALID_PARAMETER;/* LCOV_EXCL_LINE */ } auto* cxt = reinterpret_cast(context); if (cxt->GetWindow()) - elm_win_title_set(cxt->GetWindow(), title); + elm_win_title_set(cxt->GetWindow(), title);/* LCOV_EXCL_LINE */ return WIDGET_ERROR_NONE; } diff --git a/test/unit_tests/main.cc b/test/unit_tests/main.cc index 5f340cd..d945e33 100644 --- a/test/unit_tests/main.cc +++ b/test/unit_tests/main.cc @@ -9,16 +9,16 @@ int main(int argc, char** argv) { int ret = -1; try { testing::InitGoogleTest(&argc, argv); - } catch(...) { - std::cout << "Exception occurred" << std::endl; + } catch(...) {/* LCOV_EXCL_LINE */ + std::cout << "Exception occurred" << std::endl;/* LCOV_EXCL_LINE */ } try { ret = RUN_ALL_TESTS(); - } catch (const ::testing::internal::GoogleTestFailureException& e) { - ret = -1; - std::cout << "GoogleTestFailureException was thrown:" << e.what() - << std::endl; + } catch (const ::testing::internal::GoogleTestFailureException& e) {/* LCOV_EXCL_LINE */ + ret = -1;/* LCOV_EXCL_LINE */ + std::cout << "GoogleTestFailureException was thrown:" << e.what()/* LCOV_EXCL_LINE */ + << std::endl;/* LCOV_EXCL_LINE */ } return ret; diff --git a/test/unit_tests/mock/ecore_wl2_mock.cc b/test/unit_tests/mock/ecore_wl2_mock.cc index 1cf68e6..08c0649 100644 --- a/test/unit_tests/mock/ecore_wl2_mock.cc +++ b/test/unit_tests/mock/ecore_wl2_mock.cc @@ -25,16 +25,6 @@ extern "C" int ecore_wl2_init() { return MOCK_HOOK_P0(EcoreWl2Mock, ecore_wl2_init); } -extern "C" Ecore_Wl2_Display* ecore_wl2_connected_display_get( - const char *display) { - return MOCK_HOOK_P1(EcoreWl2Mock, ecore_wl2_connected_display_get, display); -} - -extern "C" void ecore_wl2_window_iconified_set( - Ecore_Wl2_Window *win, Eina_Bool flag) { - return MOCK_HOOK_P2(EcoreWl2Mock, ecore_wl2_window_iconified_set, win, flag); -} - extern "C" void ecore_wl2_window_class_set( Ecore_Wl2_Window *win, const char *name) { return MOCK_HOOK_P2(EcoreWl2Mock, ecore_wl2_window_class_set, win, name); @@ -45,19 +35,6 @@ extern "C" int ecore_wl2_window_id_get( return MOCK_HOOK_P1(EcoreWl2Mock, ecore_wl2_window_id_get, win); } -extern "C" void ecore_wl2_display_disconnect( - Ecore_Wl2_Display *display) { - return MOCK_HOOK_P1(EcoreWl2Mock, ecore_wl2_display_disconnect, display); -} - -extern "C" int ecore_wl2_shutdown() { - return MOCK_HOOK_P0(EcoreWl2Mock, ecore_wl2_shutdown); -} - -extern "C" Ecore_Wl2_Display *ecore_wl2_display_connect(const char *conn) { - return MOCK_HOOK_P1(EcoreWl2Mock, ecore_wl2_display_connect, conn); -} - extern "C" Ecore_Wl2_Window *ecore_evas_wayland2_window_get(const Ecore_Evas *ee) { return MOCK_HOOK_P1(EcoreWl2Mock, ecore_evas_wayland2_window_get, ee); } @@ -70,10 +47,6 @@ extern "C" Evas *evas_object_evas_get(const Eo *eo_obj) { return MOCK_HOOK_P1(EcoreWl2Mock, evas_object_evas_get, eo_obj); } -extern "C" void evas_object_del(Evas_Object *obj) { - return MOCK_HOOK_P1(EcoreWl2Mock, evas_object_del, obj); -} - extern "C" struct wl_surface *ecore_wl2_window_surface_get(Ecore_Wl2_Window *window) { return MOCK_HOOK_P1(EcoreWl2Mock, ecore_wl2_window_surface_get, window); } diff --git a/test/unit_tests/mock/ecore_wl2_mock.h b/test/unit_tests/mock/ecore_wl2_mock.h index bf7f84f..e0cd5fd 100644 --- a/test/unit_tests/mock/ecore_wl2_mock.h +++ b/test/unit_tests/mock/ecore_wl2_mock.h @@ -30,28 +30,16 @@ class EcoreWl2Mock : public virtual ModuleMock { MOCK_METHOD0(ecore_wl2_init, int()); - MOCK_METHOD1(ecore_wl2_connected_display_get, - Ecore_Wl2_Display*(const char *)); - MOCK_METHOD2(ecore_wl2_window_iconified_set, - void(Ecore_Wl2_Window *, Eina_Bool)); MOCK_METHOD2(ecore_wl2_window_class_set, void(Ecore_Wl2_Window *, const char *)); MOCK_METHOD1(ecore_wl2_window_id_get, int(Ecore_Wl2_Window *)); - MOCK_METHOD1(ecore_wl2_display_disconnect, - void(Ecore_Wl2_Display *)); - MOCK_METHOD0(ecore_wl2_shutdown, - int()); - MOCK_METHOD1(ecore_wl2_display_connect, - Ecore_Wl2_Display *(const char *)); MOCK_METHOD1(ecore_evas_wayland2_window_get, Ecore_Wl2_Window *(const Ecore_Evas *)); MOCK_METHOD1(ecore_evas_ecore_evas_get, Ecore_Evas *(const Evas *)); MOCK_METHOD1(evas_object_evas_get, Evas *(const Eo *)); - MOCK_METHOD1(evas_object_del, - void (Evas_Object *)); MOCK_METHOD1(ecore_wl2_window_surface_get, struct wl_surface *(Ecore_Wl2_Window *)); MOCK_METHOD3(evas_object_data_set, diff --git a/test/unit_tests/mock/gio_mock.cc b/test/unit_tests/mock/gio_mock.cc deleted file mode 100644 index 4e048fc..0000000 --- a/test/unit_tests/mock/gio_mock.cc +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "unit_tests/mock/gio_mock.h" - -#include - -#include "unit_tests/mock/mock_hook.h" -#include "unit_tests/mock/test_fixture.h" - -extern "C" GDBusConnection* g_bus_get_sync(GBusType type, - GCancellable* cancellable, GError** error) { - return MOCK_HOOK_P3(GioMock, g_bus_get_sync, type, cancellable, error); -} - -extern "C" GDBusMessage* g_dbus_connection_send_message_with_reply_sync( - GDBusConnection* conn, GDBusMessage* msg, GDBusSendMessageFlags flags, - gint timeout, volatile guint32* out_serial, GCancellable* cancellable, - GError** error) { - return MOCK_HOOK_P7(GioMock, g_dbus_connection_send_message_with_reply_sync, - conn, msg, flags, timeout, out_serial, cancellable, error); -} - -extern "C" GDBusMessage* g_dbus_message_new_method_call(const gchar* arg0, - const gchar* arg1, const gchar* arg2, const gchar* arg3) { - return MOCK_HOOK_P4(GioMock, g_dbus_message_new_method_call, arg0, arg1, arg2, - arg3); -} - -extern "C" void g_dbus_message_set_body(GDBusMessage* arg0, GVariant* arg1) { - return MOCK_HOOK_P2(GioMock, g_dbus_message_set_body, arg0, arg1); -} - -extern "C" GVariant* g_dbus_message_get_body(GDBusMessage* arg0) { - return MOCK_HOOK_P1(GioMock, g_dbus_message_get_body, arg0); -} - -extern "C" gboolean g_dbus_connection_emit_signal(GDBusConnection* arg0, - const gchar* arg1, const gchar* arg2, const gchar* arg3, const gchar* arg4, - GVariant* arg5, GError** arg6) { - return MOCK_HOOK_P7(GioMock, g_dbus_connection_emit_signal, - arg0, arg1, arg2, arg3, arg4, arg5, arg6); -} - -extern "C" GDBusNodeInfo* g_dbus_node_info_new_for_xml( - const gchar* arg0, GError** arg1) { - return MOCK_HOOK_P2(GioMock, g_dbus_node_info_new_for_xml, arg0, arg1); -} - -extern "C" guint g_dbus_connection_register_object(GDBusConnection* arg0, - const gchar* arg1, GDBusInterfaceInfo* arg2, - const GDBusInterfaceVTable* arg3, gpointer arg4, - GDestroyNotify arg5, GError** arg6) { - return MOCK_HOOK_P7(GioMock, g_dbus_connection_register_object, - arg0, arg1, arg2, arg3, arg4, arg5, arg6); -} - -extern "C" guint g_bus_own_name_on_connection(GDBusConnection* arg0, - const gchar* arg1, GBusNameOwnerFlags arg2, - GBusNameAcquiredCallback arg3, GBusNameLostCallback arg4, - gpointer arg5, GDestroyNotify arg6) { - return MOCK_HOOK_P7(GioMock, g_bus_own_name_on_connection, - arg0, arg1, arg2, arg3, arg4, arg5, arg6); -} - -extern "C" guint g_dbus_connection_signal_subscribe(GDBusConnection* arg0, - const gchar* arg1, const gchar* arg2, const gchar* arg3, const gchar* arg4, - const gchar* arg5, GDBusSignalFlags arg6, GDBusSignalCallback arg7, - gpointer arg8, GDestroyNotify arg9) { - return MOCK_HOOK_P10(GioMock, g_dbus_connection_signal_subscribe, - arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); -} - -extern "C" void g_dbus_connection_send_message_with_reply(GDBusConnection* arg0, - GDBusMessage* arg1, GDBusSendMessageFlags arg2, gint arg3, - volatile guint32* arg4, GCancellable* arg5, GAsyncReadyCallback arg6, - gpointer arg7) { - return MOCK_HOOK_P8(GioMock, g_dbus_connection_send_message_with_reply, - arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); -} - -extern "C" GDBusMessage* g_dbus_connection_send_message_with_reply_finish( - GDBusConnection* arg0, GAsyncResult* arg1, GError** arg2) { - return MOCK_HOOK_P3(GioMock, g_dbus_connection_send_message_with_reply_finish, - arg0, arg1, arg2); -} diff --git a/test/unit_tests/mock/gio_mock.h b/test/unit_tests/mock/gio_mock.h deleted file mode 100755 index a85f992..0000000 --- a/test/unit_tests/mock/gio_mock.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef UNIT_TESTS_MOCK_GIO_MOCK_H_ -#define UNIT_TESTS_MOCK_GIO_MOCK_H_ - -#include -#include - -#include "mock/module_mock.h" - -class GioMock : public virtual ModuleMock { - public: - virtual ~GioMock() {} - - MOCK_METHOD3(g_bus_get_sync, - GDBusConnection*(GBusType, GCancellable*, GError**)); - MOCK_METHOD7(g_bus_own_name_on_connection, - guint(GDBusConnection*, const gchar*, GBusNameOwnerFlags, - GBusNameAcquiredCallback, GBusNameLostCallback, - gpointer, GDestroyNotify)); - - MOCK_METHOD4(g_dbus_message_new_method_call, - GDBusMessage*(const gchar*, const gchar*, const gchar*, const gchar*)); - MOCK_METHOD2(g_dbus_message_set_body, void(GDBusMessage*, GVariant*)); - MOCK_METHOD1(g_dbus_message_get_body, GVariant*(GDBusMessage*)); - - MOCK_METHOD7(g_dbus_connection_send_message_with_reply_sync, - GDBusMessage*(GDBusConnection*, GDBusMessage*, GDBusSendMessageFlags, - gint, volatile guint32*, GCancellable*, GError**)); - MOCK_METHOD7(g_dbus_connection_emit_signal, - gboolean(GDBusConnection*, const gchar*, const gchar*, const gchar*, - const gchar*, GVariant*, GError**)); - MOCK_METHOD7(g_dbus_connection_register_object, - guint(GDBusConnection*, const gchar*, GDBusInterfaceInfo*, - const GDBusInterfaceVTable*, gpointer, GDestroyNotify, GError**)); - MOCK_METHOD10(g_dbus_connection_signal_subscribe, - guint(GDBusConnection*, const gchar*, const gchar*, const gchar*, - const gchar*, const gchar*, GDBusSignalFlags, GDBusSignalCallback, - gpointer, GDestroyNotify)); - MOCK_METHOD8(g_dbus_connection_send_message_with_reply, - void(GDBusConnection*, GDBusMessage*, GDBusSendMessageFlags, gint, - volatile guint32*, GCancellable*, GAsyncReadyCallback, gpointer)); - MOCK_METHOD3(g_dbus_connection_send_message_with_reply_finish, - GDBusMessage*(GDBusConnection*, GAsyncResult*, GError**)); - - MOCK_METHOD2(g_dbus_node_info_new_for_xml, - GDBusNodeInfo*(const gchar*, GError**)); - - MOCK_METHOD2(g_dbus_method_invocation_return_value, - GDBusNodeInfo*(GDBusMethodInvocation*, GVariant*)); -}; - -#endif // UNIT_TESTS_MOCK_GIO_MOCK_H_ diff --git a/test/unit_tests/test_widget_app.cc b/test/unit_tests/test_widget_app.cc index 7c73261..dce49a5 100644 --- a/test/unit_tests/test_widget_app.cc +++ b/test/unit_tests/test_widget_app.cc @@ -24,13 +24,13 @@ #include #include "include/widget_app.h" +#include "include/widget_app_internal.h" #include "include/widget_app_efl.h" #include "unit_tests/mock/app_common_mock.h" #include "unit_tests/mock/appcore_multiwindow_base_mock.h" #include "unit_tests/mock/aul_mock.h" #include "unit_tests/mock/ecore_wl2_mock.h" #include "unit_tests/mock/elm_mock.h" -#include "unit_tests/mock/gio_mock.h" #include "unit_tests/mock/system_info_mock.h" #include "unit_tests/mock/test_fixture.h" #include "unit_tests/mock/widget_service_mock.h" @@ -53,6 +53,7 @@ int __instance_destroy_cb(widget_context_h context, return 0; } +/* LCOV_EXCL_START */ int __instance_pause_cb(widget_context_h context, void* user_data) { return 0; } @@ -61,13 +62,14 @@ int __instance_resume_cb(widget_context_h context, void* user_data) { return 0; } -int __instance_resize_cb(widget_context_h context, - int w, int h, void* user_data) { +int __instance_update_cb(widget_context_h context, + bundle* content, int force, void* user_data) { return 0; } +/* LCOV_EXCL_STOP */ -int __instance_update_cb(widget_context_h context, - bundle* content, int force, void* user_data) { +int __instance_resize_cb(widget_context_h context, + int w, int h, void* user_data) { return 0; } @@ -88,18 +90,17 @@ int __aul_app_get_pkgid_bypid_fake(int pid, char* pkgid, int len) { snprintf(pkgid, len, "%s", "test"); return 0; } - +/* LCOV_EXCL_START */ void __app_event_cb(app_event_info_h event_info, void *user_data) { } bool __widget_context_cb(widget_context_h context, void *user_data) { return true; } - +/* LCOV_EXCL_STOP */ } // namespace -class Mocks : public ::testing::NiceMock, - public ::testing::NiceMock, +class Mocks : public ::testing::NiceMock, public ::testing::NiceMock, public ::testing::NiceMock, public ::testing::NiceMock, @@ -221,6 +222,8 @@ class WidgetAppTest : public TestFixture { b.Add("__WIDGET_OP__", "period"); p->OnControl(b); + p->OnReceive(AUL_WIDGET_CONTENT, b); + p->OnTerminate(); } }; @@ -253,6 +256,18 @@ TEST_F(WidgetAppTest, widget_app_main) { }); } +TEST_F(WidgetAppTest, widget_app_restart) { + PrepareContext( + [](widget_context_h context, bundle* content, + int w, int h, void* user_data) -> int { + EXPECT_CALL(GetMock(), + aul_notify_exit()).WillRepeatedly(Return(0)); + widget_app_exit(); + widget_app_restart(); + return 0; + }); +} + TEST_F(WidgetAppTest, widget_app_add_event_handler) { app_event_handler_h handle; EXPECT_CALL(GetMock(), diff --git a/test/unit_tests/test_widget_app_cpp.cc b/test/unit_tests/test_widget_app_cpp.cc index 8d5fca5..ec8ef39 100644 --- a/test/unit_tests/test_widget_app_cpp.cc +++ b/test/unit_tests/test_widget_app_cpp.cc @@ -26,7 +26,6 @@ #include "unit_tests/mock/aul_mock.h" #include "unit_tests/mock/ecore_wl2_mock.h" #include "unit_tests/mock/elm_mock.h" -#include "unit_tests/mock/gio_mock.h" #include "unit_tests/mock/system_info_mock.h" #include "unit_tests/mock/test_fixture.h" #include "unit_tests/mock/widget_service_mock.h" @@ -37,8 +36,7 @@ using ::testing::Invoke; using ::testing::Return; using ::testing::SetArgPointee; -class Mocks : public ::testing::NiceMock, - public ::testing::NiceMock, +class Mocks : public ::testing::NiceMock, public ::testing::NiceMock, public ::testing::NiceMock, public ::testing::NiceMock, @@ -63,12 +61,14 @@ class WidgetApp : public tizen_appfw::WidgetAppBase { }; explicit Instance(widget_context_h h) : InstanceBase(h) {} +/* LCOV_EXCL_START */ void OnCreate(const tizen_base::Bundle& content, int w, int h) override {} void OnDestroy(DestroyType reason, tizen_base::Bundle* content) override {} void OnPause() override {} void OnResume() override {} void OnResize(int w, int h) override {} void OnUpdate(const tizen_base::Bundle& content, bool force) override {} +/* LCOV_EXCL_STOP */ }; WidgetApp() {} @@ -85,6 +85,23 @@ TEST_F(WidgetAppCppTest, Run_InvalidParameter) { std::unique_ptr factory( new WidgetApp::Instance::Factory()); + widget_context_h h = nullptr; + factory->Create(h); + app.OnCreate(); int ret = app.Run(0, nullptr, std::move(factory)); EXPECT_EQ(ret, APP_ERROR_INVALID_PARAMETER); + app.OnTerminate(); } + +TEST_F(WidgetAppCppTest, NullInstance) { + EXPECT_CALL(GetMock(), + system_info_get_platform_bool(_, _)). + WillRepeatedly(DoAll(SetArgPointee<1>(true), Return(0))); + + widget_context_h h = nullptr; + std::unique_ptr inst( + new WidgetApp::Instance(h)); + + widget_context_h ret_h = inst->GetHandle(); + EXPECT_EQ(ret_h, nullptr); +} \ No newline at end of file -- 2.7.4 From c182561f55832eb085823bdb08b6da9e30c1d4c5 Mon Sep 17 00:00:00 2001 From: Inkyun Kil Date: Thu, 21 Sep 2023 19:20:23 +0900 Subject: [PATCH 12/16] Release version 1.5.1 changes: - Change unittest package name and improves code coverage Change-Id: Ifff9a569f9242cd17ab2886d9a65b3fe075aae90 Signed-off-by: Inkyun Kil --- packaging/appcore-widget.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/appcore-widget.spec b/packaging/appcore-widget.spec index b722455..61a7ede 100644 --- a/packaging/appcore-widget.spec +++ b/packaging/appcore-widget.spec @@ -1,6 +1,6 @@ Name: appcore-widget Summary: Widget Application -Version: 1.5.0 +Version: 1.5.1 Release: 1 Group: Application Framework/Libraries License: Apache-2.0 -- 2.7.4 From d21f15ff6374207d7284186dbf7fcd549f826c8e Mon Sep 17 00:00:00 2001 From: Inkyun Kil Date: Tue, 12 Mar 2024 13:05:47 +0900 Subject: [PATCH 13/16] Fix lcov option for lcov 2.0 Change-Id: I4e63c4746e01b26f61aa5b2dc7f9c1caf928915e Signed-off-by: Inkyun Kil --- packaging/appcore-widget.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/appcore-widget.spec b/packaging/appcore-widget.spec index 61a7ede..cba50b7 100644 --- a/packaging/appcore-widget.spec +++ b/packaging/appcore-widget.spec @@ -130,7 +130,7 @@ install -m 0755 run-unittest.sh %{buildroot}%{_bindir}/tizen-unittests/%{name}/ export LD_LIBRARY_PATH=../../src/base:../../src/efl_base ctest -V %if 0%{?gcov:1} -lcov -c --ignore-errors graph --no-external -q -d . -o appcore-widget.info +lcov -c --ignore-errors mismatch,graph,unused --no-external -q -d . -o appcore-widget.info genhtml appcore-widget.info -o appcore-widget.out zip -r appcore-widget.zip appcore-widget.out install -m 0644 appcore-widget.zip %{buildroot}%{_datadir}/gcov/obj/ -- 2.7.4 From 7d0c39395beada62d84ba8fd59b51367b63e44a6 Mon Sep 17 00:00:00 2001 From: Inkyun Kil Date: Tue, 12 Mar 2024 13:27:11 +0900 Subject: [PATCH 14/16] Release version 1.5.2 changes: - Fix lcov option for lcov 2.0 Change-Id: Ic90e350d68467828a976f8e57dc831ab38b5c7a9 Signed-off-by: Inkyun Kil --- packaging/appcore-widget.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/appcore-widget.spec b/packaging/appcore-widget.spec index cba50b7..7a5c053 100644 --- a/packaging/appcore-widget.spec +++ b/packaging/appcore-widget.spec @@ -1,6 +1,6 @@ Name: appcore-widget Summary: Widget Application -Version: 1.5.1 +Version: 1.5.2 Release: 1 Group: Application Framework/Libraries License: Apache-2.0 -- 2.7.4 From 5952fedca21771977a0f8ea5975818a79a4a9430 Mon Sep 17 00:00:00 2001 From: SukhyungKang Date: Tue, 14 May 2024 14:30:40 +0900 Subject: [PATCH 15/16] Modify api documentation Change-Id: I54f1e9007f7629f19a50cad59aa870868c3eb557 Signed-off-by: SukhyungKang --- include/widget_app.h | 24 ++++++++++++++++++++++++ include/widget_app_efl.h | 18 ++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/include/widget_app.h b/include/widget_app.h index f387349..a44e45e 100644 --- a/include/widget_app.h +++ b/include/widget_app.h @@ -289,6 +289,7 @@ int widget_app_foreach_context(widget_context_cb callback, void *data); /** * @brief Adds the system event handler. * @since_tizen 2.3.1 + * @remarks The @a event_handler should be released using widget_app_remove_event_handler(). * @param[out] event_handler The event handler * @param[in] event_type The system event type. #APP_EVENT_DEVICE_ORIENTATION_CHANGED is not supported * @param[in] callback The callback function @@ -300,6 +301,27 @@ int widget_app_foreach_context(widget_context_cb callback, void *data); * @retval #WIDGET_ERROR_INVALID_PARAMETER Invalid parameter * @retval #WIDGET_ERROR_OUT_OF_MEMORY Out of memory * @retval #WIDGET_ERROR_FAULT Unrecoverable error + * @par Example + * @code +#include + +static void +widget_app_event_cb(app_event_info_h event_info, void *user_data) +{ +} +... +int main() +{ + int ret; + app_event_handler_h event_handler = NULL; + + r = widget_app_add_event_handler(&event_handler, APP_EVENT_LOW_BATTERY, widget_app_event_cb, NULL); + ... + r = widget_app_remove_event_handler(event_handler); + + return 0; +} + * @endcode * @see app_event_type_e * @see app_event_cb() * @see widget_app_remove_event_handler() @@ -381,6 +403,7 @@ int widget_app_context_set_tag(widget_context_h context, void *tag); /** * @brief Gets the tag in the context. * @since_tizen 2.3.1 + * @remarks Releasing the @a tag value depends on the value that set by widget_app_context_set_tag() function. * @param[in] context The context for widget instance * @param[out] tag The value to get * @return #WIDGET_ERROR_NONE on success, @@ -389,6 +412,7 @@ int widget_app_context_set_tag(widget_context_h context, void *tag); * @retval #WIDGET_ERROR_NOT_SUPPORTED Not supported * @retval #WIDGET_ERROR_INVALID_PARAMETER Invalid parameter * @retval #WIDGET_ERROR_FAULT Unrecoverable error + * @see widget_app_context_set_tag() */ int widget_app_context_get_tag(widget_context_h context, void **tag); diff --git a/include/widget_app_efl.h b/include/widget_app_efl.h index 8817395..5deb827 100644 --- a/include/widget_app_efl.h +++ b/include/widget_app_efl.h @@ -34,6 +34,7 @@ extern "C" { /** * @brief Gets an Evas object for the widget. * @since_tizen 2.3.1 + * @remarks The @a win should be released using evas_object_del(). * @param[in] context The context for widget instance * @param[out] win evas object for window * @return 0 on success, @@ -42,6 +43,23 @@ extern "C" { * @retval #WIDGET_ERROR_NOT_SUPPORTED Not supported * @retval #WIDGET_ERROR_INVALID_PARAMETER Invalid parameter * @retval #WIDGET_ERROR_FAULT Failed to make evas object + * @par Example + * @code +#include + +int widget_create(widget_context_h context) +{ + Evas_Object *win = NULL; + int ret; + + ret = widget_app_elm_win(context, &win); + ... + evas_object_del(win) + + return 0; +} + * @endcode + * @see evas_object_del() */ int widget_app_get_elm_win(widget_context_h context, Evas_Object **win); -- 2.7.4 From f1272e4e2714e375c3483de89cfaf8619fafbda5 Mon Sep 17 00:00:00 2001 From: SukhyungKang Date: Fri, 17 May 2024 13:09:27 +0900 Subject: [PATCH 16/16] Change to use std::move to avoid copy Change-Id: I89ca5d94f32d32051c86d3ece0b9781b4cc93fc3 Signed-off-by: SukhyungKang --- test/unit_tests/test_widget_app.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit_tests/test_widget_app.cc b/test/unit_tests/test_widget_app.cc index dce49a5..ebf0fa0 100644 --- a/test/unit_tests/test_widget_app.cc +++ b/test/unit_tests/test_widget_app.cc @@ -222,7 +222,7 @@ class WidgetAppTest : public TestFixture { b.Add("__WIDGET_OP__", "period"); p->OnControl(b); - p->OnReceive(AUL_WIDGET_CONTENT, b); + p->OnReceive(AUL_WIDGET_CONTENT, std::move(b)); p->OnTerminate(); } -- 2.7.4