diff options
author | Hwankyu Jhun <h.jhun@samsung.com> | 2024-06-11 08:13:06 +0900 |
---|---|---|
committer | Hwankyu Jhun <h.jhun@samsung.com> | 2024-06-11 08:18:23 +0900 |
commit | 446c458e6df2768c1d75fa338e7f1284342a4f30 (patch) | |
tree | 1b4d0c94548d3bd987157b310b13aee3e997f82e | |
parent | efb7e02edd99b4e1f60e91cc49ea9bfe9a51597f (diff) | |
download | librua-446c458e6df2768c1d75fa338e7f1284342a4f30.tar.gz librua-446c458e6df2768c1d75fa338e7f1284342a4f30.tar.bz2 librua-446c458e6df2768c1d75fa338e7f1284342a4f30.zip |
Fix wrong unit testaccepted/tizen/unified/x/20240611.050137accepted/tizen/unified/toolchain/20240611.043140accepted/tizen/unified/20240611.123808
The label should be set.
Change-Id: Iea2184d716d7a5bb0a8acbbdd3ecc420c6301e89
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
-rw-r--r-- | src/rua_info.c | 2 | ||||
-rw-r--r-- | tests/unittest/rua_manager_unit_test.cc | 17 |
2 files changed, 11 insertions, 8 deletions
diff --git a/src/rua_info.c b/src/rua_info.c index 59fd2bb..f433618 100644 --- a/src/rua_info.c +++ b/src/rua_info.c @@ -858,7 +858,7 @@ static char *__get_label(rua_info_h info) { pkgmgrinfo_appinfo_h app_info; aul_comp_info_h comp_info; - char *label; + char *label = NULL; int ret; if (info->value[RUA_INFO_COMP_INFO]) { diff --git a/tests/unittest/rua_manager_unit_test.cc b/tests/unittest/rua_manager_unit_test.cc index b0428e5..83a1624 100644 --- a/tests/unittest/rua_manager_unit_test.cc +++ b/tests/unittest/rua_manager_unit_test.cc @@ -32,10 +32,11 @@ using ::testing::_; using ::testing::DoAll; using ::testing::SetArgPointee; using ::testing::Return; +using ::testing::Invoke; static bool __rua_info_cb(rua_info_h info, void* user_data) { if (user_data) { - rua_info_h* cloned = (rua_info_h*)user_data; + rua_info_h* cloned = static_cast<rua_info_h*>(user_data); rua_info_clone(info, cloned); } @@ -43,7 +44,7 @@ static bool __rua_info_cb(rua_info_h info, void* user_data) { } static char** __create_table(void) { - char** table = (char** )calloc(10, sizeof(char*)); + char** table = reinterpret_cast<char**>(calloc(10, sizeof(char*))); table[0] = strdup("pkgname"); if (table[0] == nullptr) goto out; @@ -397,12 +398,14 @@ TEST_F(RuaManagerTest, rua_info_is_managed_by_task_manager) { } TEST_F(RuaManagerTest, rua_info_get_label) { - EXPECT_CALL(GetMock<AulMock>(), - aul_comp_info_get_label(_, _)). - WillOnce(Return(0)); + EXPECT_CALL(GetMock<AulMock>(), aul_comp_info_get_label(_, _)) + .WillOnce(Invoke([&](aul_comp_info_h info, const char** label) { + *label = strdup("test"); + return 0; + })); - char* label; + char* label = NULL; int ret = rua_info_get_label(info_, &label); auto p = std::unique_ptr<char, decltype(std::free)*>(label, std::free); EXPECT_EQ(ret, 0); -}
\ No newline at end of file +} |