From b57d01639f76a094b15bbd50be7333a0da16bfa1 Mon Sep 17 00:00:00 2001 From: "SukHyung, Kang" Date: Wed, 29 Apr 2020 18:57:56 +0900 Subject: [PATCH] Add new unittest TCs Change-Id: Iecd0ab655fe8f22b876a217979c9be8f615d3e1a Signed-off-by: SukHyung, Kang --- CMakeLists.txt | 2 +- packaging/libwidget_service.spec | 21 +- unittest/CMakeLists.txt | 4 +- unittest/mock/aul_mock.h | 54 ++++ unittest/mock/cynara_mock.h | 42 +++ unittest/mock/db_mock.cc | 266 +++++++++++++++++ unittest/mock/db_mock.h | 32 ++ unittest/mock/fcntl_mock.h | 34 +++ unittest/mock/mock.cc | 53 +++- unittest/mock/mock.h | 2 +- unittest/mock/pkgmgr_info_mock.h | 43 +++ unittest/mock/system_info_mock.h | 33 +++ unittest/mock/tzplatform_config_mock.h | 37 +++ unittest/src/test_main.cc | 1 + unittest/src/test_widget_service.cc | 422 ++++++++++++++++++++++++++- unittest/src/test_widget_service_instance.cc | 308 +++++++++++++++++++ 16 files changed, 1342 insertions(+), 12 deletions(-) create mode 100644 unittest/mock/aul_mock.h create mode 100644 unittest/mock/cynara_mock.h create mode 100644 unittest/mock/db_mock.cc create mode 100644 unittest/mock/db_mock.h create mode 100644 unittest/mock/fcntl_mock.h create mode 100644 unittest/mock/pkgmgr_info_mock.h create mode 100644 unittest/mock/system_info_mock.h create mode 100644 unittest/mock/tzplatform_config_mock.h create mode 100644 unittest/src/test_widget_service_instance.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index bf3a5c9..5ea780b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -PROJECT(widget_service C) +PROJECT(widget_service C CXX) SET(PREFIX ${CMAKE_INSTALL_PREFIX}) SET(EXEC_PREFIX "\${prefix}") diff --git a/packaging/libwidget_service.spec b/packaging/libwidget_service.spec index 8d37dab..f37dccd 100644 --- a/packaging/libwidget_service.spec +++ b/packaging/libwidget_service.spec @@ -30,6 +30,11 @@ BuildRequires: pkgconfig(iniparser) BuildRequires: pkgconfig(libsmack) BuildRequires: pkgconfig(gmock) +%if 0%{?gcov:1} +BuildRequires: lcov +BuildRequires: zip +%endif + %if "%{model_build_feature_widget}" == "0" ExclusiveArch: %endif @@ -47,6 +52,9 @@ Requires: %{name} = %{version}-%{release} %description devel Gathering the installed widget information. +################################################# +# widget_service_gcov +################################################# %if 0%{?gcov:1} %package gcov Summary: Widget Service API(gcov) @@ -70,13 +78,22 @@ export LDFLAGS+=" -lgcov" MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` %cmake . -DFULLVER=%{version} -DMAJORVER=${MAJORVER} -make %{?jobs:-j%jobs} +%__make %{?jobs:-j%jobs} %if 0%{?gcov:1} mkdir -p gcov-obj find . -name '*.gcno' -exec cp '{}' gcov-obj ';' %endif +%check +ctest -V +%if 0%{?gcov:1} +lcov -c --ignore-errors graph --no-external -q -d . -o widget_service.info +genhtml widget_service.info -o widget_service.out +zip -r widget_service.zip widget_service.out widget_service.info +install -m 0644 widget_service.zip %{buildroot}%{_datadir}/gcov/ +%endif + %install rm -rf %{buildroot} %make_install @@ -162,7 +179,7 @@ GTest for widget_service %if 0%{?gcov:1} %files gcov -%{_datadir}/gcov/obj/* +%{_datadir}/gcov/* %endif # End of a file diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt index 8a6840b..4c254b5 100644 --- a/unittest/CMakeLists.txt +++ b/unittest/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) PROJECT(widget_service_unittests) INCLUDE(FindPkgConfig) @@ -6,6 +6,8 @@ pkg_check_modules(widget_service_unittests REQUIRED dlog gmock glib-2.0 + sqlite3 + bundle ) FOREACH(flag ${widget_service_unittests_CFLAGS}) diff --git a/unittest/mock/aul_mock.h b/unittest/mock/aul_mock.h new file mode 100644 index 0000000..0916a7f --- /dev/null +++ b/unittest/mock/aul_mock.h @@ -0,0 +1,54 @@ +/* + * 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 MOCK_AUL_WIDGET_H_ +#define MOCK_AUL_WIDGET_H_ + +#include "mock.h" +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void *aul_app_com_result_e; +typedef void *aul_app_com_permission_h; +typedef void *aul_app_com_connection_h; + +typedef int (*app_com_cb)(const char *endpoint, aul_app_com_result_e result, bundle *envelope, void *user_data); +typedef void (*aul_widget_instance_foreach_cb)(const char *instance_id, void *data); + +DECLARE_FAKE_VALUE_FUNC(int, aul_widget_service_set_disable, + const char *, bool); +DECLARE_FAKE_VALUE_FUNC(int, aul_app_com_create, const char *, aul_app_com_permission_h, + app_com_cb, void *, aul_app_com_connection_h *); +DECLARE_FAKE_VALUE_FUNC(int, aul_app_com_leave, aul_app_com_connection_h); +DECLARE_FAKE_VALUE_FUNC(int, aul_widget_instance_update, const char *, + const char *, bundle *); +DECLARE_FAKE_VALUE_FUNC(int, aul_widget_instance_foreach, const char *, + aul_widget_instance_foreach_cb, void *); +DECLARE_FAKE_VALUE_FUNC(int, aul_widget_instance_get_content, const char *, + const char *, char **); +DECLARE_FAKE_VALUE_FUNC(int, aul_widget_instance_count, const char *); +DECLARE_FAKE_VALUE_FUNC(int, aul_launch_app_async, const char *, bundle *); +DECLARE_FAKE_VALUE_FUNC(int, aul_debug_info_init); +DECLARE_FAKE_VALUE_FUNC(int, aul_debug_info_set, bundle *, bundle *); + + +#ifdef __cplusplus +} +#endif +#endif /* MOCK_AUL_WIDGET_H_ */ \ No newline at end of file diff --git a/unittest/mock/cynara_mock.h b/unittest/mock/cynara_mock.h new file mode 100644 index 0000000..1e493b1 --- /dev/null +++ b/unittest/mock/cynara_mock.h @@ -0,0 +1,42 @@ +/* + * 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 MOCK_CYNARA_H_ +#define MOCK_CYNARA_H_ + +#include "mock.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void cynara; +typedef void* cynara_configuration; + +#define CYNARA_API_ACCESS_ALLOWED 2 + +#define CYNARA_API_SUCCESS 0 + +DECLARE_FAKE_VALUE_FUNC(int, cynara_initialize, cynara**, + const cynara_configuration*); +DECLARE_FAKE_VALUE_FUNC(int, cynara_finish, cynara*); +DECLARE_FAKE_VALUE_FUNC(int, cynara_check, cynara*, + const char*, const char*, const char*, const char*); + +#ifdef __cplusplus +} +#endif +#endif /* MOCK_CYNARA_CLIENT_H_ */ \ No newline at end of file diff --git a/unittest/mock/db_mock.cc b/unittest/mock/db_mock.cc new file mode 100644 index 0000000..cb82ccc --- /dev/null +++ b/unittest/mock/db_mock.cc @@ -0,0 +1,266 @@ +/* + * 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 +#include +#include +#include "db_mock.h" + +#define CREATE_WIDGET_TABLE " \ +PRAGMA user_version = 50; \ +PRAGMA journal_mode = PERSIST; \ +PRAGMA foreign_keys = ON; \ +BEGIN EXCLUSIVE TRANSACTION; \ +CREATE TABLE widget_class ( \ + classid TEXT NOT NULL, \ + update_period INTEGER DEFAULT 0, \ + setup_appid TEXT, \ + appid TEXT NOT NULL, \ + pkgid TEXT NOT NULL, \ + nodisplay INTEGER DEFAULT 0, \ + max_instance INTEGER DEFAULT 0, \ + prime INTEGER DEFAULT 0, \ + is_disable INTEGER DEFAULT 0, \ + PRIMARY KEY(classid) \ +); \ +CREATE TABLE support_size ( \ + classid TEXT NOT NULL, \ + preview TEXT NOT NULL, \ + frame INTEGER DEFAULT 0, \ + width INTEGER NOT NULL, \ + height INTEGER NOT NULL, \ + FOREIGN KEY(classid) REFERENCES widget_class (classid) ON DELETE CASCADE \ +); \ +CREATE TABLE label ( \ + classid TEXT NOT NULL, \ + locale TEXT DEFAULT 'No Locale', \ + label TEXT NOT NULL, \ + FOREIGN KEY(classid) REFERENCES widget_class (classid) ON DELETE CASCADE \ +); \ +CREATE TABLE icon ( \ + classid TEXT NOT NULL, \ + locale TEXT DEFAULT 'No Locale', \ + icon TEXT NOT NULL, \ + FOREIGN KEY(classid) REFERENCES widget_class (classid) ON DELETE CASCADE \ +); \ +COMMIT TRANSACTION; " + +int insert_widget_class(sqlite3 *db); +int insert_support_size(sqlite3 *db); +int insert_label(sqlite3 *db); + +const char *get_db_path() { + const char *path = ".widget_test.db"; + return path; +} + +int create_db() { + int ret; + sqlite3 *db; + + ret = sqlite3_open_v2(get_db_path(), &db, + SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE, + NULL); + if (ret != SQLITE_OK) { + printf("error 1\n"); + goto out; + } + + ret = sqlite3_exec(db, CREATE_WIDGET_TABLE, NULL, NULL, NULL); + if (ret != SQLITE_OK) { + printf("error 2\n"); + goto out; + } + +out: + if (db) + sqlite3_close_v2(db); + + return ret; +} + +int insert_widget_class(sqlite3 *db) { + int ret; + char *query = NULL; + sqlite3_stmt *stmt = NULL; + + query = sqlite3_mprintf("INSERT INTO widget_class " + "(classid, setup_appid, appid, pkgid, prime, nodisplay, max_instance) " + "VALUES (%Q, %Q, %Q, %Q, %d, %d, %d)", + "org.tizen.test_widget", "org.tizen.setup_appid", "org.tizen.test_appid", + "org.tizen.test_pkgid", 1, 2, 3); + + ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL); + if (ret != SQLITE_OK) { + printf("widget class error 1\n"); + goto out; + } + + + ret = sqlite3_step(stmt); + if (ret != SQLITE_DONE) { + printf("widget class error 2\n"); + goto out; + } + +out: + if (query) + sqlite3_free(query); + + if (stmt) + sqlite3_finalize(stmt); + + return ret; +} + +int insert_support_size(sqlite3 *db) { + int ret; + char *query = NULL; + sqlite3_stmt *stmt = NULL; + + query = sqlite3_mprintf("INSERT INTO support_size " + "(classid, preview, width, height) " + "VALUES (%Q, %Q, %d, %d)", + "org.tizen.test_widget", "/unittest/preview.png", 4, 2); + + ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL); + if (ret != SQLITE_OK) { + printf("support size error 1\n"); + goto out; + } + + + ret = sqlite3_step(stmt); + if (ret != SQLITE_DONE) { + printf("support size error 2\n"); + goto out; + } + +out: + if (query) + sqlite3_free(query); + + if (stmt) + sqlite3_finalize(stmt); + + return ret; +} + +int insert_label(sqlite3 *db) { + int ret; + char *query = NULL; + sqlite3_stmt *stmt = NULL; + + query = sqlite3_mprintf("INSERT INTO label " + "(classid, locale, label) " + "VALUES (%Q, %Q, %Q)", + "org.tizen.test_widget", "en-us", "TestWidget"); + + ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL); + if (ret != SQLITE_OK) { + printf("label error 1\n"); + goto out; + } + + + ret = sqlite3_step(stmt); + if (ret != SQLITE_DONE) { + printf("label error 2\n"); + goto out; + } + +out: + if (query) + sqlite3_free(query); + + if (stmt) + sqlite3_finalize(stmt); + + return ret; +} + +int insert_icon(sqlite3 *db) { + int ret; + char *query = NULL; + sqlite3_stmt *stmt = NULL; + + query = sqlite3_mprintf("INSERT INTO icon " + "(classid, locale, icon) " + "VALUES (%Q, %Q, %Q)", + "org.tizen.test_widget", "en-us", "/unittest/icon.png"); + + ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL); + if (ret != SQLITE_OK) { + printf("icon error 1\n"); + goto out; + } + + + ret = sqlite3_step(stmt); + if (ret != SQLITE_DONE) { + printf("icon error 2\n"); + goto out; + } + +out: + if (query) + sqlite3_free(query); + + if (stmt) + sqlite3_finalize(stmt); + + return ret; +} + +int insert_default_data() { + int ret; + sqlite3 *db; + + ret = sqlite3_open_v2(get_db_path(), &db, SQLITE_OPEN_READWRITE, NULL); + if (ret != SQLITE_OK) { + printf("insert_default_data error 1\n"); + goto out; + } + + ret = insert_widget_class(db); + if (ret != SQLITE_DONE) { + printf("insert_default_data error 2\n"); + goto out; + } + + ret = insert_support_size(db); + if (ret != SQLITE_DONE) { + printf("insert_default_data error 3\n"); + goto out; + } + + ret = insert_label(db); + if (ret != SQLITE_DONE) { + printf("insert_default_data error 4\n"); + goto out; + } + + ret = insert_icon(db); + if (ret != SQLITE_DONE) { + printf("insert_default_data error 5\n"); + goto out; + } + +out: + sqlite3_close_v2(db); + + return ret; +} \ No newline at end of file diff --git a/unittest/mock/db_mock.h b/unittest/mock/db_mock.h new file mode 100644 index 0000000..bcbaf4f --- /dev/null +++ b/unittest/mock/db_mock.h @@ -0,0 +1,32 @@ +/* + * 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 MOCK_DB_H_ +#define MOCK_DB_H_ + + +#ifdef __cplusplus +extern "C" { +#endif + +const char *get_db_path(); +int create_db(); +int insert_default_data(); + +#ifdef __cplusplus +} +#endif +#endif /* MOCK_DB_H_ */ \ No newline at end of file diff --git a/unittest/mock/fcntl_mock.h b/unittest/mock/fcntl_mock.h new file mode 100644 index 0000000..52de55c --- /dev/null +++ b/unittest/mock/fcntl_mock.h @@ -0,0 +1,34 @@ +/* + * 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 MOCK_FCNTL_H_ +#define MOCK_FCNTL_H_ + +#include "mock.h" + +#ifdef __cplusplus +extern "C" { +#endif + +DECLARE_FAKE_VALUE_FUNC(int, open, const char *, int); +DECLARE_FAKE_VALUE_FUNC(ssize_t, read, int, void *, size_t); +DECLARE_FAKE_VALUE_FUNC(int, chown, const char *, uid_t, gid_t); +DECLARE_FAKE_VALUE_FUNC(int, chmod, const char *, mode_t); + +#ifdef __cplusplus +} +#endif +#endif /* MOCK_FCNTL_H_ */ \ No newline at end of file diff --git a/unittest/mock/mock.cc b/unittest/mock/mock.cc index 4b3e1da..c100a99 100644 --- a/unittest/mock/mock.cc +++ b/unittest/mock/mock.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * 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. @@ -17,6 +17,57 @@ #include #include "mock.h" +#include "system_info_mock.h" +#include "aul_mock.h" +#include "cynara_mock.h" +#include "fcntl_mock.h" +#include "tzplatform_config_mock.h" +#include "pkgmgr_info_mock.h" DEFINE_FFF_GLOBALS; +/* system */ +DEFINE_FAKE_VALUE_FUNC(int, system_info_get_platform_bool, + const char*, bool*); +DEFINE_FAKE_VALUE_FUNC(uid_t, getuid); + +/* aul */ +DEFINE_FAKE_VALUE_FUNC(int, aul_widget_service_set_disable, + const char*, bool); +DEFINE_FAKE_VALUE_FUNC(int, aul_app_com_create, const char *, aul_app_com_permission_h, + app_com_cb, void *, aul_app_com_connection_h *); +DEFINE_FAKE_VALUE_FUNC(int, aul_app_com_leave, aul_app_com_connection_h); +DEFINE_FAKE_VALUE_FUNC(int, aul_widget_instance_update, const char *, + const char *, bundle *); +DEFINE_FAKE_VALUE_FUNC(int, aul_widget_instance_foreach, const char *, + aul_widget_instance_foreach_cb, void *); +DEFINE_FAKE_VALUE_FUNC(int, aul_widget_instance_get_content, const char *, + const char *, char **); +DEFINE_FAKE_VALUE_FUNC(int, aul_widget_instance_count, const char *); +DEFINE_FAKE_VALUE_FUNC(int, aul_launch_app_async, const char *, bundle *); +DEFINE_FAKE_VALUE_FUNC(int, aul_debug_info_init); +DEFINE_FAKE_VALUE_FUNC(int, aul_debug_info_set, bundle *, bundle *); + +/* cynara */ +DEFINE_FAKE_VALUE_FUNC(int, cynara_initialize, cynara**, + const cynara_configuration*); +DEFINE_FAKE_VALUE_FUNC(int, cynara_finish, cynara*); +DEFINE_FAKE_VALUE_FUNC(int, cynara_check, cynara*, + const char*, const char*, const char*, const char*); + +/* fcntl */ +DEFINE_FAKE_VALUE_FUNC(int, open, const char *, int); +DEFINE_FAKE_VALUE_FUNC(ssize_t, read, int, void *, size_t); +DEFINE_FAKE_VALUE_FUNC(int, chown, const char *, uid_t, gid_t); +DEFINE_FAKE_VALUE_FUNC(int, chmod, const char *, mode_t); + +/* tzplatform_config */ +DEFINE_FAKE_VALUE_FUNC(const char *, tzplatform_mkpath, + enum tzplatform_variable, const char *); + +/* pkgmgr_info */ +DEFINE_FAKE_VALUE_FUNC(int, pkgmgrinfo_pkginfo_get_usr_pkginfo, + const char *, uid_t, pkgmgrinfo_pkginfo_h *); +DEFINE_FAKE_VALUE_FUNC(int, pkgmgrinfo_pkginfo_get_mainappid, + pkgmgrinfo_pkginfo_h, char **); + diff --git a/unittest/mock/mock.h b/unittest/mock/mock.h index 23adbd0..2ba0991 100644 --- a/unittest/mock/mock.h +++ b/unittest/mock/mock.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * 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. diff --git a/unittest/mock/pkgmgr_info_mock.h b/unittest/mock/pkgmgr_info_mock.h new file mode 100644 index 0000000..5057e2a --- /dev/null +++ b/unittest/mock/pkgmgr_info_mock.h @@ -0,0 +1,43 @@ +/* + * 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 MOCK_PKGMGR_INFO_H_ +#define MOCK_PKGMGR_INFO_H_ + +#include "mock.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void *pkgmgrinfo_pkginfo_h; + +enum { + PMINFO_R_ENOENT = -3, /**< No result */ + PMINFO_R_EINVAL = -2, /**< Invalid argument */ + PMINFO_R_ERROR = -1, /**< General error */ + PMINFO_R_OK = 0 /**< General success */ +}; + +DECLARE_FAKE_VALUE_FUNC(int, pkgmgrinfo_pkginfo_get_usr_pkginfo, + const char *, uid_t, pkgmgrinfo_pkginfo_h *); +DECLARE_FAKE_VALUE_FUNC(int, pkgmgrinfo_pkginfo_get_mainappid, + pkgmgrinfo_pkginfo_h, char **); + +#ifdef __cplusplus +} +#endif +#endif /* MOCK_PKGMGR_INFO_H_ */ \ No newline at end of file diff --git a/unittest/mock/system_info_mock.h b/unittest/mock/system_info_mock.h new file mode 100644 index 0000000..de826a1 --- /dev/null +++ b/unittest/mock/system_info_mock.h @@ -0,0 +1,33 @@ +/* + * 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 MOCK_SYSTEM_INFO_H_ +#define MOCK_SYSTEM_INFO_H_ + +#include "mock.h" + +#ifdef __cplusplus +extern "C" { +#endif + +DECLARE_FAKE_VALUE_FUNC(int, system_info_get_platform_bool, + const char *, bool *); +DECLARE_FAKE_VALUE_FUNC(uid_t, getuid); + +#ifdef __cplusplus +} +#endif +#endif /* MOCK_SYSTEM_INFO_H_ */ \ No newline at end of file diff --git a/unittest/mock/tzplatform_config_mock.h b/unittest/mock/tzplatform_config_mock.h new file mode 100644 index 0000000..423dbf0 --- /dev/null +++ b/unittest/mock/tzplatform_config_mock.h @@ -0,0 +1,37 @@ +/* + * 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 MOCK_TZPLATFORM_CONFIG_H_ +#define MOCK_TZPLATFORM_CONFIG_H_ + +#include "mock.h" + +#ifdef __cplusplus +extern "C" { +#endif + +enum tzplatform_variable { + USER = 0, + SYSTEM = 1, +}; + +DECLARE_FAKE_VALUE_FUNC(const char *, tzplatform_mkpath, + enum tzplatform_variable, const char *); + +#ifdef __cplusplus +} +#endif +#endif /* MOCK_TZPLATFORM_CONFIG_H_ */ \ No newline at end of file diff --git a/unittest/src/test_main.cc b/unittest/src/test_main.cc index 8065f0f..6030805 100644 --- a/unittest/src/test_main.cc +++ b/unittest/src/test_main.cc @@ -16,6 +16,7 @@ #include #include +#include "unittest/mock/db_mock.h" int main(int argc, char** argv){ int ret = -1; diff --git a/unittest/src/test_widget_service.cc b/unittest/src/test_widget_service.cc index 54f29b6..f8e28cc 100644 --- a/unittest/src/test_widget_service.cc +++ b/unittest/src/test_widget_service.cc @@ -17,19 +17,429 @@ #include #include #include +#include #include "include/widget_service.h" +#include "include/widget_errno.h" +#include "include/widget_service_internal.h" +#include "unittest/mock/system_info_mock.h" +#include "unittest/mock/aul_mock.h" +#include "unittest/mock/cynara_mock.h" +#include "unittest/mock/fcntl_mock.h" +#include "unittest/mock/tzplatform_config_mock.h" +#include "unittest/mock/db_mock.h" +#include "unittest/mock/pkgmgr_info_mock.h" namespace { -class WidgetServiceTest : public ::testing::Test { - protected: - void SetUp() override { +int __fake_system_info_get_platform_bool(const char* key, bool* value) { + *value = true; + return 0; +} - } - void TearDown() override { +uid_t __fake_getuid(void) { + return (uid_t)0; +} - } +int __fake_aul_widget_service_set_disable(const char* widget_id, bool disabled) { + return 0; +} + +int __fake_cynara_initialize(cynara** cyn, const cynara_configuration* conf) { + return CYNARA_API_SUCCESS; +} + +int __fake_cynara_check(cynara* cyn, const char* client, const char* client_session, + const char* user, const char* privilege) { + return CYNARA_API_ACCESS_ALLOWED; +} + +int __fake_cynara_finish(cynara* cyn) { + return 0; +} + +int __fake_open(const char* path, int flag) { + return 0; +} + +ssize_t __fake_read(int fd, void* buf, size_t size) { + return 0; +} + +int __fake_chown(const char *pathname, uid_t owner, gid_t group) { + return 0; +} +int __fake_chmod(const char *pathname, mode_t mode) { + return 0; +} + +int __fake_aul_app_com_create(const char *endpoint, aul_app_com_permission_h permission, + app_com_cb callback, void *user_data, aul_app_com_connection_h *connection) { + aul_app_com_connection_h *conn; + conn = (aul_app_com_connection_h *)malloc(sizeof(connection)); + *connection = conn; + free(conn); + return 0; +} + +int __fake_aul_app_com_leave(aul_app_com_connection_h connection) { + return 0; +} + +int __fake_aul_widget_instance_update(const char *widget_id, const char *instance_id, bundle *b) { + return 0; +} + +int __fake_aul_widget_instance_get_content(const char *widget_id, + const char *instance_id, char **content) { + bundle *b; + bundle_raw *raw; + int len; + + b = bundle_create(); + bundle_add_str(b, "testkey", "testvalue"); + bundle_encode(b, &raw, &len); + + *content = strdup((const char *)raw); + + bundle_free(b); + return 0; +} + +int __fake_aul_widget_instance_count(const char *widget_id) { + return 0; +} + +struct instance_cb { + const char *widget_id; + widget_instance_list_cb cb; + void *data; + int cnt; +}; + +struct widget_instance_info_s { + int period; + bool exists; + const char *instance_id; }; +int __fake_aul_widget_instance_foreach(const char *widget_id, aul_widget_instance_foreach_cb cb, + void *data) { + struct instance_cb *cb_data = (struct instance_cb *)data; + cb_data->cnt = 5; + + if (cb_data->data != NULL) { + struct widget_instance_info_s *instance_info = (struct widget_instance_info_s *)cb_data->data; + instance_info->exists = true; + } + + return 0; +} + +const char *__fake_tzplatform_mkpath(enum tzplatform_variable id, const char *path) { + return get_db_path(); +} + +int __fake_pkgmgrinfo_pkginfo_get_usr_pkginfo(const char *pkgid, + uid_t uid, pkgmgrinfo_pkginfo_h *handle) { + return PMINFO_R_OK; +} + +int __fake_pkgmgrinfo_pkginfo_get_mainappid(pkgmgrinfo_pkginfo_h handle, char **mainappid) { + *mainappid = (char *)"org.tizen.mainappid"; + return PMINFO_R_OK; +} + +class WidgetServiceTest : public ::testing::Test { + public: + virtual void SetUp() { + system_info_get_platform_bool_fake.custom_fake = __fake_system_info_get_platform_bool; + aul_widget_service_set_disable_fake.custom_fake = __fake_aul_widget_service_set_disable; + cynara_initialize_fake.custom_fake = __fake_cynara_initialize; + cynara_check_fake.custom_fake = __fake_cynara_check; + cynara_finish_fake.custom_fake = __fake_cynara_finish; + open_fake.custom_fake = __fake_open; + read_fake.custom_fake = __fake_read; + chmod_fake.custom_fake = __fake_chmod; + chown_fake.custom_fake = __fake_chown; + aul_app_com_create_fake.custom_fake = __fake_aul_app_com_create; + aul_app_com_leave_fake.custom_fake = __fake_aul_app_com_leave; + aul_widget_instance_update_fake.custom_fake = __fake_aul_widget_instance_update; + aul_widget_instance_foreach_fake.custom_fake = __fake_aul_widget_instance_foreach; + aul_widget_instance_get_content_fake.custom_fake = __fake_aul_widget_instance_get_content; + aul_widget_instance_count_fake.custom_fake = __fake_aul_widget_instance_count; + tzplatform_mkpath_fake.custom_fake = __fake_tzplatform_mkpath; + getuid_fake.custom_fake = __fake_getuid; + pkgmgrinfo_pkginfo_get_usr_pkginfo_fake.custom_fake = __fake_pkgmgrinfo_pkginfo_get_usr_pkginfo; + pkgmgrinfo_pkginfo_get_mainappid_fake.custom_fake = __fake_pkgmgrinfo_pkginfo_get_mainappid; + } + virtual void TearDown() { + } +}; + +/* internal api */ +TEST_F(WidgetServiceTest, CheckDBIntegrity) { + int ret; + + // create db + ret = widget_service_check_db_integrity(false); + ASSERT_EQ(ret, WIDGET_ERROR_NONE); + + // insert default data + insert_default_data(); +} + +TEST_F(WidgetServiceTest, SetDisabled) { + int ret; + + ret = widget_service_set_widget_disabled("org.tizen.test_widget", true); + ASSERT_EQ(ret, WIDGET_ERROR_NONE); +} + +TEST_F(WidgetServiceTest, GetDisabled) { + int ret = WIDGET_ERROR_NONE; + bool is_disabled; + + ret = widget_service_get_widget_disabled("org.tizen.test_widget", + &is_disabled); + ASSERT_EQ(ret, WIDGET_ERROR_NONE); +} + +void _widget_disable_event_cb(const char *widget_id, bool is_disabled, void *user_data) { +} + +TEST_F(WidgetServiceTest, SetDisabledEventCallback) { + int ret; + + ret = widget_service_set_disable_event_cb(_widget_disable_event_cb, NULL); + ASSERT_EQ(ret, WIDGET_ERROR_NONE); +} + +TEST_F(WidgetServiceTest, UnsetDisabledEventCallback) { + int ret; + + ret = widget_service_set_disable_event_cb(_widget_disable_event_cb, NULL); + ret = widget_service_unset_disable_event_cb(); + ASSERT_EQ(ret, WIDGET_ERROR_NONE); +} + +TEST_F(WidgetServiceTest, GetSize) { + int ret; + int width, height; + + ret = widget_service_get_size(WIDGET_SIZE_TYPE_4x4, &width, &height); + ASSERT_EQ(ret, WIDGET_ERROR_NONE); +} + +TEST_F(WidgetServiceTest, GetSizeType) { + int ret; + widget_size_type_e type; + + ret = widget_service_get_size_type(175, 175, &type); + ASSERT_EQ(ret, WIDGET_ERROR_NONE); +} + +TEST_F(WidgetServiceTest, GetNeedOfMouseEvent) { + int ret; + bool need_of_event; + + ret = widget_service_get_need_of_mouse_event("org.tizen.test_widget", WIDGET_SIZE_TYPE_4x2, + &need_of_event); + ASSERT_EQ(ret, WIDGET_ERROR_NONE); +} + +TEST_F(WidgetServiceTest, GetNeedOfTouchEffect) { + int ret; + bool need_of_event; + + ret = widget_service_get_need_of_touch_effect("org.tizen.test_widget", WIDGET_SIZE_TYPE_4x2, + &need_of_event); + ASSERT_EQ(ret, WIDGET_ERROR_NONE); +} + +TEST_F(WidgetServiceTest, GetNeedOfFrame) { + int ret; + bool need_of_frame; + + ret = widget_service_get_need_of_frame("org.tizen.test_widget", WIDGET_SIZE_TYPE_4x2, + &need_of_frame); + ASSERT_EQ(ret, WIDGET_ERROR_NONE); +} + +TEST_F(WidgetServiceTest, TriggerUpdate) { + int ret; + + ret = widget_service_trigger_update("org.tizen.test_widget", + "org.tizen.test_widget", NULL, 1); + ASSERT_EQ(ret, WIDGET_ERROR_NONE); +} + +TEST_F(WidgetServiceTest, ChangePeriod) { + int ret; + + ret = widget_service_change_period("org.tizen.test_widget", + "org.tizen.test_widget", 1.0); + ASSERT_EQ(ret, WIDGET_ERROR_NONE); +} + +int _widget_list_cb(const char *pkgid, const char *widget_id, int is_prime, void *user_data) { + return 0; +} + +TEST_F(WidgetServiceTest, GetWidgetList) { + int ret; + + ret = widget_service_get_widget_list(_widget_list_cb, NULL); + ASSERT_EQ(ret, 1); +} + +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"); +} + +int _widget_list_by_pkgid_cb(const char *widget_id, int is_prime, void *user_data) { + return 0; +} + +TEST_F(WidgetServiceTest, GetWidgetListByPkgId) { + int ret; + + ret = widget_service_get_widget_list_by_pkgid("org.tizen.test_widget", _widget_list_by_pkgid_cb, NULL); + ASSERT_EQ(ret, WIDGET_ERROR_NONE); +} + +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"); +} + +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"); +} + +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"); +} + +TEST_F(WidgetServiceTest, GetName) { + char *name = NULL; + + name = widget_service_get_name("org.tizen.test_widget", "en-us"); + ASSERT_STREQ(name, "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"); +} + +TEST_F(WidgetServiceTest, GetIcon) { + char *path = NULL; + + path = widget_service_get_icon("org.tizen.test_pkgid", "en-us"); + ASSERT_STREQ(path, "/unittest/icon.png"); +} + +TEST_F(WidgetServiceTest, GetNodisplay) { + int ret = WIDGET_ERROR_NONE; + + ret = widget_service_get_nodisplay("org.tizen.test_widget"); + ASSERT_EQ(ret, 2); +} + +TEST_F(WidgetServiceTest, GetSupportedSizes) { + int ret; + int cnt = 10; + int *w; + int *h; + + ret = widget_service_get_supported_sizes("org.tizen.test_widget", &cnt, &w, &h); + ASSERT_EQ(ret, WIDGET_ERROR_NONE); +} + +TEST_F(WidgetServiceTest, GetSupportedSizeTypes) { + int ret; + int cnt = 10; + int *types; + + ret = widget_service_get_supported_size_types("org.tizen.test_widget", &cnt, &types); + ASSERT_EQ(ret, WIDGET_ERROR_NONE); +} + +int _widget_instance_list_cb(const char *widget_id, const char *instance_id, void *user_data) { + return 0; +} + +TEST_F(WidgetServiceTest, GetInstanceList) { + int ret; + struct instance_cb cb_data; + + cb_data.widget_id = "widget_id"; + cb_data.cb = NULL; + cb_data.data = NULL; + cb_data.cnt = 0; + + ret = widget_service_get_widget_instance_list("org.tizen.test_widget", + _widget_instance_list_cb, &cb_data); + ASSERT_TRUE(ret > 0); +} + +int _widget_lifecycle_event_cb(const char *widget_id, widget_lifecycle_event_e lifecycle_event, + const char *widget_instance_id, void *user_data) { + return 0; +} + +TEST_F(WidgetServiceTest, SetLifecycleEventCb) { + int ret; + + ret = widget_service_set_lifecycle_event_cb("org.tizen.test_widget", + _widget_lifecycle_event_cb, NULL); + ASSERT_EQ(ret, WIDGET_ERROR_NONE); +} + + +TEST_F(WidgetServiceTest, UnsetLifecycleEventCb) { + int ret; + + ret = widget_service_unset_lifecycle_event_cb("org.tizen.test_widget", NULL); + ASSERT_EQ(ret, WIDGET_ERROR_NONE); +} + +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); + ASSERT_EQ(ret, WIDGET_ERROR_NONE); +} + +/* internal api */ +TEST_F(WidgetServiceTest, GetWidgetMaxCount) { + int ret; + + ret = widget_service_get_widget_max_count("org.tizen.test_widget"); + ASSERT_EQ(ret, 3); +} + +/* internal api */ +TEST_F(WidgetServiceTest, GetInstanceCount) { + int ret; + + ret = widget_service_get_instance_count("org.tizen.test_widget", NULL, NULL); + ASSERT_EQ(ret, WIDGET_ERROR_NONE); +} + } diff --git a/unittest/src/test_widget_service_instance.cc b/unittest/src/test_widget_service_instance.cc new file mode 100644 index 0000000..2350175 --- /dev/null +++ b/unittest/src/test_widget_service_instance.cc @@ -0,0 +1,308 @@ +/* + * 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 +#include +#include + +#include "include/widget_errno.h" +#include "include/widget_instance.h" +#include "include/widget_service_internal.h" +#include "unittest/mock/tzplatform_config_mock.h" +#include "unittest/mock/db_mock.h" +#include "unittest/mock/aul_mock.h" + +namespace { + +const char *__fake_tzplatform_mkpath(enum tzplatform_variable id, const char *path) { + return get_db_path(); +} + +int __fake_aul_launch_app_async(const char *appid, bundle *kb) { + return 0; +} + +int __fake_aul_app_com_create(const char *endpoint, aul_app_com_permission_h permission, + app_com_cb callback, void *user_data, aul_app_com_connection_h *connection) { + aul_app_com_connection_h *conn; + + conn = (aul_app_com_connection_h *)malloc(sizeof(connection)); + *connection = conn; + free(conn); + return 0; +} + +int __fake_aul_app_com_leave(aul_app_com_connection_h connection) { + return 0; +} + +int __fake_aul_widget_instance_update(const char *widget_id, const char *instance_id, bundle *b) { + return 0; +} + +int __fake_aul_debug_info_init() { + return 0; +} + +int __fake_aul_debug_info_set(bundle *src, bundle *dst) { + return 0; +} + +class WidgetInstanceTest : public ::testing::Test { + public: + virtual void SetUp() { + tzplatform_mkpath_fake.custom_fake = __fake_tzplatform_mkpath; + aul_launch_app_async_fake.custom_fake= __fake_aul_launch_app_async; + aul_app_com_create_fake.custom_fake = __fake_aul_app_com_create; + aul_app_com_leave_fake.custom_fake = __fake_aul_app_com_leave; + aul_widget_instance_update_fake.custom_fake = __fake_aul_widget_instance_update; + aul_debug_info_init_fake.custom_fake = __fake_aul_debug_info_init; + aul_debug_info_set_fake.custom_fake = __fake_aul_debug_info_set; + } + virtual void TearDown() { + } +}; + +TEST_F(WidgetInstanceTest, InstanceInit) { + int ret; + + ret = widget_instance_init("org.tizen.test_viewer"); + ASSERT_EQ(ret, 0); +} + +char *instance_id = NULL; + +TEST_F(WidgetInstanceTest, InstanceCreate) { + int ret = 0; + + ret = widget_instance_create("org.tizen.test_widget", &instance_id); + ASSERT_EQ(ret, 0); +} + +TEST_F(WidgetInstanceTest, InstanceLaunch) { + int ret = 0; + + ret = widget_instance_launch(instance_id, (char *)"TestContent", 4, 2); + ASSERT_EQ(ret, 0); +} + +TEST_F(WidgetInstanceTest, InstanceResume) { + int ret = 0; + + ret = widget_instance_resume(instance_id); + ASSERT_EQ(ret, 0); +} + +TEST_F(WidgetInstanceTest, InstancePause) { + int ret = 0; + + ret = widget_instance_pause(instance_id); + ASSERT_EQ(ret, 0); +} + +TEST_F(WidgetInstanceTest, InstanceResize) { + int ret = 0; + + ret = widget_instance_resize(instance_id, 4, 2); + ASSERT_EQ(ret, 0); +} + +widget_instance_h ins; + +int _widget_instance_foreach_cb(widget_instance_h instance, void *data) { + return 0; +} + +TEST_F(WidgetInstanceTest, InstanceForeach) { + int ret = 0; + + ret = widget_instance_foreach("org.tizen.test_widget", _widget_instance_foreach_cb, NULL); + ASSERT_EQ(ret, 0); +} + +TEST_F(WidgetInstanceTest, InstanceGetInstance) { + widget_instance_h instance = nullptr; + + instance = widget_instance_get_instance("org.tizen.test_widget", instance_id); + ASSERT_NE(instance, nullptr); + + ins = instance; +} + +TEST_F(WidgetInstanceTest, InstanceGetId) { + int ret = 0; + char *id = NULL; + + ret = widget_instance_get_id(ins, &id); + ASSERT_EQ(ret, 0); +} + +TEST_F(WidgetInstanceTest, InstanceGetContent) { + int ret = 0; + char *content = NULL; + + ret = widget_instance_get_content(ins, &content); + ASSERT_EQ(ret, 0); +} + +TEST_F(WidgetInstanceTest, InstanceGetWidth) { + int ret = 0; + int w; + + ret = widget_instance_get_width(ins, &w); + ASSERT_EQ(ret, 0); +} + +TEST_F(WidgetInstanceTest, InstanceGetHeight) { + int ret = 0; + int h; + + ret = widget_instance_get_height(ins, &h); + ASSERT_EQ(ret, 0); +} + +TEST_F(WidgetInstanceTest, InstanceSetPeriod) { + int ret = 0; + + ret = widget_instance_set_period(ins, 3.0); + ASSERT_EQ(ret, 0); +} + +TEST_F(WidgetInstanceTest, InstanceGetPeriod) { + int ret = 0; + double period; + + ret = widget_instance_get_period(ins, &period); + ASSERT_EQ(ret, 0); +} + +TEST_F(WidgetInstanceTest, InstanceGetErr) { + int ret = 0; + int err; + + ret = widget_instance_get_error_code(ins, &err); + ASSERT_EQ(ret, 0); +} + +int _widget_instance_list_cb(const char *widget_id, const char *instance_id, void *user_data) { + return 0; +} + +TEST_F(WidgetInstanceTest, InstanceGetList) { + int ret = 0; + + ret = widget_instance_get_instance_list("org.tizen.test_widget", _widget_instance_list_cb, NULL); + ASSERT_EQ(ret, 0); +} + +TEST_F(WidgetInstanceTest, InstanceChangePeriod) { + int ret = 0; + + ret = widget_instance_change_period("org.tizen.test_widget", instance_id, 5.0); + ASSERT_EQ(ret, 0); +} + +TEST_F(WidgetInstanceTest, InstanceTriggerUpdate) { + int ret = 0; + + ret = widget_instance_trigger_update(ins, "ContentInfo", 1); + ASSERT_EQ(ret, 0); +} + +int _widget_instance_event_cb(const char *widget_id, const char *instance_id, int event, void *data) { + return 0; +} + +TEST_F(WidgetInstanceTest, InstanceListenEvent) { + int ret = 0; + + ret = widget_instance_listen_event(_widget_instance_event_cb, NULL); + ASSERT_EQ(ret, 0); +} + +TEST_F(WidgetInstanceTest, InstanceUnlistenEvent) { + int ret = 0; + + ret = widget_instance_unlisten_event(_widget_instance_event_cb); + ASSERT_EQ(ret, 0); +} + +TEST_F(WidgetInstanceTest, InstanceListenStatus) { + int ret = 0; + + ret = widget_instance_listen_status("org.tizen.test_widget", _widget_instance_event_cb, NULL); + ASSERT_EQ(ret, 0); +} + +TEST_F(WidgetInstanceTest, InstanceUnlistenStatus) { + int ret = 0; + + ret = widget_instance_unlisten_status("org.tizen.test_widget"); + ASSERT_EQ(ret, 0); +} + +TEST_F(WidgetInstanceTest, InstanceTriggerUpdateV2) { + int ret = 0; + + ret = widget_instance_trigger_update_v2("org.tizen.test_widget", instance_id, "ContetnInfo", 1); + ASSERT_EQ(ret, 0); +} + + +TEST_F(WidgetInstanceTest, InstanceSetSdkUtil) { + int ret = 0; + bundle *b; + + b = bundle_create(); + bundle_add_str(b, "__AUL_SDK__", "SdkUtil"); + + ret = widget_service_set_sdk_util(b); + ASSERT_EQ(ret, 0); + + bundle_free(b); +} + +TEST_F(WidgetInstanceTest, InstanceRefUnref) { + widget_instance_h instance = nullptr; + + instance = widget_instance_ref(ins); + ASSERT_NE(instance, nullptr); + + widget_instance_unref(instance); +} + +TEST_F(WidgetInstanceTest, InstanceTerminate) { + int ret = 0; + + ret = widget_instance_terminate(instance_id); + ASSERT_EQ(ret, 0); +} + +TEST_F(WidgetInstanceTest, InstanceDestroy) { + int ret = 0; + + ret = widget_instance_destroy(instance_id); + ASSERT_EQ(ret, 0); +} + +TEST_F(WidgetInstanceTest, InstanceFini) { + int ret = 0; + + ret = widget_instance_fini(); + ASSERT_EQ(ret, 0); +} + +} \ No newline at end of file -- 2.7.4