From: Hwankyu Jhun Date: Fri, 16 Feb 2024 08:32:40 +0000 (+0900) Subject: Revert "Use app_core_base_control API" X-Git-Tag: accepted/tizen/8.0/unified/20240219.160536~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bff957b08731386e4d1e5f8383f453f742b37e57;p=platform%2Fcore%2Fapi%2Fapp-control.git Revert "Use app_core_base_control API" This reverts commit e3e3989ee72276aa902d6116c2bba7e632901b56. Change-Id: Icc9144da5647014063ca31620c4e2eb1f011c8f2 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 5fbba78..d192907 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,7 +33,7 @@ ADD_TEST(NAME ${TARGET_APP_CONTROL_UNIT_TEST} INCLUDE(FindPkgConfig) INCLUDE(ApplyPkgConfig) -PKG_CHECK_MODULES(APP_CORE_CPP_DEPS REQUIRED app-core-cpp) +PKG_CHECK_MODULES(APPCORE_COMMON_DEPS REQUIRED appcore-common) PKG_CHECK_MODULES(AUL_DEPS REQUIRED aul) PKG_CHECK_MODULES(BUNDLE_DEPS REQUIRED bundle) PKG_CHECK_MODULES(CAPI_BASE_COMMON_DEPS REQUIRED capi-base-common) diff --git a/packaging/capi-appfw-app-control.spec b/packaging/capi-appfw-app-control.spec index 6e92f82..4f604f8 100644 --- a/packaging/capi-appfw-app-control.spec +++ b/packaging/capi-appfw-app-control.spec @@ -11,7 +11,7 @@ BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(bundle) BuildRequires: pkgconfig(aul) BuildRequires: pkgconfig(capi-base-common) -BuildRequires: pkgconfig(app-core-cpp) +BuildRequires: pkgconfig(appcore-common) BuildRequires: pkgconfig(gmock) %if 0%{?gcov:1} BuildRequires: lcov diff --git a/src/app-control/CMakeLists.txt b/src/app-control/CMakeLists.txt index 2ea5db3..61b25b0 100644 --- a/src/app-control/CMakeLists.txt +++ b/src/app-control/CMakeLists.txt @@ -11,7 +11,7 @@ TARGET_INCLUDE_DIRECTORIES(${TARGET_APP_CONTROL} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../include) APPLY_PKG_CONFIG(${TARGET_APP_CONTROL} PUBLIC - APP_CORE_CPP_DEPS + APPCORE_COMMON_DEPS AUL_DEPS BUNDLE_DEPS CAPI_BASE_COMMON_DEPS diff --git a/src/app-control/app_control_action.cc b/src/app-control/app_control_action.cc index 56e37eb..9529047 100644 --- a/src/app-control/app_control_action.cc +++ b/src/app-control/app_control_action.cc @@ -15,9 +15,6 @@ */ #include "app-control/app_control_action.hh" - -#include - #include "app-control/error.hh" #include "app-control/exception.hh" #include "app-control/log_private.hh" @@ -26,15 +23,15 @@ namespace app_control { AppControlAction::AppControlAction(std::string action, IEvent* listener) : action_(std::move(action)), listener_(listener) { - int ret = app_core_base_control_add(action_.c_str(), + int ret = appcore_base_control_add(action_.c_str(), AppcoreBaseControlCb, this, &handle_); - if (ret != 0) + if (ret != APPCORE_BASE_ERROR_NONE) THROW(AppcoreBaseErrorConvert(ret)); } AppControlAction::~AppControlAction() { if (handle_ != nullptr) - app_core_base_control_remove(handle_); + appcore_base_control_remove(handle_); } const std::string& AppControlAction::GetAction() const { @@ -49,11 +46,11 @@ void AppControlAction::AppcoreBaseControlCb(bundle* b, void* user_data) { int AppControlAction::AppcoreBaseErrorConvert(int ret) { switch (ret) { - case -EINVAL: + case APPCORE_BASE_ERROR_INVALID_PARAMETER: return static_cast(Error::InvalidParameter); - case -ENOKEY: + case APPCORE_BASE_ERROR_KEY_NOT_FOUND: return static_cast(Error::KeyNotFound); - case -EIO: + case APPCORE_BASE_ERROR_IO_ERROR: return static_cast(Error::IOError); default: return static_cast(Error::OutOfMemory); diff --git a/src/app-control/app_control_action.hh b/src/app-control/app_control_action.hh index 99499d6..e9546e0 100644 --- a/src/app-control/app_control_action.hh +++ b/src/app-control/app_control_action.hh @@ -17,7 +17,7 @@ #ifndef APP_CONTROL_APP_CONTROL_ACTION_HH_ #define APP_CONTROL_APP_CONTROL_ACTION_HH_ -#include +#include #include @@ -42,7 +42,7 @@ class AppControlAction { private: std::string action_; IEvent* listener_; - app_core_base_control_h handle_ = nullptr; + appcore_base_control_h handle_ = nullptr; }; } // namespace app_control diff --git a/test/unit_tests/CMakeLists.txt b/test/unit_tests/CMakeLists.txt index 5e4fbbd..73487cb 100644 --- a/test/unit_tests/CMakeLists.txt +++ b/test/unit_tests/CMakeLists.txt @@ -14,7 +14,7 @@ TARGET_INCLUDE_DIRECTORIES(${TARGET_APP_CONTROL_UNIT_TEST} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../src/uri) APPLY_PKG_CONFIG(${TARGET_APP_CONTROL_UNIT_TEST} PUBLIC - APP_CORE_CPP_DEPS + APPCORE_COMMON_DEPS AUL_DEPS GLIB_DEPS GMOCK_DEPS diff --git a/test/unit_tests/app_control_unittest.cc b/test/unit_tests/app_control_unittest.cc index 4050d20..bb01752 100644 --- a/test/unit_tests/app_control_unittest.cc +++ b/test/unit_tests/app_control_unittest.cc @@ -60,12 +60,12 @@ class CbInfo { class ActionCbInfo { public: - ActionCbInfo(std::string id, app_core_base_control_cb cb, void* data) + ActionCbInfo(std::string id, appcore_base_control_cb cb, void* data) : id_(std::move(id)), cb_(cb), data_(data) { } std::string id_; - app_core_base_control_cb cb_; + appcore_base_control_cb cb_; void* data_; }; @@ -174,9 +174,9 @@ int fake_aul_svc_send_launch_request_sync_for_uid_PID(bundle* b, return getpid(); } -int fake_app_core_base_control_add_ERROR_NONE(const char* id, - app_core_base_control_cb callback, void* user_data, - app_core_base_control_h* h) { +int fake_appcore_base_control_add_APPCORE_BASE_ERROR_NONE(const char* id, + appcore_base_control_cb callback, void* user_data, + appcore_base_control_h* h) { auto* info = new ActionCbInfo(id, callback, user_data); g_idle_add([](gpointer data) -> gboolean { auto* info = static_cast(data); @@ -185,33 +185,33 @@ int fake_app_core_base_control_add_ERROR_NONE(const char* id, bundle_free(b); return G_SOURCE_REMOVE; }, info); - *h = static_cast(info); - return 0; + *h = static_cast(info); + return APPCORE_BASE_ERROR_NONE; } -int fake_app_core_base_control_add_ERROR_INVALID_PARAMETER( - const char* id, app_core_base_control_cb callback, void* user_data, - app_core_base_control_h* h) { - return -EINVAL; +int fake_appcore_base_control_add_APPCORE_BASE_ERROR_INVALID_PARAMETER( + const char* id, appcore_base_control_cb callback, void* user_data, + appcore_base_control_h* h) { + return APPCORE_BASE_ERROR_INVALID_PARAMETER; } -int fake_app_core_base_control_add_ERROR_KEY_NOT_FOUND( - const char* id, app_core_base_control_cb callback, void* user_data, - app_core_base_control_h* h) { - return -ENOKEY; +int fake_appcore_base_control_add_APPCORE_BASE_ERROR_KEY_NOT_FOUND( + const char* id, appcore_base_control_cb callback, void* user_data, + appcore_base_control_h* h) { + return APPCORE_BASE_ERROR_KEY_NOT_FOUND; } -int fake_app_core_base_control_add_ERROR_IO_ERROR( - const char* id, app_core_base_control_cb callback, void* user_data, - app_core_base_control_h* h) { - return -EIO; +int fake_appcore_base_control_add_APPCORE_BASE_ERROR_IO_ERROR( + const char* id, appcore_base_control_cb callback, void* user_data, + appcore_base_control_h* h) { + return APPCORE_BASE_ERROR_IO_ERROR; } -int fake_app_core_base_control_remove_ERROR_NONE( - app_core_base_control_h h) { +int fake_appcore_base_control_remove_APPCORE_BASE_ERROR_NONE( + appcore_base_control_h h) { auto* info = static_cast(h); delete info; - return 0; + return APPCORE_BASE_ERROR_NONE; } int fake_aul_svc_send_resume_request_for_uid_AUL_SVC_RET_OK(bundle* b, @@ -230,7 +230,7 @@ int fake_aul_prepare_app_defined_loader_LOADER_ID(const char* loader_name) { return 22; } -} // namespace +} // namespace class Mocks : public ::testing::NiceMock, public ::testing::NiceMock {}; @@ -355,7 +355,7 @@ TEST_F(AppControlTest, app_control_create_from_uri_handle_P) { } TEST_F(AppControlTest, app_control_create_from_uri_handle_N) { - int ret = app_control_create_from_uri_handle(nullptr, nullptr); + int ret= app_control_create_from_uri_handle(nullptr, nullptr); EXPECT_EQ(ret, APP_CONTROL_ERROR_INVALID_PARAMETER); } @@ -411,7 +411,7 @@ TEST_F(AppControlTest, app_control_create_request_N) { } TEST_F(AppControlTest, app_control_create_P) { - app_control_h app_control = nullptr; + app_control_h app_control = nullptr;; int ret = app_control_create(&app_control); std::unique_ptr::type, decltype(app_control_destroy)*> ptr(app_control, app_control_destroy); @@ -526,7 +526,7 @@ TEST_F(AppControlTest, app_control_to_bundle_P) { } TEST_F(AppControlTest, app_control_to_bundle_N) { - int ret = app_control_to_bundle(nullptr, nullptr); + int ret= app_control_to_bundle(nullptr, nullptr); EXPECT_EQ(ret, APP_CONTROL_ERROR_INVALID_PARAMETER); } @@ -1351,10 +1351,10 @@ TEST_F(AppControlTest, app_control_send_launch_request_sync_N) { } TEST_F(AppControlTest, app_control_add_action_handler_P) { - EXPECT_CALL(GetMock(), app_core_base_control_add(_, _, _, _)) - .WillOnce(Invoke(fake_app_core_base_control_add_ERROR_NONE)); - EXPECT_CALL(GetMock(), app_core_base_control_remove(_)) - .WillOnce(Invoke(fake_app_core_base_control_remove_ERROR_NONE)); + EXPECT_CALL(GetMock(), appcore_base_control_add(_, _, _, _)). + WillOnce(Invoke(fake_appcore_base_control_add_APPCORE_BASE_ERROR_NONE)); + EXPECT_CALL(GetMock(), appcore_base_control_remove(_)). + WillOnce(Invoke(fake_appcore_base_control_remove_APPCORE_BASE_ERROR_NONE)); result_ = -1; app_control_action_h handle = nullptr; @@ -1376,37 +1376,37 @@ TEST_F(AppControlTest, app_control_add_action_handler_N) { int ret = app_control_add_action_handler(nullptr, nullptr, nullptr, nullptr); EXPECT_EQ(ret, APP_CONTROL_ERROR_INVALID_PARAMETER); - EXPECT_CALL(GetMock(), app_core_base_control_add(_, _, _, _)) - .WillOnce(Invoke(fake_app_core_base_control_add_ERROR_INVALID_PARAMETER)); + EXPECT_CALL(GetMock(), appcore_base_control_add(_, _, _, _)). + WillOnce(Invoke( + fake_appcore_base_control_add_APPCORE_BASE_ERROR_INVALID_PARAMETER)); app_control_action_h handle = nullptr; - ret = app_control_add_action_handler( - "action", - [](const char* action, app_control_h app_control, void* user_data) {}, - this, &handle); + ret = app_control_add_action_handler("action", + [](const char* action, app_control_h app_control, void* user_data) { + }, this, &handle); EXPECT_EQ(ret, APP_CONTROL_ERROR_INVALID_PARAMETER); - EXPECT_CALL(GetMock(), app_core_base_control_add(_, _, _, _)) - .WillOnce(Invoke(fake_app_core_base_control_add_ERROR_KEY_NOT_FOUND)); - ret = app_control_add_action_handler( - "action", - [](const char* action, app_control_h app_control, void* user_data) {}, - this, &handle); + EXPECT_CALL(GetMock(), appcore_base_control_add(_, _, _, _)). + WillOnce(Invoke( + fake_appcore_base_control_add_APPCORE_BASE_ERROR_KEY_NOT_FOUND)); + ret = app_control_add_action_handler("action", + [](const char* action, app_control_h app_control, void* user_data) { + }, this, &handle); EXPECT_EQ(ret, APP_CONTROL_ERROR_KEY_NOT_FOUND); - EXPECT_CALL(GetMock(), app_core_base_control_add(_, _, _, _)) - .WillOnce(Invoke(fake_app_core_base_control_add_ERROR_IO_ERROR)); - ret = app_control_add_action_handler( - "action", - [](const char* action, app_control_h app_control, void* user_data) {}, - this, &handle); + EXPECT_CALL(GetMock(), appcore_base_control_add(_, _, _, _)). + WillOnce(Invoke( + fake_appcore_base_control_add_APPCORE_BASE_ERROR_IO_ERROR)); + ret = app_control_add_action_handler("action", + [](const char* action, app_control_h app_control, void* user_data) { + }, this, &handle); EXPECT_EQ(ret, APP_CONTROL_ERROR_IO_ERROR); } TEST_F(AppControlTest, app_control_remove_action_handler_P) { - EXPECT_CALL(GetMock(), app_core_base_control_add(_, _, _, _)) - .WillOnce(Invoke(fake_app_core_base_control_add_ERROR_NONE)); - EXPECT_CALL(GetMock(), app_core_base_control_remove(_)) - .WillOnce(Invoke(fake_app_core_base_control_remove_ERROR_NONE)); + EXPECT_CALL(GetMock(), appcore_base_control_add(_, _, _, _)). + WillOnce(Invoke(fake_appcore_base_control_add_APPCORE_BASE_ERROR_NONE)); + EXPECT_CALL(GetMock(), appcore_base_control_remove(_)). + WillOnce(Invoke(fake_appcore_base_control_remove_APPCORE_BASE_ERROR_NONE)); app_control_action_h handle = nullptr; app_control_add_action_handler("action", diff --git a/test/unit_tests/mock/appcore_base_mock.cc b/test/unit_tests/mock/appcore_base_mock.cc index 8daa3c2..d4cbbc0 100644 --- a/test/unit_tests/mock/appcore_base_mock.cc +++ b/test/unit_tests/mock/appcore_base_mock.cc @@ -18,13 +18,13 @@ #include "unit_tests/mock/mock_hook.hh" #include "unit_tests/mock/test_fixture.hh" -extern "C" int app_core_base_control_add(const char* id, - app_core_base_control_cb callback, void* user_data, - app_core_base_control_h *h) { - return MOCK_HOOK_P4(AppCoreBaseMock, app_core_base_control_add, +extern "C" int appcore_base_control_add(const char* id, + appcore_base_control_cb callback, void* user_data, + appcore_base_control_h *h) { + return MOCK_HOOK_P4(AppCoreBaseMock, appcore_base_control_add, id, callback, user_data, h); } -extern "C" int app_core_base_control_remove(app_core_base_control_h h) { - return MOCK_HOOK_P1(AppCoreBaseMock, app_core_base_control_remove, h); +extern "C" int appcore_base_control_remove(appcore_base_control_h h) { + return MOCK_HOOK_P1(AppCoreBaseMock, appcore_base_control_remove, h); } diff --git a/test/unit_tests/mock/appcore_base_mock.hh b/test/unit_tests/mock/appcore_base_mock.hh index 1527dd1..b7ff967 100644 --- a/test/unit_tests/mock/appcore_base_mock.hh +++ b/test/unit_tests/mock/appcore_base_mock.hh @@ -17,7 +17,7 @@ #ifndef UNIT_TESTS_MOCK_APPCORE_BASE_MOCK_HH_ #define UNIT_TESTS_MOCK_APPCORE_BASE_MOCK_HH_ -#include +#include #include #include "unit_tests/mock/module_mock.hh" @@ -26,10 +26,9 @@ class AppCoreBaseMock : public virtual ModuleMock { public: virtual ~AppCoreBaseMock() {} - MOCK_METHOD4(app_core_base_control_add, - int(const char*, app_core_base_control_cb, void*, - app_core_base_control_h*)); - MOCK_METHOD1(app_core_base_control_remove, int(app_core_base_control_h)); + MOCK_METHOD4(appcore_base_control_add, + int (const char*, appcore_base_control_cb, void*, appcore_base_control_h*)); + MOCK_METHOD1(appcore_base_control_remove, int (appcore_base_control_h)); }; #endif // UNIT_TESTS_MOCK_APPCORE_BASE_MOCK_HH_