[rygel] build,tests: First unit test
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] build,tests: First unit test
- Date: Sat, 13 Mar 2010 02:09:40 +0000 (UTC)
commit 5c7fa51308bc048c634ecc4df973692532e3f70d
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Sun Mar 7 21:48:17 2010 +0200
build,tests: First unit test
Add unit test for HTTPItemURI. This also includes the needed build setup.
Makefile.am | 2 +-
configure.ac | 1 +
tests/Makefile.am | 33 +++++++++++
tests/rygel-http-item-uri-test.vala | 102 +++++++++++++++++++++++++++++++++++
tests/rygel-http-item-uri.vala | 1 +
5 files changed, 138 insertions(+), 1 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 412fdc7..88969b0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = src data
+SUBDIRS = src data tests
pkgconfig_DATA= rygel-1.0.pc
pkgconfigdir = $(libdir)/pkgconfig
diff --git a/configure.ac b/configure.ac
index da72d30..eaa695a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -273,6 +273,7 @@ src/plugins/test/Makefile
data/Makefile
data/xml/Makefile
rygel-1.0.pc
+tests/Makefile
])
echo "
diff --git a/tests/Makefile.am b/tests/Makefile.am
new file mode 100644
index 0000000..1aa18f9
--- /dev/null
+++ b/tests/Makefile.am
@@ -0,0 +1,33 @@
+shareddir = $(abs_top_builddir)/data
+
+AM_CFLAGS = $(LIBGUPNP_CFLAGS) \
+ $(LIBGUPNP_AV_CFLAGS) \
+ $(LIBGSTREAMER_CFLAGS) \
+ $(GIO_CFLAGS) \
+ $(GEE_CFLAGS) \
+ $(UUID_CFLAGS) \
+ $(LIBSOUP_CFLAGS) \
+ $(LIBDBUS_GLIB_CFLAGS) \
+ -I$(top_srcdir) -DDATA_DIR='"$(shareddir)"' \
+ -include config.h
+
+AM_VALAFLAGS = --thread \
+ --pkg gupnp-1.0 --pkg gupnp-av-1.0 --pkg dbus-glib-1 \
+ --pkg gconf-2.0 --pkg gstreamer-0.10 \
+ --pkg gio-2.0 --pkg gee-1.0 -g
+
+check_PROGRAMS = rygel-http-item-uri-test
+TESTS = $(check_PROGRAMS)
+
+rygel_http_item_uri_test_SOURCES = rygel-http-item-uri-test.vala \
+ rygel-http-item-uri.vala
+
+rygel_http_item_uri_test_LDADD = $(LIBGUPNP_LIBS) \
+ $(LIBGUPNP_AV_LIBS) \
+ $(LIBGSTREAMER_LIBS) \
+ $(GIO_LIBS) \
+ $(GEE_LIBS) \
+ $(UUID_LIBS) \
+ $(LIBSOUP_LIBS) \
+ $(LIBDBUS_GLIB_LIBS)
+
diff --git a/tests/rygel-http-item-uri-test.vala b/tests/rygel-http-item-uri-test.vala
new file mode 100644
index 0000000..ef6cd04
--- /dev/null
+++ b/tests/rygel-http-item-uri-test.vala
@@ -0,0 +1,102 @@
+public errordomain Rygel.HTTPRequestError {
+ UNACCEPTABLE = Soup.KnownStatusCode.NOT_ACCEPTABLE,
+ BAD_REQUEST = Soup.KnownStatusCode.BAD_REQUEST,
+ NOT_FOUND = Soup.KnownStatusCode.NOT_FOUND
+}
+
+public class Rygel.HTTPServer : GLib.Object {
+ private const string SERVER_PATH = "/RygelHTTPServer/Rygel/Test";
+
+ public string path_root { get; private set; }
+
+ public GUPnP.Context context;
+
+ public HTTPServer () throws Error {
+ this.path_root = SERVER_PATH;
+ this.context = new GUPnP.Context (null, "lo", 0);
+
+ assert (this.context != null);
+ assert (this.context.host_ip != null);
+ assert (this.context.port > 0);
+ }
+}
+
+public class Rygel.HTTPItemURITest : GLib.Object {
+ private const string ITEM_ID = "HELLO";
+ private const int THUMBNAIL_INDEX = 1;
+ private const string TRANSCODE_TARGET = "MP3";
+
+ private HTTPServer server;
+
+ public static int main (string[] args) {
+ try {
+ var test = new HTTPItemURITest ();
+
+ test.run ();
+ } catch (Error error) {
+ critical ("%s", error.message);
+
+ return -1;
+ }
+
+ return 0;
+ }
+
+ public void run () throws Error {
+ var uris = new HTTPItemURI[] {
+ this.test_construction (),
+ this.test_construction_with_thumbnail (),
+ this.test_construction_with_transcoder () };
+
+ foreach (var uri in uris) {
+ var str = this.test_to_string (uri);
+ this.test_construction_from_string (str);
+ }
+ }
+
+ private HTTPItemURITest () throws Error {
+ this.server = new HTTPServer ();
+ }
+
+ private HTTPItemURI test_construction () {
+ var uri = new HTTPItemURI (ITEM_ID, this.server);
+ assert (uri != null);
+
+ return uri;
+ }
+
+ private HTTPItemURI test_construction_with_thumbnail () {
+ var uri = new HTTPItemURI (ITEM_ID,
+ this.server,
+ THUMBNAIL_INDEX);
+ assert (uri != null);
+
+ return uri;
+ }
+
+ private HTTPItemURI test_construction_with_transcoder () {
+ var uri = new HTTPItemURI (ITEM_ID,
+ this.server,
+ THUMBNAIL_INDEX,
+ TRANSCODE_TARGET);
+ assert (uri != null);
+
+ return uri;
+ }
+
+ private HTTPItemURI test_construction_from_string (string str)
+ throws Error {
+ var uri = new HTTPItemURI.from_string (str, this.server);
+ assert (uri != null);
+ assert (uri.to_string () == str);
+
+ return uri;
+ }
+
+ private string test_to_string (HTTPItemURI uri) {
+ var str = uri.to_string ();
+ assert (str != null);
+
+ return str;
+ }
+}
diff --git a/tests/rygel-http-item-uri.vala b/tests/rygel-http-item-uri.vala
new file mode 120000
index 0000000..b6cf2d8
--- /dev/null
+++ b/tests/rygel-http-item-uri.vala
@@ -0,0 +1 @@
+../src/rygel/rygel-http-item-uri.vala
\ No newline at end of file
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]