summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Kukkonen <jku@goto.fi>2014-07-09 13:24:13 +0300
committerJens Georg <mail@jensge.org>2014-07-18 21:20:04 +0200
commitb6e316975e07c99aa56645584707df36b0250425 (patch)
tree971d5d424bb6244fd1c53a16baed9e7d97fe6832
parent1105badf8bb7dfaa468f7fe0f55e9076a95d3f68 (diff)
downloadgupnp-b6e316975e07c99aa56645584707df36b0250425.tar.gz
tests: Add test for #722696 (icon size request issue)
https://bugzilla.gnome.org/show_bug.cgi?id=722696
-rw-r--r--tests/gtest/data/TestDevice.xml23
-rw-r--r--tests/gtest/test-bugs.c62
2 files changed, 85 insertions, 0 deletions
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 @@
<friendlyName>GUPnP Regression Test Device</friendlyName>
<modelURL>http://gupnp.org/</modelURL>
<UDN>uuid:1234</UDN>
+<iconList>
+<icon>
+<mimetype>image/png</mimetype>
+<width>24</width>
+<height>24</height>
+<depth>24</depth>
+<url>/icon-24x24x24.png</url>
+</icon>
+<icon>
+<mimetype>image/png</mimetype>
+<width>48</width>
+<height>48</height>
+<depth>24</depth>
+<url>/icon-48x48x24.png</url>
+</icon>
+<icon>
+<mimetype>image/png</mimetype>
+<width>120</width>
+<height>120</height>
+<depth>24</depth>
+<url>/icon-120x120x24.png</url>
+</icon>
+</iconList>
<serviceList>
<service>
<serviceType>urn:test-gupnp-org:service:TestService:1</serviceType>
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 ();
}