From b6e316975e07c99aa56645584707df36b0250425 Mon Sep 17 00:00:00 2001 From: Jussi Kukkonen Date: Wed, 9 Jul 2014 13:24:13 +0300 Subject: tests: Add test for #722696 (icon size request issue) https://bugzilla.gnome.org/show_bug.cgi?id=722696 --- tests/gtest/data/TestDevice.xml | 23 +++++++++++++++ tests/gtest/test-bugs.c | 62 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) diff --git a/tests/gtest/data/TestDevice.xml b/tests/gtest/data/TestDevice.xml index d210ee2..3d2749c 100644 --- a/tests/gtest/data/TestDevice.xml +++ b/tests/gtest/data/TestDevice.xml @@ -8,6 +8,29 @@ GUPnP Regression Test Device http://gupnp.org/ uuid:1234 + + +image/png +24 +24 +24 +/icon-24x24x24.png + + +image/png +48 +48 +24 +/icon-48x48x24.png + + +image/png +120 +120 +24 +/icon-120x120x24.png + + urn:test-gupnp-org:service:TestService:1 diff --git a/tests/gtest/test-bugs.c b/tests/gtest/test-bugs.c index 38dc08d..8578c26 100644 --- a/tests/gtest/test-bugs.c +++ b/tests/gtest/test-bugs.c @@ -380,6 +380,67 @@ test_bgo_690400 (void) g_object_unref (context); } +/* Test that correct icons are returned for various size requests. + * https://bugzilla.gnome.org/show_bug.cgi?id=722696 */ +static void +test_bgo_722696 (void) +{ + GUPnPContext *context = NULL; + GError *error = NULL; + GUPnPRootDevice *rd; + char *icon; + int width; + + context = gupnp_context_new (NULL, "lo", 0, &error); + g_assert (context != NULL); + g_assert (error == NULL); + + rd = gupnp_root_device_new (context, "TestDevice.xml", DATA_PATH); + + /* prefer bigger */ + width = -1; + icon = gupnp_device_info_get_icon_url (GUPNP_DEVICE_INFO (rd), + NULL, + -1, -1, -1, + TRUE, + NULL, NULL, &width, NULL); + g_assert_cmpint (width, ==, 120); + g_free (icon); + + /* prefer smaller */ + width = -1; + icon = gupnp_device_info_get_icon_url (GUPNP_DEVICE_INFO (rd), + NULL, + -1, -1, -1, + FALSE, + NULL, NULL, &width, NULL); + g_assert_cmpint (width, ==, 24); + g_free (icon); + + /* prefer width <= 119 */ + width = -1; + icon = gupnp_device_info_get_icon_url (GUPNP_DEVICE_INFO (rd), + NULL, + -1, 119, -1, + FALSE, + NULL, NULL, &width, NULL); + g_assert_cmpint (width, ==, 48); + g_free (icon); + + /* prefer width >= 119 */ + width = -1; + icon = gupnp_device_info_get_icon_url (GUPNP_DEVICE_INFO (rd), + NULL, + -1, 119, -1, + TRUE, + NULL, NULL, &width, NULL); + g_assert_cmpint (width, ==, 120); + g_free (icon); + + g_object_unref (rd); + g_object_unref (context); +} + int main (int argc, char *argv[]) { #if !GLIB_CHECK_VERSION(2,35,0) @@ -389,6 +450,7 @@ main (int argc, char *argv[]) { g_test_add_func ("/bugs/696762", test_bgo_696762); g_test_add_func ("/bugs/678701", test_bgo_678701); g_test_add_func ("/bugs/690400", test_bgo_690400); + g_test_add_func ("/bugs/722696", test_bgo_722696); return g_test_run (); } -- cgit v1.2.1