Fix unittest build issue for glib 2.78.4 62/307762/1
authorInkyun Kil <inkyun.kil@samsung.com>
Wed, 13 Mar 2024 01:42:18 +0000 (10:42 +0900)
committerInkyun Kil <inkyun.kil@samsung.com>
Wed, 13 Mar 2024 01:42:18 +0000 (10:42 +0900)
Change-Id: I781f23c290a4bc31054fd0ca26842595f1e28336
Signed-off-by: Inkyun Kil <inkyun.kil@samsung.com>
tests/unit_tests/src/test_eventsystem.cc

index 2f67f11fa140494e49b1d4c0e7e81e6e59975df7..a10befbc70ec866e6c8924b5b95c35b590420501 100644 (file)
@@ -101,18 +101,30 @@ TEST_F(EventSystemTest, eventsystem_unregister_event) {
 }
 
 TEST_F(EventSystemTest, eventsystem_send_user_event) {
-  GDBusProxy* _proxy = (GDBusProxy*)g_object_new(G_TYPE_OBJECT, nullptr);
-  GDBusConnection* _conn = (GDBusConnection*)g_object_new(G_TYPE_OBJECT, nullptr);
-
-  EXPECT_CALL(GetMock<GioMock>(), g_bus_get_sync(_, _, _))
-        .WillRepeatedly(Return(_conn));
-
+  EXPECT_CALL(GetMock<GioMock>(), g_bus_get_sync(_, _, _)).
+      WillRepeatedly(
+        Invoke([&](GBusType type,
+            GCancellable* cancellable, GError** error)
+          -> GDBusConnection* {
+        GDBusConnection* con =
+            (GDBusConnection*)g_object_new(G_TYPE_DBUS_CONNECTION, nullptr);
+        return con;
+      }));
   EXPECT_CALL(GetMock<GioMock>(),
       g_bus_own_name_on_connection(_, _, _, _, _, _, _)).
       WillRepeatedly(Return(1));
   EXPECT_CALL(GetMock<GioMock>(),
       g_dbus_proxy_new_sync(_, _, _, _, _, _, _, _)).
-      WillRepeatedly(Return(_proxy));
+      WillRepeatedly(
+        Invoke([&](GDBusConnection* con,
+            GDBusProxyFlags flag, GDBusInterfaceInfo* info, const gchar* name,
+            const gchar* path, const gchar* interface, GCancellable* cancellable,
+            GError** error)
+          -> GDBusProxy* {
+        GDBusProxy* proxy =
+            (GDBusProxy*)g_object_new(G_TYPE_OBJECT, nullptr);
+        return proxy;
+      }));
   EXPECT_CALL(GetMock<GioMock>(),
       g_dbus_proxy_call_sync(_, _, _, _, _, _, _)).
       WillRepeatedly(
@@ -148,14 +160,21 @@ TEST_F(EventSystemTest, eventsystem_send_system_event) {
 }
 
 TEST_F(EventSystemTest, eventsystem_request_sending_system_event) {
-  GDBusProxy* _proxy = (GDBusProxy*)g_object_new(G_TYPE_OBJECT, nullptr);
-
   EXPECT_CALL(GetMock<GioMock>(),
       g_bus_own_name_on_connection(_, _, _, _, _, _, _)).
       WillRepeatedly(Return(1));
   EXPECT_CALL(GetMock<GioMock>(),
       g_dbus_proxy_new_sync(_, _, _, _, _, _, _, _)).
-      WillRepeatedly(Return(_proxy));
+      WillRepeatedly(
+        Invoke([&](GDBusConnection* con,
+            GDBusProxyFlags flag, GDBusInterfaceInfo* info, const gchar* name,
+            const gchar* path, const gchar* interface, GCancellable* cancellable,
+            GError** error)
+          -> GDBusProxy* {
+        GDBusProxy* proxy =
+            (GDBusProxy*)g_object_new(G_TYPE_OBJECT, nullptr);
+        return proxy;
+      }));
   EXPECT_CALL(GetMock<GioMock>(),
       g_dbus_proxy_call_sync(_, _, _, _, _, _, _)).
       WillRepeatedly(
@@ -175,8 +194,15 @@ TEST_F(EventSystemTest, eventsystem_request_sending_system_event) {
 }
 
 TEST_F(EventSystemTest, eventsystem_register_application_event) {
-  GDBusProxy* _proxy = (GDBusProxy*)g_object_new(G_TYPE_OBJECT, nullptr);
-
+  EXPECT_CALL(GetMock<GioMock>(), g_bus_get_sync(_, _, _)).
+      WillRepeatedly(
+        Invoke([&](GBusType type,
+            GCancellable* cancellable, GError** error)
+          -> GDBusConnection* {
+        GDBusConnection* con =
+            (GDBusConnection*)g_object_new(G_TYPE_DBUS_CONNECTION, nullptr);
+        return con;
+      }));
   EXPECT_CALL(GetMock<GioMock>(),
       g_dbus_is_interface_name(_)).
       WillOnce(Return(true));
@@ -188,7 +214,16 @@ TEST_F(EventSystemTest, eventsystem_register_application_event) {
       WillRepeatedly(Return(1));
   EXPECT_CALL(GetMock<GioMock>(),
       g_dbus_proxy_new_sync(_, _, _, _, _, _, _, _)).
-      WillRepeatedly(Return(_proxy));
+      WillRepeatedly(
+        Invoke([&](GDBusConnection* con,
+            GDBusProxyFlags flag, GDBusInterfaceInfo* info, const gchar* name,
+            const gchar* path, const gchar* interface, GCancellable* cancellable,
+            GError** error)
+          -> GDBusProxy* {
+        GDBusProxy* proxy =
+            (GDBusProxy*)g_object_new(G_TYPE_OBJECT, nullptr);
+        return proxy;
+      }));
   EXPECT_CALL(GetMock<GioMock>(),
       g_dbus_proxy_call_sync(_, _, _, _, _, _, _)).
       WillOnce(
@@ -213,8 +248,15 @@ TEST_F(EventSystemTest, eventsystem_register_application_event) {
 }
 
 TEST_F(EventSystemTest, eventsystem_unregister_application_event) {
- GDBusProxy* _proxy = (GDBusProxy*)g_object_new(G_TYPE_OBJECT, nullptr);
-
+  EXPECT_CALL(GetMock<GioMock>(), g_bus_get_sync(_, _, _)).
+      WillRepeatedly(
+        Invoke([&](GBusType type,
+            GCancellable* cancellable, GError** error)
+          -> GDBusConnection* {
+        GDBusConnection* con =
+            (GDBusConnection*)g_object_new(G_TYPE_DBUS_CONNECTION, nullptr);
+        return con;
+      }));
   EXPECT_CALL(GetMock<GioMock>(),
       g_dbus_is_interface_name(_)).
       WillOnce(Return(true));
@@ -226,7 +268,16 @@ TEST_F(EventSystemTest, eventsystem_unregister_application_event) {
       WillRepeatedly(Return(1));
   EXPECT_CALL(GetMock<GioMock>(),
       g_dbus_proxy_new_sync(_, _, _, _, _, _, _, _)).
-      WillRepeatedly(Return(_proxy));
+      WillRepeatedly(
+        Invoke([&](GDBusConnection* con,
+            GDBusProxyFlags flag, GDBusInterfaceInfo* info, const gchar* name,
+            const gchar* path, const gchar* interface, GCancellable* cancellable,
+            GError** error)
+          -> GDBusProxy* {
+        GDBusProxy* proxy =
+            (GDBusProxy*)g_object_new(G_TYPE_OBJECT, nullptr);
+        return proxy;
+      }));
   EXPECT_CALL(GetMock<GioMock>(),
       g_dbus_proxy_call_sync(_, _, _, _, _, _, _)).
       WillOnce(
@@ -255,8 +306,15 @@ TEST_F(EventSystemTest, eventsystem_unregister_application_event) {
 }
 
 TEST_F(EventSystemTest, eventsystem_keep_last_event_data) {
-  GDBusProxy* _proxy = (GDBusProxy*)g_object_new(G_TYPE_OBJECT, nullptr);
-
+  EXPECT_CALL(GetMock<GioMock>(), g_bus_get_sync(_, _, _)).
+      WillRepeatedly(
+        Invoke([&](GBusType type,
+            GCancellable* cancellable, GError** error)
+          -> GDBusConnection* {
+        GDBusConnection* con =
+            (GDBusConnection*)g_object_new(G_TYPE_DBUS_CONNECTION, nullptr);
+        return con;
+      }));
   EXPECT_CALL(GetMock<GioMock>(),
       g_dbus_is_interface_name(_)).
       WillOnce(Return(true));
@@ -268,7 +326,16 @@ TEST_F(EventSystemTest, eventsystem_keep_last_event_data) {
       WillRepeatedly(Return(1));
   EXPECT_CALL(GetMock<GioMock>(),
       g_dbus_proxy_new_sync(_, _, _, _, _, _, _, _)).
-      WillRepeatedly(Return(_proxy));
+      WillRepeatedly(
+        Invoke([&](GDBusConnection* con,
+            GDBusProxyFlags flag, GDBusInterfaceInfo* info, const gchar* name,
+            const gchar* path, const gchar* interface, GCancellable* cancellable,
+            GError** error)
+          -> GDBusProxy* {
+        GDBusProxy* proxy =
+            (GDBusProxy*)g_object_new(G_TYPE_OBJECT, nullptr);
+        return proxy;
+      }));
   EXPECT_CALL(GetMock<GioMock>(),
       g_dbus_proxy_call_sync(_, _, _, _, _, _, _)).
       WillRepeatedly(