1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
/*
* Copyright © 2020 Purism SPC
*
* SPDX-License-Identifier: GPL-3.0-or-later
*
* Author: Guido Günther <agx@sigxcpu.org>
*/
#include "notifications/mount-notification.h"
#include "stubs/bad-prop.h"
#include <gio/gdesktopappinfo.h>
#define PHOSH_TYPE_TEST_DUMMY_MOUNT (phosh_test_dummy_mount_get_type ())
G_DECLARE_FINAL_TYPE (PhoshTestDummyMount, phosh_test_dummy_mount, PHOSH, TEST_DUMMY_MOUNT, GObject)
typedef struct _PhoshTestDummyMount {
GObject parent;
} PhoshTestDummyMount;
static char *
test_dummy_get_name (GMount *mount)
{
return g_strdup ("dummy");
}
static GFile *
test_dummy_get_root (GMount *mount)
{
return g_file_new_for_path ("/");
}
static void
mount_iface_init (GMountIface *iface)
{
/* just what we need for the test */
iface->get_root = test_dummy_get_root;
iface->get_name = test_dummy_get_name;
}
G_DEFINE_TYPE_WITH_CODE (PhoshTestDummyMount, phosh_test_dummy_mount, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (G_TYPE_MOUNT, mount_iface_init))
static void
phosh_test_dummy_mount_class_init (PhoshTestDummyMountClass *klass)
{
}
static void
phosh_test_dummy_mount_init (PhoshTestDummyMount *self)
{
}
static void
test_phosh_mount_notification_new (void)
{
g_autoptr (PhoshMountNotification) mn = NULL;
g_autoptr (GMount) mount = g_object_new (PHOSH_TYPE_TEST_DUMMY_MOUNT, NULL);
GIcon *icon = NULL;
g_autofree char *name = NULL;
g_assert_true (G_IS_MOUNT (mount));
name = g_mount_get_name (mount);
g_debug ("mount: %s", name);
mn = phosh_mount_notification_new_from_mount (1, mount);
g_assert_cmpstr (phosh_notification_get_summary (PHOSH_NOTIFICATION (mn)), ==, "dummy");
icon = phosh_notification_get_app_icon (PHOSH_NOTIFICATION (mn));
g_assert_true (G_IS_THEMED_ICON (icon));
g_assert_true (g_strcmp0 (g_themed_icon_get_names (G_THEMED_ICON (icon))[0],
"applications-system-symbolic") == 0 ||
g_strcmp0 (g_themed_icon_get_names (G_THEMED_ICON (icon))[0],
"mobi.phosh.Shell") == 0);
icon = phosh_notification_get_image (PHOSH_NOTIFICATION (mn));
g_assert_true (G_IS_THEMED_ICON (icon));
g_assert_cmpstr (g_themed_icon_get_names (G_THEMED_ICON (icon))[0],
==,
"folder-remote-symbolic");
}
int
main (int argc, char **argv)
{
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/phosh/mount-notification/new", test_phosh_mount_notification_new);
return g_test_run ();
}
|