diff options
author | hyunho <hhstark.kang@samsung.com> | 2020-09-15 17:04:46 +0900 |
---|---|---|
committer | hyunho <hhstark.kang@samsung.com> | 2020-09-15 17:55:54 +0900 |
commit | 083f63fba450dd6cdacb3e324434af947c6507b3 (patch) | |
tree | 551f097d2d6b39ee340323fad3397dcf1e24f3cb | |
parent | a25fcc613467100337013504c4dae2825934493d (diff) | |
download | widget-service-083f63fba450dd6cdacb3e324434af947c6507b3.tar.gz widget-service-083f63fba450dd6cdacb3e324434af947c6507b3.tar.bz2 widget-service-083f63fba450dd6cdacb3e324434af947c6507b3.zip |
Fix gtest memory leak
Change-Id: I6b7f22545ffa10473c31a1e38ba85ab5d05f4661
Signed-off-by: hyunho <hhstark.kang@samsung.com>
-rw-r--r-- | unittest/src/test_widget_service.cc | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/unittest/src/test_widget_service.cc b/unittest/src/test_widget_service.cc index 141c4bc..aec4a7c 100644 --- a/unittest/src/test_widget_service.cc +++ b/unittest/src/test_widget_service.cc @@ -301,7 +301,8 @@ TEST_F(WidgetServiceTest, GetMainAppId) { char *app_id = NULL; app_id = widget_service_get_main_app_id("org.tizen.test_widget"); - ASSERT_STREQ(app_id, "org.tizen.mainappid"); + auto p = std::unique_ptr<char, decltype(std::free)*>(app_id, std::free); + ASSERT_STREQ(p.get(), "org.tizen.mainappid"); } int _widget_list_by_pkgid_cb(const char *widget_id, int is_prime, void *user_data) { @@ -319,42 +320,49 @@ TEST_F(WidgetServiceTest, GetWidgetId) { char *widget_id = NULL; widget_id = widget_service_get_widget_id("org.tizen.test_appid"); - ASSERT_STREQ(widget_id, "org.tizen.test_widget"); + auto p = std::unique_ptr<char, decltype(std::free)*>(widget_id, std::free); + ASSERT_STREQ(p.get(), "org.tizen.test_widget"); } TEST_F(WidgetServiceTest, GetAppIdOfSetupApp) { char *app_id = NULL; app_id = widget_service_get_app_id_of_setup_app("org.tizen.test_widget"); - ASSERT_STREQ(app_id, "org.tizen.setup_appid"); + auto p = std::unique_ptr<char, decltype(std::free)*>(app_id, std::free); + ASSERT_STREQ(p.get(), "org.tizen.setup_appid"); } TEST_F(WidgetServiceTest, GetPackageId) { char *package_id = NULL; package_id = widget_service_get_package_id("org.tizen.test_widget"); - ASSERT_STREQ(package_id, "org.tizen.test_pkgid"); + auto p = std::unique_ptr<char, decltype(std::free)*>(package_id, std::free); + ASSERT_STREQ(p.get(), "org.tizen.test_pkgid"); } TEST_F(WidgetServiceTest, GetName) { char *name = NULL; name = widget_service_get_name("org.tizen.test_widget", "en-us"); - ASSERT_STREQ(name, "TestWidget"); + auto p = std::unique_ptr<char, decltype(std::free)*>(name, std::free); + ASSERT_STREQ(p.get(), "TestWidget"); } TEST_F(WidgetServiceTest, GetPreviewImagePath) { char *path = NULL; - path = widget_service_get_preview_image_path("org.tizen.test_widget", WIDGET_SIZE_TYPE_4x2); - ASSERT_STREQ(path, "/unittest/preview.png"); + path = widget_service_get_preview_image_path( + "org.tizen.test_widget", WIDGET_SIZE_TYPE_4x2); + auto p = std::unique_ptr<char, decltype(std::free)*>(path, std::free); + ASSERT_STREQ(p.get(), "/unittest/preview.png"); } TEST_F(WidgetServiceTest, GetIcon) { char *path = NULL; path = widget_service_get_icon("org.tizen.test_pkgid", "en-us"); - ASSERT_STREQ(path, "/unittest/icon.png"); + auto p = std::unique_ptr<char, decltype(std::free)*>(path, std::free); + ASSERT_STREQ(p.get(), "/unittest/icon.png"); } TEST_F(WidgetServiceTest, GetNodisplay) { @@ -426,8 +434,10 @@ TEST_F(WidgetServiceTest, GetContent) { int ret; bundle *b; - ret = widget_service_get_content_of_widget_instance("org.tizen.test_widget", "org.tizen.test_widget", &b); + ret = widget_service_get_content_of_widget_instance( + "org.tizen.test_widget", "org.tizen.test_widget", &b); ASSERT_EQ(ret, WIDGET_ERROR_NONE); + bundle_free(b); } /* internal api */ |