2 * Copyright (C) 2013 Intel Corporation.
4 * Author: Jens Georg <jensg@openismus.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
26 #include <libgupnp/gupnp.h>
29 struct _GUPnPServiceAction {
30 volatile gint ref_count;
32 GUPnPContext *context;
42 GString *response_str;
47 typedef struct _TestBgo696762Data {
49 GUPnPServiceProxy *proxy;
53 test_bgo_696762_on_browse_call (G_GNUC_UNUSED GUPnPService *service,
54 G_GNUC_UNUSED GUPnPServiceAction *action,
55 G_GNUC_UNUSED gpointer user_data)
57 xmlNode *node = action->node->children;
58 g_assert (node != NULL);
59 g_assert_cmpstr ((const char *) node->name, ==, "ObjectID");
62 g_assert (node != NULL);
63 g_assert_cmpstr ((const char *) node->name, ==, "BrowseFlag");
66 g_assert (node != NULL);
67 g_assert_cmpstr ((const char *) node->name, ==, "Filter");
70 g_assert (node != NULL);
71 g_assert_cmpstr ((const char *) node->name, ==, "StartingIndex");
74 g_assert (node != NULL);
75 g_assert_cmpstr ((const char *) node->name, ==, "RequestedCount");
78 g_assert (node != NULL);
79 g_assert_cmpstr ((const char *) node->name, ==, "SortCriteria");
81 gupnp_service_action_return (action);
85 test_bgo_696762_on_browse (G_GNUC_UNUSED GUPnPServiceProxy *proxy,
86 G_GNUC_UNUSED GUPnPServiceProxyAction *action,
89 TestBgo696762Data *data = (TestBgo696762Data *) user_data;
91 g_main_loop_quit (data->loop);
95 test_bgo_696762_on_sp_available (G_GNUC_UNUSED GUPnPControlPoint *cp,
96 GUPnPServiceProxy *proxy,
99 TestBgo696762Data *data = (TestBgo696762Data *) user_data;
101 data->proxy = g_object_ref (proxy);
103 g_main_loop_quit (data->loop);
107 test_bgo_696762_on_timeout (G_GNUC_UNUSED gpointer user_data)
109 g_assert_not_reached ();
114 /* Test if a call on a service proxy keeps argument order */
116 test_bgo_696762 (void)
118 GUPnPContext *context = NULL;
119 GError *error = NULL;
120 GUPnPControlPoint *cp = NULL;
121 guint timeout_id = 0;
123 TestBgo696762Data data = { NULL, NULL };
124 GUPnPServiceInfo *info = NULL;
126 data.loop = g_main_loop_new (NULL, FALSE);
128 context = gupnp_context_new (NULL, "lo", 0, &error);
129 g_assert (context != NULL);
130 g_assert (error == NULL);
132 cp = gupnp_control_point_new (context,
133 "urn:test-gupnp-org:service:bgo696762:1");
135 gssdp_resource_browser_set_active (GSSDP_RESOURCE_BROWSER (cp), TRUE);
137 g_signal_connect (G_OBJECT (cp),
138 "service-proxy-available",
139 G_CALLBACK (test_bgo_696762_on_sp_available),
143 rd = gupnp_root_device_new (context, "TestBgo696762.xml", DATA_PATH);
144 gupnp_root_device_set_available (rd, TRUE);
145 info = gupnp_device_info_get_service (GUPNP_DEVICE_INFO (rd),
146 "urn:test-gupnp-org:service:bgo696762:1");
147 g_signal_connect (G_OBJECT (info),
148 "action-invoked::Browse",
149 G_CALLBACK (test_bgo_696762_on_browse_call),
152 timeout_id = g_timeout_add_seconds (2, test_bgo_696762_on_timeout, &(data.loop));
153 g_main_loop_run (data.loop);
154 g_source_remove (timeout_id);
155 g_assert (data.proxy != NULL);
157 gupnp_service_proxy_begin_action (data.proxy,
159 test_bgo_696762_on_browse,
161 "ObjectID", G_TYPE_STRING, "0",
162 "BrowseFlag", G_TYPE_STRING, "BrowseDirectChildren",
163 "Filter", G_TYPE_STRING, "res,dc:date,res@size",
164 "StartingIndex", G_TYPE_UINT, 0,
165 "RequestedCount", G_TYPE_UINT, 0,
166 "SortCriteria", G_TYPE_STRING, "",
169 timeout_id = g_timeout_add_seconds (2, test_bgo_696762_on_timeout, &(data.loop));
170 g_main_loop_run (data.loop);
171 g_source_remove (timeout_id);
175 main (int argc, char *argv[]) {
176 #if !GLIB_CHECK_VERSION(2,35,0)
179 g_test_init (&argc, &argv, NULL);
180 g_test_add_func ("/bugs/696762", test_bgo_696762);
182 return g_test_run ();