gio: fix g-icon tests to follow recent changes.

Main changes were:
- take into account that style variants are added to the list of icon
  names.
- In the test of icons set with 3 names ("first", "testicon" and
  "last"), I also changed "first" to "first-symbolic" so that we can
  test in such a case that the variant is the regular icon (only for
  this name, out of the 3).
- Finally icon hashes are necessarily changed, and since emblems are
  sorted by their hash in emblem icons, I had to invert an order which
  was now different in one of the tests.
This commit is contained in:
Jehan 2018-06-08 01:33:30 +02:00
parent 8f729c06ea
commit 2cac8381db

View File

@ -110,7 +110,7 @@ test_g_icon_to_string (void)
icon = g_themed_icon_new ("network-server");
data = g_icon_to_string (icon);
g_assert_cmpstr (data, ==, "network-server");
g_assert_cmpstr (data, ==, ". GThemedIcon network-server network-server-symbolic");
icon2 = g_icon_new_for_string (data, &error);
g_assert_no_error (error);
g_assert (g_icon_equal (icon, icon2));
@ -371,7 +371,7 @@ test_themed_icon (void)
{
GIcon *icon1, *icon2, *icon3, *icon4;
const gchar *const *names;
const gchar *names2[] = { "first", "testicon", "last", NULL };
const gchar *names2[] = { "first-symbolic", "testicon", "last", NULL };
gchar *str;
gboolean fallbacks;
GVariant *variant;
@ -382,17 +382,21 @@ test_themed_icon (void)
g_assert (!fallbacks);
names = g_themed_icon_get_names (G_THEMED_ICON (icon1));
g_assert_cmpint (g_strv_length ((gchar **)names), ==, 1);
g_assert_cmpint (g_strv_length ((gchar **)names), ==, 2);
g_assert_cmpstr (names[0], ==, "testicon");
g_assert_cmpstr (names[1], ==, "testicon-symbolic");
g_themed_icon_prepend_name (G_THEMED_ICON (icon1), "first");
g_themed_icon_prepend_name (G_THEMED_ICON (icon1), "first-symbolic");
g_themed_icon_append_name (G_THEMED_ICON (icon1), "last");
names = g_themed_icon_get_names (G_THEMED_ICON (icon1));
g_assert_cmpint (g_strv_length ((gchar **)names), ==, 3);
g_assert_cmpstr (names[0], ==, "first");
g_assert_cmpint (g_strv_length ((gchar **)names), ==, 6);
g_assert_cmpstr (names[0], ==, "first-symbolic");
g_assert_cmpstr (names[1], ==, "testicon");
g_assert_cmpstr (names[2], ==, "last");
g_assert_cmpuint (g_icon_hash (icon1), ==, 2400773466U);
g_assert_cmpstr (names[3], ==, "first");
g_assert_cmpstr (names[4], ==, "testicon-symbolic");
g_assert_cmpstr (names[5], ==, "last-symbolic");
g_assert_cmpuint (g_icon_hash (icon1), ==, 1812785139);
icon2 = g_themed_icon_new_from_names ((gchar**)names2, -1);
g_assert (g_icon_equal (icon1, icon2));
@ -448,11 +452,11 @@ test_emblemed_icon (void)
emblem = emblems->data;
g_assert (g_emblem_get_icon (emblem) == icon2);
g_assert (g_emblem_get_origin (emblem) == G_EMBLEM_ORIGIN_TAG);
g_assert (g_emblem_get_origin (emblem) == G_EMBLEM_ORIGIN_UNKNOWN);
emblem = emblems->next->data;
g_assert (g_emblem_get_icon (emblem) == icon2);
g_assert (g_emblem_get_origin (emblem) == G_EMBLEM_ORIGIN_UNKNOWN);
g_assert (g_emblem_get_origin (emblem) == G_EMBLEM_ORIGIN_TAG);
g_emblemed_icon_clear_emblems (G_EMBLEMED_ICON (icon4));
g_assert (g_emblemed_icon_get_emblems (G_EMBLEMED_ICON (icon4)) == NULL);