forked from dunst-project/dunst
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
651be8e
commit 3f7de41
Showing
14 changed files
with
204 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../invalid.png |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../invalid.svg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../valid.png |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../valid.svg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../valid.png |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../valid.svg |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
#include "greatest.h" | ||
#include "../src/icon.h" | ||
#include "../src/utils.h" | ||
|
||
#include <gdk-pixbuf/gdk-pixbuf.h> | ||
#include <glib.h> | ||
|
||
#define ICONPREFIX "./data/icons/path" | ||
|
||
/* As there are no hints to test if the loaded GdkPixbuf is | ||
* read from a PNG or an SVG file, the sample icons in the | ||
* test structure have different sizes | ||
*/ | ||
#define IS_ICON_PNG(pb) 4 == gdk_pixbuf_get_width(pb) | ||
#define IS_ICON_SVG(pb) 16 == gdk_pixbuf_get_width(pb) | ||
|
||
TEST test_get_pixbuf_from_path_invalid(void) | ||
{ | ||
GdkPixbuf *pixbuf = get_pixbuf_from_path("invalid"); | ||
ASSERT(pixbuf == NULL); | ||
g_clear_pointer(&pixbuf, g_object_unref); | ||
|
||
PASS(); | ||
} | ||
|
||
TEST test_get_pixbuf_from_path_both(void) | ||
{ | ||
GdkPixbuf *pixbuf = get_pixbuf_from_path("icon1"); | ||
ASSERT(pixbuf); | ||
ASSERTm("SVG pixbuf hasn't precedence", IS_ICON_SVG(pixbuf)); | ||
g_clear_pointer(&pixbuf, g_object_unref); | ||
|
||
PASS(); | ||
} | ||
|
||
TEST test_get_pixbuf_from_path_onlysvg(void) | ||
{ | ||
GdkPixbuf *pixbuf = get_pixbuf_from_path("onlysvg"); | ||
ASSERT(pixbuf); | ||
ASSERTm("SVG pixbuf isn't loaded", IS_ICON_SVG(pixbuf)); | ||
g_clear_pointer(&pixbuf, g_object_unref); | ||
|
||
PASS(); | ||
} | ||
|
||
TEST test_get_pixbuf_from_path_onlypng(void) | ||
{ | ||
GdkPixbuf *pixbuf = get_pixbuf_from_path("onlypng"); | ||
ASSERT(pixbuf); | ||
ASSERTm("PNG pixbuf isn't loaded", IS_ICON_PNG(pixbuf)); | ||
g_clear_pointer(&pixbuf, g_object_unref); | ||
|
||
PASS(); | ||
} | ||
|
||
TEST test_get_pixbuf_from_path_filename(void) | ||
{ | ||
char *icon = string_append(g_get_current_dir(), "/data/icons/valid.png", NULL); | ||
GdkPixbuf *pixbuf = get_pixbuf_from_path(icon); | ||
ASSERT(pixbuf); | ||
ASSERTm("PNG pixbuf isn't loaded", IS_ICON_PNG(pixbuf)); | ||
g_clear_pointer(&pixbuf, g_object_unref); | ||
|
||
g_free(icon); | ||
PASS(); | ||
} | ||
|
||
TEST test_get_pixbuf_from_path_fileuri(void) | ||
{ | ||
char *curdir = g_get_current_dir(); | ||
char *icon = g_strconcat("file://", curdir,"/data/icons/valid.svg", NULL); | ||
GdkPixbuf *pixbuf = get_pixbuf_from_path(icon); | ||
ASSERT(pixbuf); | ||
ASSERTm("SVG pixbuf isn't loaded", IS_ICON_SVG(pixbuf)); | ||
g_clear_pointer(&pixbuf, g_object_unref); | ||
|
||
g_free(icon); | ||
g_free(curdir); | ||
PASS(); | ||
} | ||
|
||
SUITE(suite_icon) | ||
{ | ||
settings.icon_path = | ||
ICONPREFIX "/invalid" | ||
":" ICONPREFIX "/valid" | ||
":" ICONPREFIX "/both"; | ||
|
||
RUN_TEST(test_get_pixbuf_from_path_invalid); | ||
RUN_TEST(test_get_pixbuf_from_path_both); | ||
RUN_TEST(test_get_pixbuf_from_path_onlysvg); | ||
RUN_TEST(test_get_pixbuf_from_path_onlypng); | ||
RUN_TEST(test_get_pixbuf_from_path_filename); | ||
RUN_TEST(test_get_pixbuf_from_path_fileuri); | ||
|
||
settings.icon_path = NULL; | ||
} | ||
/* vim: set tabstop=8 shiftwidth=8 expandtab textwidth=0: */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters