Revert "Use app_core_base_control API" 46/306146/1
authorHwankyu Jhun <h.jhun@samsung.com>
Fri, 16 Feb 2024 08:32:40 +0000 (17:32 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Fri, 16 Feb 2024 08:32:46 +0000 (17:32 +0900)
This reverts commit e3e3989ee72276aa902d6116c2bba7e632901b56.

Change-Id: Icc9144da5647014063ca31620c4e2eb1f011c8f2

CMakeLists.txt
packaging/capi-appfw-app-control.spec
src/app-control/CMakeLists.txt
src/app-control/app_control_action.cc
src/app-control/app_control_action.hh
test/unit_tests/CMakeLists.txt
test/unit_tests/app_control_unittest.cc
test/unit_tests/mock/appcore_base_mock.cc
test/unit_tests/mock/appcore_base_mock.hh

index 5fbba78b2c222bc621897edecbd449cc65b7bfaa..d192907b29b81f019a99d581dea594ce56a38369 100644 (file)
@@ -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)
index 6e92f82377a185965ab5945dfcb5cfe80be700b1..4f604f8f41f51d4c672dc11c7984aa62773f62d8 100644 (file)
@@ -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
index 2ea5db3ab62a8fb63bcb31a9169ab46a3a01983c..61b25b09590951098e6c864805d09fe7128b3b7d 100644 (file)
@@ -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
index 56e37eba410593833d57c5e8d0179d6d6804972c..9529047d2710c0454e4c666214873779c74e382b 100644 (file)
@@ -15,9 +15,6 @@
  */
 
 #include "app-control/app_control_action.hh"
-
-#include <utility>
-
 #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<int>(Error::InvalidParameter);
-  case -ENOKEY:
+  case APPCORE_BASE_ERROR_KEY_NOT_FOUND:
     return static_cast<int>(Error::KeyNotFound);
-  case -EIO:
+  case APPCORE_BASE_ERROR_IO_ERROR:
     return static_cast<int>(Error::IOError);
   default:
     return static_cast<int>(Error::OutOfMemory);
index 99499d65b410ed9288106c3ea804e72c7af495f5..e9546e0597aa223c29938bee123977c1a1519cdb 100644 (file)
@@ -17,7 +17,7 @@
 #ifndef APP_CONTROL_APP_CONTROL_ACTION_HH_
 #define APP_CONTROL_APP_CONTROL_ACTION_HH_
 
-#include <app_core_base_control.h>
+#include <appcore_base_control.h>
 
 #include <string>
 
@@ -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
index 5e4fbbd0663fa955c9d87d96b417175a5144a58d..73487cbaf838006616124fa0e237f45c92bfdedd 100644 (file)
@@ -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
index 4050d20d760998237c601ca2af0f2d41d704b846..bb01752e3aedc9fea2c74a0cff4bffe7a3dfbcc4 100644 (file)
@@ -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<ActionCbInfo*>(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<app_core_base_control_h>(info);
-  return 0;
+  *h = static_cast<appcore_base_control_h>(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<ActionCbInfo*>(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<AulMock>,
               public ::testing::NiceMock<AppCoreBaseMock> {};
@@ -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<std::remove_pointer<app_control_h>::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<AppCoreBaseMock>(), app_core_base_control_add(_, _, _, _))
-      .WillOnce(Invoke(fake_app_core_base_control_add_ERROR_NONE));
-  EXPECT_CALL(GetMock<AppCoreBaseMock>(), app_core_base_control_remove(_))
-      .WillOnce(Invoke(fake_app_core_base_control_remove_ERROR_NONE));
+  EXPECT_CALL(GetMock<AppCoreBaseMock>(), appcore_base_control_add(_, _, _, _)).
+      WillOnce(Invoke(fake_appcore_base_control_add_APPCORE_BASE_ERROR_NONE));
+  EXPECT_CALL(GetMock<AppCoreBaseMock>(), 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<AppCoreBaseMock>(), app_core_base_control_add(_, _, _, _))
-      .WillOnce(Invoke(fake_app_core_base_control_add_ERROR_INVALID_PARAMETER));
+  EXPECT_CALL(GetMock<AppCoreBaseMock>(), 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<AppCoreBaseMock>(), 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<AppCoreBaseMock>(), 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<AppCoreBaseMock>(), 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<AppCoreBaseMock>(), 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<AppCoreBaseMock>(), app_core_base_control_add(_, _, _, _))
-      .WillOnce(Invoke(fake_app_core_base_control_add_ERROR_NONE));
-  EXPECT_CALL(GetMock<AppCoreBaseMock>(), app_core_base_control_remove(_))
-      .WillOnce(Invoke(fake_app_core_base_control_remove_ERROR_NONE));
+  EXPECT_CALL(GetMock<AppCoreBaseMock>(), appcore_base_control_add(_, _, _, _)).
+      WillOnce(Invoke(fake_appcore_base_control_add_APPCORE_BASE_ERROR_NONE));
+  EXPECT_CALL(GetMock<AppCoreBaseMock>(), 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",
index 8daa3c26705fdbdb65b98c05b3ae7aec45be4829..d4cbbc0f1e9561428f1a7b0b45701a920e32a723 100644 (file)
 #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);
 }
index 1527dd13968d9f0a4383a850a30f49f315b738bc..b7ff9672716cec71272fdc33ef3bb6512c8c9029 100644 (file)
@@ -17,7 +17,7 @@
 #ifndef UNIT_TESTS_MOCK_APPCORE_BASE_MOCK_HH_
 #define UNIT_TESTS_MOCK_APPCORE_BASE_MOCK_HH_
 
-#include <app_core_base_control.h>
+#include <appcore_base_control.h>
 #include <gmock/gmock.h>
 
 #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_