Revert "Remove capi-system-info library dependency" 39/306139/1
authorHwankyu Jhun <h.jhun@samsung.com>
Fri, 16 Feb 2024 08:25:30 +0000 (17:25 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Fri, 16 Feb 2024 08:25:34 +0000 (17:25 +0900)
This reverts commit 9cfc2342991b6d847d2b5320549b25855b22376f.

Change-Id: I165373b1dd5091abae06c614eae0cd4e63ee06c9

CMakeLists.txt
legacy/CMakeLists.txt
legacy/src/legacy/appcore.c
packaging/app-core.spec
tizen-cpp/app-core-cpp/CMakeLists.txt
tizen-cpp/app-core-cpp/app_core_base.cc
tizen-cpp/app-core-cpp/suspend_event_private.cc [deleted file]
tizen-cpp/app-core-cpp/suspend_event_private.hh [deleted file]
unittests/CMakeLists.txt
unittests/mock/dbus_mock.cc
unittests/mock/dbus_mock.h

index 36b2ac03a7eba15bb4da4ddbfba4a3643cbbfccd..a24831a24df695dca67a6e3ed531d91aaa4c0822 100644 (file)
@@ -33,6 +33,7 @@ INCLUDE(ApplyPkgConfig)
 
 PKG_CHECK_MODULES(AUL_DEPS REQUIRED aul)
 PKG_CHECK_MODULES(BUNDLE_DEPS REQUIRED bundle)
+PKG_CHECK_MODULES(CAPI_SYSTEM_INFO_DEPS REQUIRED capi-system-info)
 PKG_CHECK_MODULES(DLOG_DEPS REQUIRED dlog)
 PKG_CHECK_MODULES(ECORE_DEPS REQUIRED ecore)
 PKG_CHECK_MODULES(ECORE_WL2_DEPS REQUIRED ecore-wl2)
index f6b42b0f6eeb939a20f735e6f1a97ec2dc5cb949..d7dd697e2d563df3ab688e53d33279d9b9adaa6d 100644 (file)
@@ -40,7 +40,7 @@ SET(HEADERS_common
        appcore_base_control.h)
 
 INCLUDE(FindPkgConfig)
-SET(APPCORE_PKG_CHECK_MODULES "gio-2.0 vconf sensor aul dlog ttrace pkgmgr-info")
+SET(APPCORE_PKG_CHECK_MODULES "gio-2.0 vconf sensor aul dlog capi-system-info ttrace pkgmgr-info")
 
 pkg_check_modules(pkg_common REQUIRED ${APPCORE_PKG_CHECK_MODULES})
 
index 81d36b85eca899b7bb99c49565d2181b46733715..af0c251a2f25f4f67873e1d679c9fc6f537167b4 100644 (file)
@@ -28,6 +28,7 @@
 #include <dlfcn.h>
 #include <vconf.h>
 #include <bundle_internal.h>
+#include <system_info.h>
 #include <gio/gio.h>
 
 #include "appcore-internal.h"
index 13e90d609e5cc4f1b284d2ff4e2c55b7d841a851..218254b2902162f6e748a914d5a3a44f298d28e5 100644 (file)
@@ -10,6 +10,7 @@ Source1001:     app-core.manifest
 BuildRequires:  cmake
 BuildRequires:  pkgconfig(aul)
 BuildRequires:  pkgconfig(bundle)
+BuildRequires:  pkgconfig(capi-system-info)
 BuildRequires:  pkgconfig(dlog)
 BuildRequires:  pkgconfig(ecore)
 BuildRequires:  pkgconfig(ecore-wl2)
index 6f427fb097a64ce86f8984e68161769d4dffb8d1..61cd42591c87b6079ae2c48b5961dcf4b79caf52 100644 (file)
@@ -16,6 +16,7 @@ SET_TARGET_PROPERTIES(${TARGET_APP_CORE_CPP} PROPERTIES VERSION ${FULLVER})
 APPLY_PKG_CONFIG(${TARGET_APP_CORE_CPP} PUBLIC
   AUL_DEPS
   BUNDLE_DEPS
+  CAPI_SYSTEM_INFO_DEPS
   DLOG_DEPS
   GIO_2_DEPS
   SENSOR_DEPS
index 2e14d8ae5db246156bf45e986267cb1b663cbc0b..eaf7f51dfea5f1bad932ea315ec56ea145b67e28 100644 (file)
@@ -35,6 +35,7 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <sys/types.h>
+#include <system_info.h>
 #include <time.h>
 #include <ttrace.h>
 #include <unistd.h>
@@ -53,7 +54,6 @@
 #include "app-core-cpp/app_core_plugin_private.hh"
 #include "app-core-cpp/exit_handler_private.hh"
 #include "app-core-cpp/sigterm_handler_private.hh"
-#include "app-core-cpp/suspend_event_private.hh"
 #include "common/glib_private.hh"
 #include "common/log_private.hh"
 #include "common/log_tracer.hh"
@@ -68,8 +68,60 @@ namespace {
 internal::ExitHandler exit_handler;
 internal::SigtermHandler sigterm_handler;
 
+enum TizenProfile {
+  Unknown = 0x00,
+  Mobile = 0x01,
+  Wearable = 0x02,
+  Tv = 0x04,
+  Ivi = 0x08,
+  Common = 0x10,
+};
+
+TizenProfile TizenProfileGet() {
+  static TizenProfile profile = TizenProfile::Unknown;
+  if (__builtin_expect(profile != TizenProfile::Unknown, 1))
+    return profile;
+
+  char* profile_name = nullptr;
+  system_info_get_platform_string("http://tizen.org/feature/profile",
+      &profile_name);
+  if (profile_name == nullptr)
+    return profile;
+
+  switch (*profile_name) {
+  case 'm':
+  case 'M':
+    profile = TizenProfile::Mobile;
+    break;
+  case 'w':
+  case 'W':
+    profile = TizenProfile::Wearable;
+    break;
+  case 't':
+  case 'T':
+    profile = TizenProfile::Tv;
+    break;
+  case 'i':
+  case 'I':
+    profile = TizenProfile::Ivi;
+    break;
+  default:
+    profile = TizenProfile::Common;
+    break;
+  }
+  free(profile_name);
+
+  return profile;
+}
+
 constexpr const char PATH_LOCALE[] = "locale";
 constexpr int SQLITE_FLUSH_MAX = 1024 * 1024;
+constexpr const char RESOURCED_FREEZER_PATH[] =
+    "/Org/Tizen/ResourceD/Freezer";
+constexpr const char RESOURCED_FREEZER_INTERFACE[] =
+    "org.tizen.resourced.freezer";
+constexpr const char RESOURCED_FREEZER_SIGNAL[] =
+    "FreezerState";
 
 struct Rotation {
   int conn;
@@ -81,6 +133,8 @@ struct Rotation {
 };
 
 Rotation __rotation;
+GDBusConnection* __bus;
+guint __suspend_dbus_handler_initialized;
 AppCoreBase::DisplayState __display_state = AppCoreBase::DISPLAY_STATE_UNKNOWN;
 
 }  // namespace
@@ -93,9 +147,14 @@ class AppCoreBase::EventBase::Impl {
   int val_ = -1;
 };
 
-class AppCoreBase::Impl : public SuspendEvent::IEventListener {
+class AppCoreBase::Impl {
  public:
-  explicit Impl(AppCoreBase* parent) : parent_(parent) {}
+  explicit Impl(AppCoreBase* parent) : parent_(parent) {
+    if (TizenProfileGet() & TizenProfile::Wearable)
+      feature_ |= FEATURE_CHARGER_STATUS;
+    if (!(TizenProfileGet() & TizenProfile::Tv))
+      feature_ |= FEATURE_BACKGROUND_MANAGEMENT;
+  }
 
  private:
   void UnregisterRotationChangedEvent();
@@ -129,14 +188,17 @@ class AppCoreBase::Impl : public SuspendEvent::IEventListener {
     }
   }
 
-  void InitSuspend();
-  void OnSuspend(pid_t pid, int status) override;
+  static void InitSuspendDbusHandler(gpointer data);
+  static gboolean InitSuspendCb(gpointer data);
   static gboolean InvokeLangChangeCb(gpointer data);
+  static void ReceiveSuspendSignalCb(GDBusConnection*, const gchar*,
+      const gchar*, const gchar*, const gchar*, GVariant*, gpointer);
   static void OnLowBatteryCb(keynode_t* key, void* data);
   static void OnTimeZoneChangedCb(keynode_t* key, void* data);
   static void LockCb(keynode_t* node, void* user_data);
   static void AutoRotationChangedCb(sensor_t sensor, unsigned int event_type,
       sensor_data_t* data, void* user_data);
+  static void ChargerStatusChangedCb(keynode_t* keynode, void* user_data);
   static void LanguageChangeCb(keynode_t* key, void* data);
   static void RegionChangeCb(keynode_t* key, void* data);
   static void LowMemoryCb(keynode_t* key, void* data);
@@ -167,7 +229,6 @@ class AppCoreBase::Impl : public SuspendEvent::IEventListener {
   IMainLoop* loop_delegator_ = nullptr;
   guint signal_handler_source_ = 0;
   std::unique_ptr<AppCorePlugin> plugin_;
-  std::unique_ptr<SuspendEvent> suspend_event_;
 };
 
 AppCoreBase::EventBase::EventBase(Type type)
@@ -267,8 +328,38 @@ AppCoreBase::RotationState AppCoreBase::Impl::GetRm(sensor_data_t data) {
   }
 }
 
-void AppCoreBase::Impl::InitSuspend() {
-  suspend_event_.reset(new SuspendEvent(this));
+void AppCoreBase::Impl::InitSuspendDbusHandler(gpointer data) {
+  if (__suspend_dbus_handler_initialized)
+    return;
+
+  if (__bus == nullptr) {
+    GError* err = nullptr;
+    __bus = g_bus_get_sync(G_BUS_TYPE_SYSTEM, nullptr, &err);
+    if (__bus == nullptr) {
+      _E("Failed to connect to the D-BUS daemon: %s", err ? err->message : "");
+      if (err)
+        g_error_free(err);
+
+      return;
+    }
+  }
+
+  __suspend_dbus_handler_initialized = g_dbus_connection_signal_subscribe(
+    __bus, nullptr, RESOURCED_FREEZER_INTERFACE, RESOURCED_FREEZER_SIGNAL,
+    RESOURCED_FREEZER_PATH, nullptr, G_DBUS_SIGNAL_FLAGS_NONE,
+    ReceiveSuspendSignalCb, data, nullptr);
+
+  if (__suspend_dbus_handler_initialized == 0) {
+    _E("g_dbus_connection_signal_subscribe() is failed.");
+    return;
+  }
+
+  _D("[__SUSPEND__] suspend signal initialized");
+}
+
+gboolean AppCoreBase::Impl::InitSuspendCb(gpointer data) {
+  InitSuspendDbusHandler(data);
+  return G_SOURCE_REMOVE;
 }
 
 gboolean AppCoreBase::Impl::InvokeLangChangeCb(gpointer data) {
@@ -278,8 +369,18 @@ gboolean AppCoreBase::Impl::InvokeLangChangeCb(gpointer data) {
   return G_SOURCE_REMOVE;
 }
 
-void AppCoreBase::Impl::OnSuspend(pid_t pid, int status) {
-  if (pid == getpid() && status == 0) OnFreezerSignal();
+void AppCoreBase::Impl::ReceiveSuspendSignalCb(GDBusConnection*, const gchar*,
+    const gchar*, const gchar*, const gchar* signal_name, GVariant* parameters,
+    gpointer user_data) {
+  if (g_strcmp0(signal_name, RESOURCED_FREEZER_SIGNAL) == 0) {
+    gint pid = -1;
+    gint status = 0;
+    g_variant_get(parameters, "(ii)", &status, &pid);
+    if (pid == getpid() && status == 0) {
+      AppCoreBase* base = reinterpret_cast<AppCoreBase*>(user_data);
+      base->impl_->OnFreezerSignal();
+    }
+  }
 }
 
 void AppCoreBase::Impl::LanguageChangeCb(keynode_t* key, void* user_data) {
@@ -324,6 +425,23 @@ void AppCoreBase::Impl::LowMemoryCb(keynode_t* key, void* user_data) {
     malloc_trim(0);
 }
 
+void AppCoreBase::Impl::ChargerStatusChangedCb(keynode_t* keynode,
+    void* user_data) {
+  AppCoreBase* base = reinterpret_cast<AppCoreBase*>(user_data);
+  if (base->impl_->feature_ & FEATURE_CHARGER_STATUS) {
+    __rotation.charger_status = vconf_keynode_get_int(keynode);
+    if (__rotation.ref) {
+      if (__rotation.charger_status) {
+        base->impl_->InitRotation();
+      } else {
+        base->impl_->FiniRotation();
+      }
+    }
+
+    _D("charger status(%d)", __rotation.charger_status);
+  }
+}
+
 void AppCoreBase::Impl::LockCb(keynode_t* node, void* user_data) {
   AppCoreBase::RotationState rm;
   AppCoreBase* base = reinterpret_cast<AppCoreBase*>(user_data);
@@ -476,10 +594,13 @@ int AppCoreBase::OnReceive(aul_type type, tizen_base::Bundle b) {
   switch (type) {
   case AUL_START:
     _D("[APP %d]     AUL event: AUL_START", getpid());
-    if (b.GetString(AUL_K_ALLOWED_BG) == "ALLOWED_BG") {
-      _D("[__SUSPEND__] allowed background");
-      impl_->allowed_bg_ = true;
-      RemoveSuspendTimer();
+    if (impl_->feature_ & FEATURE_BACKGROUND_MANAGEMENT) {
+      std::string bg = b.GetString(AUL_K_ALLOWED_BG);
+      if (bg == "ALLOWED_BG") {
+        _D("[__SUSPEND__] allowed background");
+        impl_->allowed_bg_ = true;
+        RemoveSuspendTimer();
+      }
     }
 
     traceBegin(TTRACE_TAG_APPLICATION_MANAGER, "APPCORE:RESET");
@@ -491,10 +612,13 @@ int AppCoreBase::OnReceive(aul_type type, tizen_base::Bundle b) {
     break;
   case AUL_RESUME:
     _D("[APP %d]     AUL event: AUL_RESUME", getpid());
-    if (b.GetString(AUL_K_ALLOWED_BG) == "ALLOWED_BG") {
-      _D("[__SUSPEND__] allowed background");
-      impl_->allowed_bg_ = true;
-      RemoveSuspendTimer();
+    if (impl_->feature_ & FEATURE_BACKGROUND_MANAGEMENT) {
+      std::string bg = b.GetString(AUL_K_ALLOWED_BG);
+      if (bg == "ALLOWED_BG") {
+        _D("[__SUSPEND__] allowed background");
+        impl_->allowed_bg_ = true;
+        RemoveSuspendTimer();
+      }
     }
     break;
   case AUL_TERMINATE:
@@ -514,18 +638,22 @@ int AppCoreBase::OnReceive(aul_type type, tizen_base::Bundle b) {
     break;
   case AUL_WAKE:
     _D("[APP %d]     AUL event: AUL_WAKE", getpid());
-    if (!impl_->allowed_bg_ && impl_->suspended_state_) {
-      RemoveSuspendTimer();
-      int suspend = SUSPENDED_STATE_DID_EXIT_FROM_SUSPEND;
-      impl_->InvokeCallback(suspend, IEvent::Type::SUSPENDED_STATE_CHANGE);
-      impl_->suspended_state_ = false;
+    if (impl_->feature_ & FEATURE_BACKGROUND_MANAGEMENT) {
+      if (!impl_->allowed_bg_ && impl_->suspended_state_) {
+        RemoveSuspendTimer();
+        int suspend = SUSPENDED_STATE_DID_EXIT_FROM_SUSPEND;
+        impl_->InvokeCallback(suspend, IEvent::Type::SUSPENDED_STATE_CHANGE);
+        impl_->suspended_state_ = false;
+      }
     }
     break;
   case AUL_SUSPEND:
     _D("[APP %d]     AUL event: AUL_SUSPEND", getpid());
-    if (!impl_->allowed_bg_ && !impl_->suspended_state_) {
-      RemoveSuspendTimer();
-      FlushMemory();
+    if (impl_->feature_ & FEATURE_BACKGROUND_MANAGEMENT) {
+      if (!impl_->allowed_bg_ && !impl_->suspended_state_) {
+        RemoveSuspendTimer();
+        FlushMemory();
+      }
     }
     break;
   case AUL_UPDATE_REQUESTED:
@@ -653,11 +781,27 @@ void AppCoreBase::Impl::UnregisterRotationChangedEvent() {
     return;
 
   __rotation.ref--;
-  if (__rotation.ref == 0) FiniRotation();
+  if (__rotation.ref == 0) {
+    FiniRotation();
+    if (feature_ & FEATURE_CHARGER_STATUS) {
+      vconf_ignore_key_changed(VCONFKEY_SYSMAN_CHARGER_STATUS,
+          ChargerStatusChangedCb);
+    }
+  }
 }
 
 void AppCoreBase::Impl::RegisterRotationChangedEvent() {
-  if (__rotation.ref == 0) InitRotation();
+  if (__rotation.ref == 0) {
+    if (feature_ & FEATURE_CHARGER_STATUS) {
+      vconf_get_int(VCONFKEY_SYSMAN_CHARGER_STATUS, &__rotation.charger_status);
+      vconf_notify_key_changed(VCONFKEY_SYSMAN_CHARGER_STATUS,
+          ChargerStatusChangedCb, parent_);
+      if (__rotation.charger_status)
+        InitRotation();
+    } else {
+      InitRotation();
+    }
+  }
 
   __rotation.ref++;
 }
@@ -1100,13 +1244,8 @@ void AppCoreBase::Init(int argc, char** argv) {
   impl_->PluginInit(argc, argv);
   traceEnd(TTRACE_TAG_APPLICATION_MANAGER);
 
-  GLib::IdleAdd(
-      [](gpointer data) -> gboolean {
-        AppCoreBase* base = reinterpret_cast<AppCoreBase*>(data);
-        base->impl_->InitSuspend();
-        return G_SOURCE_REMOVE;
-      },
-      this);
+  if (impl_->feature_ & FEATURE_BACKGROUND_MANAGEMENT)
+    GLib::IdleAdd(Impl::InitSuspendCb, this);
 
   traceBegin(TTRACE_TAG_APPLICATION_MANAGER, "APPCORE:SET_SYSTEM_EVENT");
   if (!impl_->dirty_) {
diff --git a/tizen-cpp/app-core-cpp/suspend_event_private.cc b/tizen-cpp/app-core-cpp/suspend_event_private.cc
deleted file mode 100644 (file)
index 2c88ed8..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (c) 2024 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 "app-core-cpp/suspend_event_private.hh"
-
-#include "common/log_private.hh"
-
-namespace {
-
-constexpr const char RESOURCED_FREEZER_PATH[] =
-    "/Org/Tizen/ResourceD/Freezer";
-constexpr const char RESOURCED_FREEZER_INTERFACE[] =
-    "org.tizen.resourced.freezer";
-constexpr const char RESOURCED_FREEZER_SIGNAL[] =
-    "FreezerState";
-
-}  // namespace
-
-namespace tizen_cpp {
-
-SuspendEvent::SuspendEvent(IEventListener* listener) : listener_(listener) {
-  cancellable_ = g_cancellable_new();
-  if (cancellable_ == nullptr) {
-    _E("g_cancellable_new() is failed");
-    return;
-  }
-
-  g_bus_get(G_BUS_TYPE_SYSTEM, cancellable_, GAsyncReadyCb, this);
-}
-
-SuspendEvent::~SuspendEvent() {
-  if (source_ != 0)
-    g_dbus_connection_signal_unsubscribe(conn_, source_);
-
-  if (conn_ != nullptr)
-    g_object_unref(conn_);
-
-  if (cancellable_ != nullptr) {
-    g_cancellable_cancel(cancellable_);
-    g_object_unref(cancellable_);
-  }
-}
-
-void SuspendEvent::GAsyncReadyCb(GObject* source_object, GAsyncResult* res,
-                                 gpointer user_data) {
-  auto* event = static_cast<SuspendEvent*>(user_data);
-  g_object_unref(event->cancellable_);
-  event->cancellable_ = nullptr;
-
-  GError* error = nullptr;
-  event->conn_ = g_bus_get_finish(res, &error);
-  if (event->conn_ == nullptr) {
-    _E("g_bus_get_finish() is failed. error(%s)", error ? error->message : "");
-    g_clear_error(&error);
-    return;
-  }
-
-  event->source_ = g_dbus_connection_signal_subscribe(
-      event->conn_, nullptr, RESOURCED_FREEZER_INTERFACE,
-      RESOURCED_FREEZER_SIGNAL, RESOURCED_FREEZER_PATH, nullptr,
-      G_DBUS_SIGNAL_FLAGS_NONE, GDBusSignalCb, user_data, nullptr);
-  if (event->source_ == 0) {
-    _E("g_dbus_connection_signal_subscribe() is failed");
-    return;
-  }
-
-  _D("Suspend signal subscribed");
-}
-
-void SuspendEvent::GDBusSignalCb(GDBusConnection* conn,
-                                 const gchar* sender_name,
-                                 const gchar* object_path,
-                                 const gchar* interface_name,
-                                 const gchar* signal_name, GVariant* parameters,
-                                 gpointer user_data) {
-  if (g_strcmp0(signal_name, RESOURCED_FREEZER_SIGNAL) != 0)
-    return;
-
-  gint pid = -1;
-  gint status = 0;
-  g_variant_get(parameters, "(ii)", &status, &pid);
-  auto* event = static_cast<SuspendEvent*>(user_data);
-  event->listener_->OnSuspend(pid, status);
-}
-
-}  // namespace tizen_cpp
diff --git a/tizen-cpp/app-core-cpp/suspend_event_private.hh b/tizen-cpp/app-core-cpp/suspend_event_private.hh
deleted file mode 100644 (file)
index 46cbe3e..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2024 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 TIZEN_CPP_APP_CORE_CPP_SUSPEND_EVENT_PRIVATE_HH_
-#define TIZEN_CPP_APP_CORE_CPP_SUSPEND_EVENT_PRIVATE_HH_
-
-#include <gio/gio.h>
-#include <glib.h>
-#include <sys/types.h>
-
-namespace tizen_cpp {
-
-class SuspendEvent {
- public:
-  class IEventListener {
-   public:
-    virtual ~IEventListener() = default;
-    virtual void OnSuspend(pid_t pid, int status) = 0;
-  };
-
-  explicit SuspendEvent(IEventListener* listener);
-  ~SuspendEvent();
-
- private:
-  static void GAsyncReadyCb(GObject* source_object, GAsyncResult* res,
-                            gpointer user_data);
-  static void GDBusSignalCb(GDBusConnection* conn, const gchar* sender_name,
-                            const gchar* object_path,
-                            const gchar* interface_name,
-                            const gchar* signal_name, GVariant* parameters,
-                            gpointer user_data);
-
- private:
-  IEventListener* listener_;
-  GDBusConnection* conn_ = nullptr;
-  GCancellable* cancellable_ = nullptr;
-  guint source_ = 0;
-};
-
-}  // namespace tizen_cpp
-
-#endif  // TIZEN_CPP_APP_CORE_CPP_SUSPEND_EVENT_PRIVATE_HH_
index 2e79bc9c4d2cd8222d8f87e3745bb7de3dd1bc9d..b7a6671b017815c1689a50f1b2b54f24f67cecce 100644 (file)
@@ -39,6 +39,7 @@ TARGET_INCLUDE_DIRECTORIES(${TARGET_UNIT_TEST} PUBLIC
 APPLY_PKG_CONFIG(${TARGET_UNIT_TEST} PUBLIC
   AUL_DEPS
   BUNDLE_DEPS
+  CAPI_SYSTEM_INFO_DEPS
   DLOG_DEPS
   ECORE_WL2_DEPS
   ELEMENTARY_DEPS
index d2ff12c9c209afceea10d6994271bb40cb586b85..56f23d0c6b3bd1237afcfb40611d5622fb0d9238 100644 (file)
 #include "mock/test_fixture.h"
 
 extern "C" GDBusConnection* g_bus_get_sync(GBusType bus_type,
-                                           GCancellable* cancellable,
-                                           GError** error) {
+    GCancellable* cancellable, GError** error) {
   return MOCK_HOOK_P3(DbusMock, g_bus_get_sync, bus_type, cancellable, error);
 }
 
-extern "C" guint g_dbus_connection_signal_subscribe(
-    GDBusConnection* arg0, const gchar* arg1, const gchar* arg2,
-    const gchar* arg3, const gchar* arg4, const gchar* arg5,
-    GDBusSignalFlags arg6, GDBusSignalCallback arg7, gpointer arg8,
-    GDestroyNotify arg9) {
-  return MOCK_HOOK_P10(DbusMock, g_dbus_connection_signal_subscribe, arg0, arg1,
-                       arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
-}
-
-extern "C" void g_bus_get(GBusType bus_type, GCancellable* cancellable,
-                          GAsyncReadyCallback callback, gpointer user_data) {
-  MOCK_HOOK_P4(DbusMock, g_bus_get, bus_type, cancellable, callback, user_data);
-}
-
-extern "C" GDBusConnection* g_bus_get_finish(GAsyncResult* res,
-                                             GError** error) {
-  return MOCK_HOOK_P2(DbusMock, g_bus_get_finish, res, error);
-}
-
-extern "C" void g_dbus_connection_signal_unsubscribe(GDBusConnection* conn,
-                                                     guint subscription_id) {
-  MOCK_HOOK_P2(DbusMock, g_dbus_connection_signal_unsubscribe, conn,
-               subscription_id);
-}
-
-extern "C" GCancellable* g_cancellable_new(void) {
-  return MOCK_HOOK_P0(DbusMock, g_cancellable_new);
-}
-
-extern "C" void g_cancellable_cancel(GCancellable* cancellable) {
-  MOCK_HOOK_P1(DbusMock, g_cancellable_cancel, cancellable);
-}
-
-extern "C" void g_object_unref(gpointer object) {
-  MOCK_HOOK_P1(DbusMock, g_object_unref, object);
+extern "C" guint g_dbus_connection_signal_subscribe(GDBusConnection* arg0,
+    const gchar* arg1, const gchar* arg2, const gchar* arg3, const gchar* arg4,
+    const gchar* arg5, GDBusSignalFlags arg6, GDBusSignalCallback arg7,
+    gpointer arg8, GDestroyNotify arg9) {
+  return MOCK_HOOK_P10(DbusMock, g_dbus_connection_signal_subscribe,
+      arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
 }
index f1b5143043234c27ace95090b3c35be119f99b70..c4bf82b5eac4ab0f07ba6ad42bda2b4627480ed3 100644 (file)
@@ -27,32 +27,25 @@ class DbusMock : public virtual ModuleMock {
  public:
   DbusMock() {
     using ::testing::_;
-    using ::testing::Invoke;
     using ::testing::Return;
+    using ::testing::Invoke;
 
     static int dummy;
-    conn_ = reinterpret_cast<GDBusConnection*>(&dummy);
+    conn_ = (GDBusConnection*)&dummy;
 
-    ON_CALL(*this, g_bus_get_sync(_, _, _)).WillByDefault(Return(conn_));
+    ON_CALL(*this, g_bus_get_sync(_, _, _))
+      .WillByDefault(Return(conn_));
   }
 
-  MOCK_METHOD3(g_bus_get_sync,
-               GDBusConnection*(GBusType, GCancellable*, GError**));
-  MOCK_METHOD4(g_bus_get,
-               void(GBusType, GCancellable*, GAsyncReadyCallback, gpointer));
+  MOCK_METHOD3(g_bus_get_sync, GDBusConnection* (GBusType, GCancellable*, GError**));
   MOCK_METHOD10(g_dbus_connection_signal_subscribe,
       guint(GDBusConnection*, const gchar*, const gchar*, const gchar*,
       const gchar*, const gchar*, GDBusSignalFlags, GDBusSignalCallback,
       gpointer, GDestroyNotify));
-  MOCK_METHOD2(g_dbus_connection_signal_unsubscribe,
-               void(GDBusConnection*, guint));
-  MOCK_METHOD0(g_cancellable_new, GCancellable*());
-  MOCK_METHOD1(g_cancellable_cancel, void(GCancellable*));
-  MOCK_METHOD1(g_object_unref, void(gpointer));
-  MOCK_METHOD2(g_bus_get_finish, GDBusConnection*(GAsyncResult*, GError**));
-
- private:
-  GDBusConnection* conn_ = nullptr;
+
+  private:
+    GDBusConnection* conn_ = nullptr;
 };
 
 #endif  // UNIT_TESTS_MOCK_DBUS_MOCK_H_
+