summaryrefslogtreecommitdiff
path: root/gio/tests
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2021-10-29 10:35:47 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2021-10-29 10:35:47 +0900
commitceeb6230c225466e29ca00144216e73ef1edd96b (patch)
tree2c6c5b8234f6b3d9dc3ed5867494cab80fd117d3 /gio/tests
parent5ae663c280fa741754b78a4d442c1b5a33e502de (diff)
downloadglib-ceeb6230c225466e29ca00144216e73ef1edd96b.tar.gz
glib-ceeb6230c225466e29ca00144216e73ef1edd96b.tar.bz2
glib-ceeb6230c225466e29ca00144216e73ef1edd96b.zip
Imported Upstream version 2.69.1upstream/2.69.1
Diffstat (limited to 'gio/tests')
-rw-r--r--gio/tests/async-splice-output-stream.c1
-rw-r--r--gio/tests/g-file-info.c2
-rw-r--r--gio/tests/gnotification.c4
-rwxr-xr-xgio/tests/memory-monitor-dbus.py.in3
-rw-r--r--gio/tests/meson.build1
-rw-r--r--gio/tests/power-profile-monitor.c79
6 files changed, 86 insertions, 4 deletions
diff --git a/gio/tests/async-splice-output-stream.c b/gio/tests/async-splice-output-stream.c
index fb317b733..3ac03ae67 100644
--- a/gio/tests/async-splice-output-stream.c
+++ b/gio/tests/async-splice-output-stream.c
@@ -63,6 +63,7 @@ test_copy_chunks_splice_cb (GObject *source,
if (data->flags & TEST_CANCEL)
{
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_CANCELLED);
+ g_error_free (error);
g_main_loop_quit (data->main_loop);
return;
}
diff --git a/gio/tests/g-file-info.c b/gio/tests/g-file-info.c
index c11c50462..fd0c64b55 100644
--- a/gio/tests/g-file-info.c
+++ b/gio/tests/g-file-info.c
@@ -178,7 +178,7 @@ test_g_file_info_modification_time (void)
g_assert_nonnull (dt_usecs);
ts = g_date_time_difference (dt_usecs, dt);
- g_assert_cmpint (ts, >, 0);
+ g_assert_cmpint (ts, >=, 0);
g_assert_cmpint (ts, <, G_USEC_PER_SEC);
/* Try round-tripping the modification time. */
diff --git a/gio/tests/gnotification.c b/gio/tests/gnotification.c
index 80d476d5a..853983c18 100644
--- a/gio/tests/gnotification.c
+++ b/gio/tests/gnotification.c
@@ -180,6 +180,7 @@ struct _GNotification
gchar *body;
GIcon *icon;
GNotificationPriority priority;
+ gchar *category;
GPtrArray *buttons;
gchar *default_action;
GVariant *default_action_target;
@@ -205,10 +206,12 @@ test_properties (void)
g_notification_set_title (n, "title");
g_notification_set_body (n, "body");
+ g_notification_set_category (n, "cate.gory");
icon = g_themed_icon_new ("i-c-o-n");
g_notification_set_icon (n, icon);
g_object_unref (icon);
g_notification_set_priority (n, G_NOTIFICATION_PRIORITY_HIGH);
+ g_notification_set_category (n, "cate.gory");
g_notification_add_button (n, "label1", "app.action1::target1");
g_notification_set_default_action (n, "app.action2::target2");
@@ -222,6 +225,7 @@ test_properties (void)
g_assert_cmpstr (names[1], ==, "i-c-o-n-symbolic");
g_assert_null (names[2]);
g_assert (rn->priority == G_NOTIFICATION_PRIORITY_HIGH);
+ g_assert_cmpstr (rn->category, ==, "cate.gory");
g_assert_cmpint (rn->buttons->len, ==, 1);
b = (Button*)rn->buttons->pdata[0];
diff --git a/gio/tests/memory-monitor-dbus.py.in b/gio/tests/memory-monitor-dbus.py.in
index cd16cf4e3..7823e7309 100755
--- a/gio/tests/memory-monitor-dbus.py.in
+++ b/gio/tests/memory-monitor-dbus.py.in
@@ -31,9 +31,6 @@ try:
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
- # XDG_DESKTOP_PORTAL_PATH = os.path.expanduser("~/.cache/jhbuild/build/xdg-desktop-portal/xdg-desktop-portal")
- XDG_DESKTOP_PORTAL_PATH = "@libexecdir@/xdg-desktop-portal"
-
class TestLowMemoryMonitor(dbusmock.DBusTestCase):
'''Test GMemoryMonitorDBus'''
diff --git a/gio/tests/meson.build b/gio/tests/meson.build
index 98d1401d0..fc2055101 100644
--- a/gio/tests/meson.build
+++ b/gio/tests/meson.build
@@ -75,6 +75,7 @@ gio_tests = {
'network-monitor-race' : {},
'permission' : {},
'pollable' : {'dependencies' : [libdl_dep]},
+ 'power-profile-monitor' : {},
'proxy-test' : {},
'readwrite' : {},
'simple-async-result' : {},
diff --git a/gio/tests/power-profile-monitor.c b/gio/tests/power-profile-monitor.c
new file mode 100644
index 000000000..bb32f181f
--- /dev/null
+++ b/gio/tests/power-profile-monitor.c
@@ -0,0 +1,79 @@
+/* GIO - GLib Input, Output and Streaming Library
+ *
+ * Copyright 2021 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <gio/gio.h>
+
+static void
+test_dup_default (void)
+{
+ GPowerProfileMonitor *monitor;
+
+ monitor = g_power_profile_monitor_dup_default ();
+ g_assert_nonnull (monitor);
+ g_object_unref (monitor);
+}
+
+static void
+power_saver_enabled_cb (GPowerProfileMonitor *monitor,
+ GParamSpec *pspec,
+ gpointer user_data)
+{
+ gboolean enabled;
+
+ enabled = g_power_profile_monitor_get_power_saver_enabled (monitor);
+ g_debug ("Power Saver %s (%d)", enabled ? "enabled" : "disabled", enabled);
+}
+
+static void
+do_watch_power_profile (void)
+{
+ GPowerProfileMonitor *monitor;
+ GMainLoop *loop;
+ gulong signal_id;
+
+ monitor = g_power_profile_monitor_dup_default ();
+ signal_id = g_signal_connect (G_OBJECT (monitor), "notify::power-saver-enabled",
+ G_CALLBACK (power_saver_enabled_cb), NULL);
+
+ loop = g_main_loop_new (NULL, TRUE);
+ g_main_loop_run (loop);
+
+ g_signal_handler_disconnect (monitor, signal_id);
+ g_object_unref (monitor);
+ g_main_loop_unref (loop);
+}
+
+int
+main (int argc, char **argv)
+{
+ int ret;
+
+ if (argc == 2 && !strcmp (argv[1], "--watch"))
+ {
+ do_watch_power_profile ();
+ return 0;
+ }
+
+ g_test_init (&argc, &argv, NULL);
+
+ g_test_add_func ("/power-profile-monitor/default", test_dup_default);
+
+ ret = g_test_run ();
+
+ return ret;
+}