forked from AuroraMiddleware/gtk
testsuite: Add more icontheme tests
Check that the lookup order works properly when forcing either symbolic or regular icons.
This commit is contained in:
parent
5ba4a085e2
commit
5f794773aa
@ -128,6 +128,10 @@ keyhash_SOURCES = \
|
||||
test_icontheme = \
|
||||
icons/16x16/simple.png \
|
||||
icons/index.theme \
|
||||
icons/scalable/everything-justregular.svg \
|
||||
icons/scalable/everything-justsymbolic-symbolic.svg \
|
||||
icons/scalable/everything.svg \
|
||||
icons/scalable/everything-symbolic.svg \
|
||||
$(NULL)
|
||||
|
||||
EXTRA_DIST += \
|
||||
|
@ -3,10 +3,16 @@ Name=Icons
|
||||
Comment=Testing of the Icon theme code
|
||||
Example=16x16/simple.png
|
||||
|
||||
Directories=16x16
|
||||
Directories=16x16,scalable
|
||||
|
||||
[16x16]
|
||||
Context=16x16 icons
|
||||
Size=16
|
||||
Type=Fixed
|
||||
|
||||
[scalable]
|
||||
Context=scalable icons
|
||||
Type=Scalable
|
||||
Size=128
|
||||
Min-Size=1
|
||||
Max-Size=256
|
||||
|
11
testsuite/gtk/icons/scalable/everything-justregular.svg
Normal file
11
testsuite/gtk/icons/scalable/everything-justregular.svg
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" standalone="no"?>
|
||||
<svg width="128" height="128" version="1.1" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect x="0" y="0" width="32" height="32" fill="black"/>
|
||||
<rect x="32" y="32" width="32" height="32" fill="black"/>
|
||||
<rect x="64" y="0" width="32" height="32" fill="black"/>
|
||||
<rect x="96" y="32" width="32" height="32" fill="black"/>
|
||||
<rect x="0" y="64" width="32" height="32" fill="black"/>
|
||||
<rect x="32" y="96" width="32" height="32" fill="black"/>
|
||||
<rect x="64" y="64" width="32" height="32" fill="black"/>
|
||||
<rect x="96" y="96" width="32" height="32" fill="black"/>
|
||||
</svg>
|
After Width: | Height: | Size: 601 B |
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" standalone="no"?>
|
||||
<svg width="128" height="128" version="1.1" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect x="0" y="0" width="32" height="32" fill="black"/>
|
||||
<rect x="32" y="32" width="32" height="32" fill="black"/>
|
||||
<rect x="64" y="0" width="32" height="32" fill="black"/>
|
||||
<rect x="96" y="32" width="32" height="32" fill="black"/>
|
||||
<rect x="0" y="64" width="32" height="32" fill="black"/>
|
||||
<rect x="32" y="96" width="32" height="32" fill="black"/>
|
||||
<rect x="64" y="64" width="32" height="32" fill="black"/>
|
||||
<rect x="96" y="96" width="32" height="32" fill="black"/>
|
||||
</svg>
|
After Width: | Height: | Size: 601 B |
5
testsuite/gtk/icons/scalable/everything-symbolic.svg
Normal file
5
testsuite/gtk/icons/scalable/everything-symbolic.svg
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" standalone="no"?>
|
||||
<svg width="128" height="128" version="1.1" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect x="0" y="0" width="64" height="64" fill="black"/>
|
||||
<rect x="64" y="64" width="64" height="64" fill="black"/>
|
||||
</svg>
|
After Width: | Height: | Size: 243 B |
5
testsuite/gtk/icons/scalable/everything.svg
Normal file
5
testsuite/gtk/icons/scalable/everything.svg
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" standalone="no"?>
|
||||
<svg width="128" height="128" version="1.1" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect x="0" y="0" width="64" height="64" fill="black"/>
|
||||
<rect x="64" y="64" width="64" height="64" fill="black"/>
|
||||
</svg>
|
After Width: | Height: | Size: 243 B |
@ -2,6 +2,8 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#define SCALABLE_IMAGE_SIZE (128)
|
||||
|
||||
static GtkIconTheme *
|
||||
get_test_icontheme (void)
|
||||
{
|
||||
@ -62,25 +64,153 @@ assert_icon_lookup (const char *icon_name,
|
||||
{
|
||||
g_error ("Icon for \"%s\" with flags %s at size %d should be \"...%s\" but is \"...%s\"",
|
||||
icon_name, lookup_flags_to_string (flags), size,
|
||||
filename, gtk_icon_info_get_filename (info) + strlen (gtk_icon_info_get_filename (info)) - strlen (filename));
|
||||
filename, gtk_icon_info_get_filename (info) + strlen (g_get_current_dir ()));
|
||||
return;
|
||||
}
|
||||
|
||||
g_object_unref (info);
|
||||
}
|
||||
|
||||
static void
|
||||
assert_icon_lookup_fails (const char *icon_name,
|
||||
gint size,
|
||||
GtkIconLookupFlags flags)
|
||||
{
|
||||
static gboolean seen_could_not_find_message = FALSE;
|
||||
GtkIconInfo *info;
|
||||
|
||||
if (!seen_could_not_find_message)
|
||||
g_test_expect_message ("Gtk", G_LOG_LEVEL_WARNING, "Could not find the icon*");
|
||||
info = gtk_icon_theme_lookup_icon (get_test_icontheme (), icon_name, size, flags);
|
||||
if (!seen_could_not_find_message)
|
||||
{
|
||||
g_test_assert_expected_messages ();
|
||||
seen_could_not_find_message = TRUE;
|
||||
}
|
||||
if (info != NULL)
|
||||
{
|
||||
g_error ("Should not find an icon for \"%s\" with flags %s at size %d, but found \"%s\"",
|
||||
icon_name, lookup_flags_to_string (flags), size, gtk_icon_info_get_filename (info) + strlen (g_get_current_dir ()));
|
||||
g_object_unref (info);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_basics (void)
|
||||
{
|
||||
assert_icon_lookup ("simple", 16, 0, "/icons/16x16/simple.png");
|
||||
}
|
||||
|
||||
static void
|
||||
test_force_symbolic (void)
|
||||
{
|
||||
/* check forcing symbolic works */
|
||||
assert_icon_lookup ("everything",
|
||||
SCALABLE_IMAGE_SIZE,
|
||||
GTK_ICON_LOOKUP_FORCE_SYMBOLIC,
|
||||
"/icons/scalable/everything-symbolic.svg");
|
||||
/* check forcing symbolic also works for symbolic icons (d'oh) */
|
||||
assert_icon_lookup ("everything-symbolic",
|
||||
SCALABLE_IMAGE_SIZE,
|
||||
GTK_ICON_LOOKUP_FORCE_SYMBOLIC,
|
||||
"/icons/scalable/everything-symbolic.svg");
|
||||
|
||||
/* check all the combos for fallbacks on an icon that only exists as symbolic */
|
||||
assert_icon_lookup ("everything-justsymbolic",
|
||||
SCALABLE_IMAGE_SIZE,
|
||||
GTK_ICON_LOOKUP_FORCE_SYMBOLIC,
|
||||
"/icons/scalable/everything-justsymbolic-symbolic.svg");
|
||||
assert_icon_lookup ("everything-justsymbolic",
|
||||
SCALABLE_IMAGE_SIZE,
|
||||
GTK_ICON_LOOKUP_GENERIC_FALLBACK | GTK_ICON_LOOKUP_FORCE_SYMBOLIC,
|
||||
"/icons/scalable/everything-justsymbolic-symbolic.svg");
|
||||
assert_icon_lookup ("everything-justsymbolic-symbolic",
|
||||
SCALABLE_IMAGE_SIZE,
|
||||
GTK_ICON_LOOKUP_FORCE_SYMBOLIC,
|
||||
"/icons/scalable/everything-justsymbolic-symbolic.svg");
|
||||
assert_icon_lookup ("everything-justsymbolic-symbolic",
|
||||
SCALABLE_IMAGE_SIZE,
|
||||
GTK_ICON_LOOKUP_GENERIC_FALLBACK | GTK_ICON_LOOKUP_FORCE_SYMBOLIC,
|
||||
"/icons/scalable/everything-justsymbolic-symbolic.svg");
|
||||
|
||||
/* check all the combos for fallbacks, this time for an icon that only exists as regular */
|
||||
assert_icon_lookup ("everything-justregular",
|
||||
SCALABLE_IMAGE_SIZE,
|
||||
GTK_ICON_LOOKUP_FORCE_SYMBOLIC,
|
||||
"/icons/scalable/everything-justregular.svg");
|
||||
assert_icon_lookup ("everything-justregular",
|
||||
SCALABLE_IMAGE_SIZE,
|
||||
GTK_ICON_LOOKUP_GENERIC_FALLBACK | GTK_ICON_LOOKUP_FORCE_SYMBOLIC,
|
||||
"/icons/scalable/everything-symbolic.svg");
|
||||
assert_icon_lookup_fails ("everything-justregular-symbolic",
|
||||
SCALABLE_IMAGE_SIZE,
|
||||
GTK_ICON_LOOKUP_FORCE_SYMBOLIC);
|
||||
assert_icon_lookup ("everything-justregular-symbolic",
|
||||
SCALABLE_IMAGE_SIZE,
|
||||
GTK_ICON_LOOKUP_GENERIC_FALLBACK | GTK_ICON_LOOKUP_FORCE_SYMBOLIC,
|
||||
"/icons/scalable/everything-symbolic.svg");
|
||||
}
|
||||
|
||||
static void
|
||||
test_force_regular (void)
|
||||
{
|
||||
/* check forcing regular works (d'oh) */
|
||||
assert_icon_lookup ("everything",
|
||||
SCALABLE_IMAGE_SIZE,
|
||||
GTK_ICON_LOOKUP_FORCE_REGULAR,
|
||||
"/icons/scalable/everything.svg");
|
||||
/* check forcing regular also works for symbolic icons ) */
|
||||
assert_icon_lookup ("everything-symbolic",
|
||||
SCALABLE_IMAGE_SIZE,
|
||||
GTK_ICON_LOOKUP_FORCE_REGULAR,
|
||||
"/icons/scalable/everything.svg");
|
||||
|
||||
/* check all the combos for fallbacks on an icon that only exists as regular */
|
||||
assert_icon_lookup ("everything-justregular",
|
||||
SCALABLE_IMAGE_SIZE,
|
||||
GTK_ICON_LOOKUP_FORCE_REGULAR,
|
||||
"/icons/scalable/everything-justregular.svg");
|
||||
assert_icon_lookup ("everything-justregular",
|
||||
SCALABLE_IMAGE_SIZE,
|
||||
GTK_ICON_LOOKUP_GENERIC_FALLBACK | GTK_ICON_LOOKUP_FORCE_REGULAR,
|
||||
"/icons/scalable/everything-justregular.svg");
|
||||
assert_icon_lookup ("everything-justregular-symbolic",
|
||||
SCALABLE_IMAGE_SIZE,
|
||||
GTK_ICON_LOOKUP_FORCE_REGULAR,
|
||||
"/icons/scalable/everything-justregular.svg");
|
||||
assert_icon_lookup ("everything-justregular-symbolic",
|
||||
SCALABLE_IMAGE_SIZE,
|
||||
GTK_ICON_LOOKUP_GENERIC_FALLBACK | GTK_ICON_LOOKUP_FORCE_REGULAR,
|
||||
"/icons/scalable/everything-justregular.svg");
|
||||
|
||||
/* check all the combos for fallbacks, this time for an icon that only exists as symbolic */
|
||||
assert_icon_lookup_fails ("everything-justsymbolic",
|
||||
SCALABLE_IMAGE_SIZE,
|
||||
GTK_ICON_LOOKUP_FORCE_REGULAR);
|
||||
assert_icon_lookup ("everything-justsymbolic",
|
||||
SCALABLE_IMAGE_SIZE,
|
||||
GTK_ICON_LOOKUP_GENERIC_FALLBACK | GTK_ICON_LOOKUP_FORCE_REGULAR,
|
||||
"/icons/scalable/everything.svg");
|
||||
assert_icon_lookup ("everything-justsymbolic-symbolic",
|
||||
SCALABLE_IMAGE_SIZE,
|
||||
GTK_ICON_LOOKUP_FORCE_REGULAR,
|
||||
"/icons/scalable/everything-justsymbolic-symbolic.svg");
|
||||
assert_icon_lookup ("everything-justsymbolic-symbolic",
|
||||
SCALABLE_IMAGE_SIZE,
|
||||
GTK_ICON_LOOKUP_GENERIC_FALLBACK | GTK_ICON_LOOKUP_FORCE_REGULAR,
|
||||
"/icons/scalable/everything.svg");
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
gtk_test_init (&argc, &argv);
|
||||
|
||||
g_test_add_func ("/icontheme/basics", test_basics);
|
||||
g_test_add_func ("/icontheme/force-symbolic", test_force_symbolic);
|
||||
g_test_add_func ("/icontheme/force-regular", test_force_regular);
|
||||
|
||||
return g_test_run();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user