summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorZeeshan Ali <zeenix@gmail.com>2008-06-06 11:42:59 +0000
committerZeeshan Ali <zeenix@gmail.com>2008-06-06 11:42:59 +0000
commitc9b2073c93b64789f5b7628a704cd2c8bc239e04 (patch)
tree1dc7b9805cfa94e6711dd502cf77dbb0bca20188 /tests
parent0713a3cfc6f6f949ecccc17d21f28b7a3703499b (diff)
downloadgupnp-vala-c9b2073c93b64789f5b7628a704cd2c8bc239e04.tar.gz
Fix indentation (4-spaces for Vala) and align the function arguments.
git-svn-id: https://svn.o-hand.com/repos/gupnp/trunk/bindings/gupnp-vala@1035 d8cb91d7-bff9-0310-92b9-80b65e4482b2
Diffstat (limited to 'tests')
-rw-r--r--tests/browsing-test.vala88
-rw-r--r--tests/device-view-test.vala71
-rw-r--r--tests/introspection-test.vala305
-rw-r--r--tests/proxy-test.vala160
-rw-r--r--tests/search-criteria-test.vala94
-rw-r--r--tests/server-test.vala107
-rw-r--r--tests/test-browser.vala52
-rw-r--r--tests/test-publisher.vala44
8 files changed, 464 insertions, 457 deletions
diff --git a/tests/browsing-test.vala b/tests/browsing-test.vala
index e17cd8f..aa250f6 100644
--- a/tests/browsing-test.vala
+++ b/tests/browsing-test.vala
@@ -9,56 +9,56 @@ using GUPnP;
public class Test.BrowsingTest : GLib.Object {
- public static int main (string[] args) {
- GUPnP.Context ctxt;
+ public static int main (string[] args) {
+ GUPnP.Context ctxt;
- try {
- GLib.Thread.init (null);
- ctxt = new Context (null, null, 0);
- } catch (GLib.Error err) {
- GLib.critical (err.message);
- return 1;
- }
+ try {
+ GLib.Thread.init (null);
+ ctxt = new Context (null, null, 0);
+ } catch (GLib.Error err) {
+ GLib.critical (err.message);
+ return 1;
+ }
- /* We're interested in everything */
- GUPnP.ControlPoint cp = new ControlPoint (ctxt, "ssdp:all");
- cp.device_proxy_available += on_device_proxy_available;
- cp.device_proxy_unavailable += on_device_proxy_unavailable;
- cp.service_proxy_available += on_service_proxy_available;
- cp.service_proxy_unavailable += on_service_proxy_unavailable;
- cp.active = true;
+ /* We're interested in everything */
+ GUPnP.ControlPoint cp = new ControlPoint (ctxt, "ssdp:all");
+ cp.device_proxy_available += on_device_proxy_available;
+ cp.device_proxy_unavailable += on_device_proxy_unavailable;
+ cp.service_proxy_available += on_service_proxy_available;
+ cp.service_proxy_unavailable += on_service_proxy_unavailable;
+ cp.active = true;
- GLib.MainLoop loop = new MainLoop (null, false);
- loop.run();
+ GLib.MainLoop loop = new MainLoop (null, false);
+ loop.run();
- return 0;
- }
+ return 0;
+ }
- private static void on_service_proxy_available (GUPnP.ControlPoint cp,
- GUPnP.ServiceProxy proxy) {
- GLib.print ("Service available:\n");
- GLib.print ("\ttype: %s\n", proxy.service_type);
- GLib.print ("\tlocation: %s\n", proxy.location);
- }
+ private static void on_service_proxy_available (GUPnP.ControlPoint cp,
+ GUPnP.ServiceProxy proxy) {
+ GLib.print ("Service available:\n");
+ GLib.print ("\ttype: %s\n", proxy.service_type);
+ GLib.print ("\tlocation: %s\n", proxy.location);
+ }
- private static void on_service_proxy_unavailable (GUPnP.ControlPoint cp,
- GUPnP.ServiceProxy proxy) {
- GLib.print ("Service unavailable:\n");
- GLib.print ("\ttype: %s\n", proxy.service_type);
- GLib.print ("\tlocation: %s\n", proxy.location);
- }
+ private static void on_service_proxy_unavailable (GUPnP.ControlPoint cp,
+ GUPnP.ServiceProxy proxy) {
+ GLib.print ("Service unavailable:\n");
+ GLib.print ("\ttype: %s\n", proxy.service_type);
+ GLib.print ("\tlocation: %s\n", proxy.location);
+ }
- private static void on_device_proxy_available (GUPnP.ControlPoint cp,
- GUPnP.DeviceProxy proxy) {
- GLib.print ("Device available:\n");
- GLib.print ("\ttype: %s\n", proxy.device_type);
- GLib.print ("\tlocation: %s\n", proxy.location);
- }
+ private static void on_device_proxy_available (GUPnP.ControlPoint cp,
+ GUPnP.DeviceProxy proxy) {
+ GLib.print ("Device available:\n");
+ GLib.print ("\ttype: %s\n", proxy.device_type);
+ GLib.print ("\tlocation: %s\n", proxy.location);
+ }
- private static void on_device_proxy_unavailable (GUPnP.ControlPoint cp,
- GUPnP.DeviceProxy proxy) {
- GLib.print ("Device unavailable:\n");
- GLib.print ("\ttype: %s\n", proxy.device_type);
- GLib.print ("\tlocation: %s\n", proxy.location);
- }
+ private static void on_device_proxy_unavailable (GUPnP.ControlPoint cp,
+ GUPnP.DeviceProxy proxy) {
+ GLib.print ("Device unavailable:\n");
+ GLib.print ("\ttype: %s\n", proxy.device_type);
+ GLib.print ("\tlocation: %s\n", proxy.location);
+ }
}
diff --git a/tests/device-view-test.vala b/tests/device-view-test.vala
index ae1ca6b..7aba209 100644
--- a/tests/device-view-test.vala
+++ b/tests/device-view-test.vala
@@ -4,43 +4,44 @@ using GUPnP;
public class Test.DeviceViewTest : Window {
- construct {
- title = "GUPnP DeviceView Test";
- resize (400, 300);
- destroy += Gtk.main_quit;
-
- /* Init GUPnP stuff */
- Context ctxt;
- try {
- GLib.Thread.init (null);
- ctxt = new Context (null, null, 0);
- } catch (GLib.Error err) {
- GLib.critical (err.message);
- Gtk.main_quit ();
- }
- ControlPoint cp = new ControlPoint (ctxt, "upnp:rootdevice");
- cp.active = true;
-
- /* Create a ScrolledWindow for the UIDeviceView */
- var scroll_win = new ScrolledWindow (null, null);
- scroll_win.set_policy (PolicyType.AUTOMATIC,
- PolicyType.ALWAYS);
- scroll_win.set_shadow_type (ShadowType.IN);
- add (scroll_win);
-
- /* Set up store and view */
- UIDeviceStore store = new UIDeviceStore (cp);
- UIDeviceView view = new UIDeviceView (store);
- scroll_win.add (view);
+ construct {
+ title = "GUPnP DeviceView Test";
+ resize (400, 300);
+ destroy += Gtk.main_quit;
+
+ /* Init GUPnP stuff */
+ Context ctxt;
+ try {
+ GLib.Thread.init (null);
+ ctxt = new Context (null, null, 0);
+ } catch (GLib.Error err) {
+ GLib.critical (err.message);
+ Gtk.main_quit ();
}
- static int main (string[] args) {
- Gtk.init (ref args);
+ ControlPoint cp = new ControlPoint (ctxt, "upnp:rootdevice");
+ cp.active = true;
- var test = new DeviceViewTest ();
- test.show_all ();
- Gtk.main ();
+ /* Create a ScrolledWindow for the UIDeviceView */
+ var scroll_win = new ScrolledWindow (null, null);
+ scroll_win.set_policy (PolicyType.AUTOMATIC,
+ PolicyType.ALWAYS);
+ scroll_win.set_shadow_type (ShadowType.IN);
+ add (scroll_win);
- return 0;
- }
+ /* Set up store and view */
+ UIDeviceStore store = new UIDeviceStore (cp);
+ UIDeviceView view = new UIDeviceView (store);
+ scroll_win.add (view);
+ }
+
+ static int main (string[] args) {
+ Gtk.init (ref args);
+
+ var test = new DeviceViewTest ();
+ test.show_all ();
+ Gtk.main ();
+
+ return 0;
+ }
}
diff --git a/tests/introspection-test.vala b/tests/introspection-test.vala
index 337b5c3..18b4c42 100644
--- a/tests/introspection-test.vala
+++ b/tests/introspection-test.vala
@@ -8,170 +8,175 @@ using GUPnP;
*/
public class Test.IntrospectionTest : Object {
- private static bool async = false;
-
- private const OptionEntry[] entries = {
- { "async", 'a', 0, OptionArg.NONE, ref async, "Create introspection object asynchronously", null },
- { null }
- };
-
- public static int main (string[] args) {
- IntrospectionTest test = new IntrospectionTest();
- return test.run (args);
- }
-
- private int run (string[] args) {
- GUPnP.Context ctxt;
-
- /* handle command line options */
- try {
- OptionContext options = new OptionContext
- ("- GUPnP introspection test program (Vala version)");
- options.add_main_entries (entries, null);
- options.parse (ref args);
- } catch (OptionError err) {
- error ("Error while parsing commandline arguments: %s",
- err.message);
- }
-
- try {
- Thread.init (null);
- ctxt = new Context (null, null, 0);
- } catch (Error err) {
- critical (err.message);
- return 1;
- }
-
- /* We're interested in everything */
- GUPnP.ControlPoint cp = new ControlPoint (ctxt, "ssdp:all");
- cp.service_proxy_available += on_service_proxy_available;
- cp.active = true;
-
- GLib.MainLoop loop = new MainLoop (null, false);
- loop.run();
-
- return 0;
+ private static bool async = false;
+
+ private const OptionEntry[] entries = {
+ { "async",
+ 'a',
+ 0,
+ OptionArg.NONE,
+ ref async,
+ "Create introspection object asynchronously",
+ null },
+ { null }
+ };
+
+ public static int main (string[] args) {
+ IntrospectionTest test = new IntrospectionTest();
+ return test.run (args);
+ }
+
+ private int run (string[] args) {
+ GUPnP.Context ctxt;
+
+ /* handle command line options */
+ try {
+ OptionContext options = new OptionContext
+ ("- GUPnP introspection test program (Vala version)");
+ options.add_main_entries (entries, null);
+ options.parse (ref args);
+ } catch (OptionError err) {
+ error ("Error while parsing commandline arguments: %s",
+ err.message);
}
- private void on_service_proxy_available (GUPnP.ControlPoint cp,
- GUPnP.ServiceProxy proxy) {
- if (async) {
- /* this will result in C compiler warning because
- * there's no way to make the callback signature have
- * "const GError" argument in Vala */
- proxy.get_introspection_async (on_get_introspection);
- } else {
- try {
- print ("service: %s\nlocation: %s\n",
- proxy.udn, proxy.location);
-
- GUPnP.ServiceIntrospection introspection =
- proxy.get_introspection ();
- print_state_variables (introspection);
- print_actions (introspection);
- } catch (Error err) {
- warning ("Failed to create introspection for '%s': %s",
- proxy.udn, err.message);
- }
- }
+ try {
+ Thread.init (null);
+ ctxt = new Context (null, null, 0);
+ } catch (Error err) {
+ critical (err.message);
+ return 1;
}
- private void on_get_introspection (GUPnP.ServiceInfo info,
- GUPnP.ServiceIntrospection introspection,
- Error err) {
+ /* We're interested in everything */
+ GUPnP.ControlPoint cp = new ControlPoint (ctxt, "ssdp:all");
+ cp.service_proxy_available += on_service_proxy_available;
+ cp.active = true;
+
+ GLib.MainLoop loop = new MainLoop (null, false);
+ loop.run();
+
+ return 0;
+ }
+
+ private void on_service_proxy_available (GUPnP.ControlPoint cp,
+ GUPnP.ServiceProxy proxy) {
+ if (async) {
+ /* this will result in C compiler warning because
+ * there's no way to make the callback signature have
+ * "const GError" argument in Vala */
+ proxy.get_introspection_async (on_get_introspection);
+ } else {
+ try {
print ("service: %s\nlocation: %s\n",
- info.udn, info.location);
-
- if (err != null) {
- warning ("Failed to create introspection for '%s': %s",
- info.udn, err.message);
- } else {
- print_state_variables (introspection);
- print_actions (introspection);
- }
+ proxy.udn, proxy.location);
+
+ GUPnP.ServiceIntrospection introspection =
+ proxy.get_introspection ();
+ print_state_variables (introspection);
+ print_actions (introspection);
+ } catch (Error err) {
+ warning ("Failed to create introspection for '%s': %s",
+ proxy.udn, err.message);
+ }
}
+ }
+
+ private void on_get_introspection (GUPnP.ServiceInfo info,
+ GUPnP.ServiceIntrospection introspection,
+ Error err) {
+ print ("service: %s\nlocation: %s\n",
+ info.udn, info.location);
+
+ if (err != null) {
+ warning ("Failed to create introspection for '%s': %s",
+ info.udn, err.message);
+ } else {
+ print_state_variables (introspection);
+ print_actions (introspection);
+ }
+ }
- private void print_state_variables (GUPnP.ServiceIntrospection introspection) {
- /* this will result in C compiler warning since the return value
- is actually "_const_ GList*", and Vala can't express that. */
- weak List<ServiceStateVariableInfo> variables =
- introspection.list_state_variables ();
+ private void print_state_variables (GUPnP.ServiceIntrospection introspection) {
+ /* this will result in C compiler warning since the return value
+ is actually "_const_ GList*", and Vala can't express that. */
+ weak List<ServiceStateVariableInfo> variables =
+ introspection.list_state_variables ();
- if (variables != null) {
- print ("State variables:\n");
- }
+ if (variables != null) {
+ print ("State variables:\n");
+ }
- foreach (weak ServiceStateVariableInfo var_info in variables) {
- print ("\tstate variable: %s\n" +
- "\t\ttype: %s\n" +
- "\t\tsend events: %s\n",
- var_info.name,
- var_info.type.name (),
- var_info.send_events? "yes": "no");
-
- Value def_val = Value (typeof (string));
- if (var_info.default_value.transform (ref def_val)) {
- weak string str = def_val.get_string ();
- if (str != null)
- print ("\t\tdefault value: %s\n", str);
- }
- def_val.unset ();
-
- if (var_info.is_numeric) {
- Value min = Value (typeof (string));
- Value max = Value (typeof (string));
- Value step = Value (typeof (string));
-
- var_info.minimum.transform (ref min);
- var_info.maximum.transform (ref max);
- var_info.step.transform (ref step);
-
- print ("\t\tminimum: %s\n" +
- "\t\tmaximum: %s\n" +
- "\t\tstep: %s\n",
- min.get_string(),
- max.get_string(),
- step.get_string());
-
- min.unset ();
- max.unset ();
- step.unset ();
- }
-
- if (var_info.allowed_values != null) {
- print ("\t\tallowed values: ");
- weak List<string> l = var_info.allowed_values;
- foreach (string val in l) {
- print ("\"%s\" ", val);
- }
- print ("\n");
- }
+ foreach (weak ServiceStateVariableInfo var_info in variables) {
+ print ("\tstate variable: %s\n" +
+ "\t\ttype: %s\n" +
+ "\t\tsend events: %s\n",
+ var_info.name,
+ var_info.type.name (),
+ var_info.send_events? "yes": "no");
+
+ Value def_val = Value (typeof (string));
+ if (var_info.default_value.transform (ref def_val)) {
+ weak string str = def_val.get_string ();
+ if (str != null)
+ print ("\t\tdefault value: %s\n", str);
+ }
+ def_val.unset ();
+
+ if (var_info.is_numeric) {
+ Value min = Value (typeof (string));
+ Value max = Value (typeof (string));
+ Value step = Value (typeof (string));
+
+ var_info.minimum.transform (ref min);
+ var_info.maximum.transform (ref max);
+ var_info.step.transform (ref step);
+
+ print ("\t\tminimum: %s\n" +
+ "\t\tmaximum: %s\n" +
+ "\t\tstep: %s\n",
+ min.get_string(),
+ max.get_string(),
+ step.get_string());
+
+ min.unset ();
+ max.unset ();
+ step.unset ();
+ }
+
+ if (var_info.allowed_values != null) {
+ print ("\t\tallowed values: ");
+ weak List<string> l = var_info.allowed_values;
+ foreach (string val in l) {
+ print ("\"%s\" ", val);
}
+ print ("\n");
+ }
}
+ }
- private void print_actions (GUPnP.ServiceIntrospection introspection) {
- /* this will result in C compiler warning since the return value
- is actually "_const_ GList*", and Vala can't express that. */
- weak List<ServiceActionInfo> actions =
- introspection.list_actions ();
+ private void print_actions (GUPnP.ServiceIntrospection introspection) {
+ /* this will result in C compiler warning since the return value
+ is actually "_const_ GList*", and Vala can't express that. */
+ weak List<ServiceActionInfo> actions = introspection.list_actions ();
- if (actions != null) {
- print ("Actions:\n");
- }
+ if (actions != null) {
+ print ("Actions:\n");
+ }
- foreach (weak ServiceActionInfo action_info in actions) {
- print ("\taction: %s\n", action_info.name);
-
- weak List<ServiceActionArgInfo> l = action_info.arguments;
- foreach (weak ServiceActionArgInfo arg_info in l) {
- print ("\t\targument: %s\n" +
- "\t\t\tdirection: %s\n" +
- "\t\t\trelated state variable: %s\n\n",
- arg_info.name,
- (arg_info.direction == ServiceActionArgDirection.IN) ? "in":"out",
- arg_info.related_state_variable);
- }
- }
+ foreach (weak ServiceActionInfo action_info in actions) {
+ print ("\taction: %s\n", action_info.name);
+
+ weak List<ServiceActionArgInfo> l = action_info.arguments;
+ foreach (weak ServiceActionArgInfo arg_info in l) {
+ print ("\t\targument: %s\n" +
+ "\t\t\tdirection: %s\n" +
+ "\t\t\trelated state variable: %s\n\n",
+ arg_info.name,
+ (arg_info.direction == ServiceActionArgDirection.IN) ? "in":"out",
+ arg_info.related_state_variable);
+ }
}
+ }
}
diff --git a/tests/proxy-test.vala b/tests/proxy-test.vala
index 213bf34..78d0481 100644
--- a/tests/proxy-test.vala
+++ b/tests/proxy-test.vala
@@ -9,87 +9,87 @@ using GUPnP;
public class Test.ProxyTest : GLib.Object {
- public static int main (string[] args) {
- GUPnP.Context ctxt;
-
- try {
- GLib.Thread.init (null);
- ctxt = new Context (null, null, 0);
- } catch (GLib.Error err) {
- GLib.critical (err.message);
- return 1;
- }
-
- GUPnP.ControlPoint cp = new ControlPoint
- (ctxt, "urn:schemas-upnp-org:service:ContentDirectory:1");
- cp.service_proxy_available += on_service_proxy_available;
- cp.service_proxy_unavailable += on_service_proxy_unavailable;
- cp.active = true;
-
- GLib.MainLoop loop = new MainLoop (null, false);
- loop.run();
-
- return 0;
+ public static int main (string[] args) {
+ GUPnP.Context ctxt;
+
+ try {
+ GLib.Thread.init (null);
+ ctxt = new Context (null, null, 0);
+ } catch (GLib.Error err) {
+ GLib.critical (err.message);
+ return 1;
}
- private static void on_service_proxy_available (GUPnP.ControlPoint cp,
- GUPnP.ServiceProxy proxy) {
- GLib.print ("ContentDirectory available:\n");
- GLib.print ("\tlocation: %s\n", proxy.location);
-
- /* We want to be notified whenever SystemUpdateID changes */
- proxy.add_notify ("SystemUpdateID", typeof (uint), on_notify);
-
- /* subscribe */
- proxy.subscription_lost += on_subscription_lost;
- proxy.subscribed = true;
-
- /* test action IO */
- try {
- string result;
- uint count, total;
-
- proxy.send_action
- ("Browse",
- /* IN args */
- "ObjectID", typeof (string), "0",
- "BrowseFlag", typeof (string), "BrowseDirectChildren",
- "Filter", typeof (string), "*",
- "StartingIndex", typeof (uint), 0,
- "RequestedCount", typeof (uint), 0,
- "SortCriteria", typeof (string), "",
- null,
- /* OUT args */
- "Result", typeof (string), out result,
- "NumberReturned", typeof (uint), out count,
- "TotalMatches", typeof (uint), out total,
- null);
- GLib.print ("Browse returned:\n");
- GLib.print ("\tResult: %s\n", result);
- GLib.print ("\tNumberReturned: %u\n", count);
- GLib.print ("\tTotalMatches: %u\n", total);
- } catch (GLib.Error err) {
- GLib.printerr ("Error: %s\n", err.message);
- }
- }
-
- private static void on_service_proxy_unavailable (GUPnP.ControlPoint cp,
- GUPnP.ServiceProxy proxy) {
- GLib.print ("ContentDirectory unavailable:\n");
- GLib.print ("\tlocation: %s\n", proxy.location);
- }
-
- private static void on_notify (GUPnP.ServiceProxy proxy,
- string variable,
- GLib.Value value) {
- GLib.print ("Received a notification for variable '%s':\n",
- variable);
- GLib.print ("\tvalue: %d\n", value.get_uint);
- }
-
- private static void on_subscription_lost (GUPnP.ServiceProxy proxy,
- GLib.Error reason) {
- GLib.print ("Lost subscription: %s\n", reason.message);
-
+ GUPnP.ControlPoint cp = new ControlPoint
+ (ctxt, "urn:schemas-upnp-org:service:ContentDirectory:1");
+ cp.service_proxy_available += on_service_proxy_available;
+ cp.service_proxy_unavailable += on_service_proxy_unavailable;
+ cp.active = true;
+
+ GLib.MainLoop loop = new MainLoop (null, false);
+ loop.run();
+
+ return 0;
+ }
+
+ private static void on_service_proxy_available (GUPnP.ControlPoint cp,
+ GUPnP.ServiceProxy proxy) {
+ GLib.print ("ContentDirectory available:\n");
+ GLib.print ("\tlocation: %s\n", proxy.location);
+
+ /* We want to be notified whenever SystemUpdateID changes */
+ proxy.add_notify ("SystemUpdateID", typeof (uint), on_notify);
+
+ /* subscribe */
+ proxy.subscription_lost += on_subscription_lost;
+ proxy.subscribed = true;
+
+ /* test action IO */
+ try {
+ string result;
+ uint count, total;
+
+ proxy.send_action
+ ("Browse",
+ /* IN args */
+ "ObjectID", typeof (string), "0",
+ "BrowseFlag", typeof (string), "BrowseDirectChildren",
+ "Filter", typeof (string), "*",
+ "StartingIndex", typeof (uint), 0,
+ "RequestedCount", typeof (uint), 0,
+ "SortCriteria", typeof (string), "",
+ null,
+ /* OUT args */
+ "Result", typeof (string), out result,
+ "NumberReturned", typeof (uint), out count,
+ "TotalMatches", typeof (uint), out total,
+ null);
+ GLib.print ("Browse returned:\n");
+ GLib.print ("\tResult: %s\n", result);
+ GLib.print ("\tNumberReturned: %u\n", count);
+ GLib.print ("\tTotalMatches: %u\n", total);
+ } catch (GLib.Error err) {
+ GLib.printerr ("Error: %s\n", err.message);
}
+ }
+
+ private static void on_service_proxy_unavailable (GUPnP.ControlPoint cp,
+ GUPnP.ServiceProxy proxy) {
+ GLib.print ("ContentDirectory unavailable:\n");
+ GLib.print ("\tlocation: %s\n", proxy.location);
+ }
+
+ private static void on_notify (GUPnP.ServiceProxy proxy,
+ string variable,
+ GLib.Value value) {
+ GLib.print ("Received a notification for variable '%s':\n",
+ variable);
+ GLib.print ("\tvalue: %d\n", value.get_uint);
+ }
+
+ private static void on_subscription_lost (GUPnP.ServiceProxy proxy,
+ GLib.Error reason) {
+ GLib.print ("Lost subscription: %s\n", reason.message);
+
+ }
}
diff --git a/tests/search-criteria-test.vala b/tests/search-criteria-test.vala
index cd529f5..c14d9a1 100644
--- a/tests/search-criteria-test.vala
+++ b/tests/search-criteria-test.vala
@@ -5,65 +5,65 @@ using GUPnP;
* Usage:
* ./search-criteria-test "<search string>"
* Example
- ./search-criteria-test \
- "upnp:class = \"object.container.person.musicArtist\" \
- and (@refID exists false or dc:title contains 'foo')"
+ ./search-criteria-test \
+ "upnp:class = \"object.container.person.musicArtist\" \
+ and (@refID exists false or dc:title contains 'foo')"
*/
public class Test.SearchCriteriaTest : Object {
- public static int main (string[] args) {
- if (args.length != 2) {
- print ("Usage:\n");
- print ("\t%s \"<search string>\"\n", args[0]);
- print ("Example:\n");
- print ("\t%s \"dc:title contains 'foo'\"\n", args[0]);
- return 1;
- }
- SearchCriteriaTest test = new SearchCriteriaTest ();
- return test.parse (args[1]);
+ public static int main (string[] args) {
+ if (args.length != 2) {
+ print ("Usage:\n");
+ print ("\t%s \"<search string>\"\n", args[0]);
+ print ("Example:\n");
+ print ("\t%s \"dc:title contains 'foo'\"\n", args[0]);
+ return 1;
}
+ SearchCriteriaTest test = new SearchCriteriaTest ();
+ return test.parse (args[1]);
+ }
- private int parse (string str) {
+ private int parse (string str) {
- var parser = new SearchCriteriaParser ();
- parser.expression += on_expression;
- parser.conjunction += on_conjunction;
- parser.disjunction += on_disjunction;
- parser.begin_parens += on_begin_parens;
- parser.end_parens += on_end_parens;
+ var parser = new SearchCriteriaParser ();
+ parser.expression += on_expression;
+ parser.conjunction += on_conjunction;
+ parser.disjunction += on_disjunction;
+ parser.begin_parens += on_begin_parens;
+ parser.end_parens += on_end_parens;
- try {
- parser.parse_text (str);
- } catch (Error err) {
- printerr ("Parse error:%s\n", err.message);
- }
- print ("\n");
- return 0;
+ try {
+ parser.parse_text (str);
+ } catch (Error err) {
+ printerr ("Parse error:%s\n", err.message);
}
+ print ("\n");
+ return 0;
+ }
- private bool on_expression (SearchCriteriaParser parser,
- string property,
- uint op,
- string value,
- Error error) {
- print ("%s OP%d %s", property, op, value);
- return true;
- }
+ private bool on_expression (SearchCriteriaParser parser,
+ string property,
+ uint op,
+ string value,
+ Error error) {
+ print ("%s OP%d %s", property, op, value);
+ return true;
+ }
- private void on_conjunction (SearchCriteriaParser parser) {
- print (" AND ");
- }
+ private void on_conjunction (SearchCriteriaParser parser) {
+ print (" AND ");
+ }
- private void on_disjunction (SearchCriteriaParser parser) {
- print (" OR ");
- }
+ private void on_disjunction (SearchCriteriaParser parser) {
+ print (" OR ");
+ }
- private void on_begin_parens (SearchCriteriaParser parser) {
- print ("(");
- }
+ private void on_begin_parens (SearchCriteriaParser parser) {
+ print ("(");
+ }
- private void on_end_parens (SearchCriteriaParser parser) {
- print (")");
- }
+ private void on_end_parens (SearchCriteriaParser parser) {
+ print (")");
+ }
}
diff --git a/tests/server-test.vala b/tests/server-test.vala
index 266fd31..40fe55f 100644
--- a/tests/server-test.vala
+++ b/tests/server-test.vala
@@ -10,71 +10,72 @@ using GUPnP;
*/
public class Test.ServerTest : GLib.Object {
- GUPnP.Service content_dir;
-
- public static int main (string[] args) {
- Test.ServerTest test = new ServerTest ();
- return test.run (args);
+ GUPnP.Service content_dir;
+
+ public static int main (string[] args) {
+ Test.ServerTest test = new ServerTest ();
+ return test.run (args);
+ }
+
+ private int run (string[] args) {
+ GUPnP.Context ctxt;
+
+ try {
+ GLib.Thread.init (null);
+ ctxt = new Context (null, null, 0);
+ } catch (GLib.Error err) {
+ GLib.critical (err.message);
+ return 1;
}
- private int run (string[] args) {
- GUPnP.Context ctxt;
-
- try {
- GLib.Thread.init (null);
- ctxt = new Context (null, null, 0);
- } catch (GLib.Error err) {
- GLib.critical (err.message);
- return 1;
- }
+ GLib.print ("Running on port %d\n", ctxt.port);
- GLib.print ("Running on port %d\n", ctxt.port);
+ /* Host current directory */
+ ctxt.host_path (".", "");
- /* Host current directory */
- ctxt.host_path (".", "");
+ /* Parse device description file */
+ Xml.Doc *doc = Xml.Parser.parse_file ("description.xml");
- /* Parse device description file */
- Xml.Doc *doc = Xml.Parser.parse_file ("description.xml");
-
- /* Create root device. Needs description.xml in working directory */
- GUPnP.RootDevice dev = new RootDevice (ctxt, "/description.xml");
- if (dev == null) {
- GLib.critical ("Creating root device failed");
- return 1;
- }
+ /* Create root device. Needs description.xml in working directory */
+ GUPnP.RootDevice dev = new RootDevice (ctxt, "/description.xml");
+ if (dev == null) {
+ GLib.critical ("Creating root device failed");
+ return 1;
+ }
- /* Implement Browse action on ContentDirectory if available */
- content_dir =
- (GUPnP.Service) dev.get_service (
- "urn:schemas-upnp-org:service:ContentDirectory");
- if (content_dir != null) {
+ /* Implement Browse action on ContentDirectory if available */
+ content_dir =
+ (GUPnP.Service) dev.get_service (
+ "urn:schemas-upnp-org:service:ContentDirectory");
+ if (content_dir != null) {
- warning ("Service signal handling not implemented yet\n");
- /* TODO: connect service signal handlers */
-
+ warning ("Service signal handling not implemented yet\n");
+ /* TODO: connect service signal handlers */
- content_dir.notify_failed += on_notify_failed;
- GLib.Timeout.add (5000, timeout);
- }
+ content_dir.notify_failed += on_notify_failed;
+ GLib.Timeout.add (5000, timeout);
+ }
- dev.available = true;
+ dev.available = true;
- GLib.MainLoop loop = new MainLoop (null, false);
- loop.run();
+ GLib.MainLoop loop = new MainLoop (null, false);
+ loop.run();
- return 0;
- }
+ return 0;
+ }
- private void on_notify_failed (GUPnP.Service service,
- GLib.List callback_url,
- GLib.Error reason) {
- GLib.print ("NOTIFY failed: %s\n", reason.message);
- }
+ private void on_notify_failed (GUPnP.Service service,
+ GLib.List callback_url,
+ GLib.Error reason) {
+ GLib.print ("NOTIFY failed: %s\n", reason.message);
+ }
- private bool timeout () {
- content_dir.notify ("SystemUpdateID", typeof (uint) ,27182818,
- null);
- return false;
- }
+ private bool timeout () {
+ content_dir.notify ("SystemUpdateID",
+ typeof (uint),
+ 27182818,
+ null);
+ return false;
+ }
}
diff --git a/tests/test-browser.vala b/tests/test-browser.vala
index adc04e8..772c03e 100644
--- a/tests/test-browser.vala
+++ b/tests/test-browser.vala
@@ -3,40 +3,40 @@ using GSSDP;
public class TestBrowser : ResourceBrowser {
- private void on_resource_available (TestBrowser browser,
- string usn,
- GLib.List<string> locations) {
- GLib.print ("Resource available:\n USN: %s\n", usn);
- for (weak List l = locations; l != null; l = l.next) {
- GLib.print (" Location: %s\n", l.data);
- }
+ private void on_resource_available (TestBrowser browser,
+ string usn,
+ GLib.List<string> locations) {
+ GLib.print ("Resource available:\n USN: %s\n", usn);
+ for (weak List l = locations; l != null; l = l.next) {
+ GLib.print (" Location: %s\n", l.data);
}
+ }
- private void on_resource_unavailable (TestBrowser browser,
- string usn) {
- GLib.print ("Resource unavailable:\n USN: %s\n", usn);
- }
+ private void on_resource_unavailable (TestBrowser browser,
+ string usn) {
+ GLib.print ("Resource unavailable:\n USN: %s\n", usn);
+ }
- construct {
- this.resource_available += this.on_resource_available;
- this.resource_unavailable += this.on_resource_unavailable;
- }
+ construct {
+ this.resource_available += this.on_resource_available;
+ this.resource_unavailable += this.on_resource_unavailable;
+ }
- public TestBrowser() {
- this.client = new Client (null);
- this.target = GSSDP.ALL_RESOURCES;
- }
+ public TestBrowser() {
+ this.client = new Client (null);
+ this.target = GSSDP.ALL_RESOURCES;
+ }
- public static int main (string[] args) {
- TestBrowser browser = new TestBrowser ();
+ public static int main (string[] args) {
+ TestBrowser browser = new TestBrowser ();
- browser.active = true;
+ browser.active = true;
- GLib.MainLoop loop = new MainLoop (null, false);
- loop.run();
+ GLib.MainLoop loop = new MainLoop (null, false);
+ loop.run();
- return 0;
- }
+ return 0;
+ }
}
diff --git a/tests/test-publisher.vala b/tests/test-publisher.vala
index 6131adc..eee21e4 100644
--- a/tests/test-publisher.vala
+++ b/tests/test-publisher.vala
@@ -2,32 +2,32 @@ using GLib;
using GSSDP;
public class TestPublisher : ResourceGroup {
- public string resource_type { get; set construct; }
- public string usn { get; set construct; }
- public string location { get; set construct; }
+ public string resource_type { get; set construct; }
+ public string usn { get; set construct; }
+ public string location { get; set construct; }
- construct {
- this.add_resource_simple (this.resource_type,
- this.usn,
- this.location);
- }
+ construct {
+ this.add_resource_simple (this.resource_type,
+ this.usn,
+ this.location);
+ }
- public TestPublisher() {
- this.client = new Client (null);
- this.resource_type = "upnp:rootdevice";
- this.usn = "uuid:1234abcd-12ab-12ab-12ab-1234567abc12" +
- "::upnp:rootdevice";
- this.location = "http://192.168.1.100/";
- }
+ public TestPublisher() {
+ this.client = new Client (null);
+ this.resource_type = "upnp:rootdevice";
+ this.usn = "uuid:1234abcd-12ab-12ab-12ab-1234567abc12" +
+ "::upnp:rootdevice";
+ this.location = "http://192.168.1.100/";
+ }
- public static int main (string[] args) {
- TestPublisher publisher = new TestPublisher ();
+ public static int main (string[] args) {
+ TestPublisher publisher = new TestPublisher ();
- publisher.available = true;
+ publisher.available = true;
- GLib.MainLoop loop = new MainLoop (null, false);
- loop.run();
+ GLib.MainLoop loop = new MainLoop (null, false);
+ loop.run();
- return 0;
- }
+ return 0;
+ }
}