Skip to content

Commit

Permalink
Merge pull request #1329 from bynect/svg-skip-err
Browse files Browse the repository at this point in the history
Test png icon if svg fails to load
  • Loading branch information
bynect authored Apr 9, 2024
2 parents a2bd494 + f107bba commit a15bc5a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
Binary file modified test/data/icons/valid.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 21 additions & 5 deletions test/notification.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,20 +128,36 @@ TEST test_notification_referencing(void)
PASS();
}


static struct notification *notification_load_icon_with_scaling(int min_icon_size, int max_icon_size)
{
static bool svg_failed = false;

struct notification *n = notification_create();

char *path = g_strconcat(base, "/data/icons/valid.svg", NULL); // 16x16
char *path;
GVariant *raw_icon = NULL;

if (!svg_failed) {
path = g_strconcat(base, "/data/icons/valid.svg", NULL); // 16x16
raw_icon = notification_setup_raw_image(path);

GVariant *rawIcon = notification_setup_raw_image(path);
if (raw_icon == NULL) {
svg_failed = true;
printf("Failed to load svg icon, using png\n");
g_free(path);
}
}

if (raw_icon == NULL) {
path = g_strconcat(base, "/data/icons/valid.png", NULL); // 16x16
raw_icon = notification_setup_raw_image(path);
}

n->min_icon_size = min_icon_size;
n->max_icon_size = max_icon_size;
notification_icon_replace_data(n, rawIcon);
notification_icon_replace_data(n, raw_icon);

g_variant_unref(rawIcon);
g_variant_unref(raw_icon);
g_free(path);

return n;
Expand Down

0 comments on commit a15bc5a

Please sign in to comment.