Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test png icon if svg fails to load #1329

Merged
merged 1 commit into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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