[rygel/wip/new-gupnp: 7/9] tests: Re-enable and fix




commit 546f5a0729dfe0aa70e6ad0072400763bb342b91
Author: Jens Georg <mail jensge org>
Date:   Sat May 7 16:17:32 2022 +0200

    tests: Re-enable and fix
    
    Need to mock Soup.ServerMessage for the seek test since that does not
    allow us to modify the parameters anymore that we need.
    
    Luckily the mock is quite shallow.

 meson.build                                    |  1 +
 meson_options.txt                              |  2 +-
 tests/meson.build                              | 20 +++++++++---------
 tests/time-seek/rygel-http-time-seek-test.vala | 29 ++++++++++++++++++++++----
 4 files changed, 37 insertions(+), 15 deletions(-)
---
diff --git a/meson.build b/meson.build
index 9055c408..7c661805 100644
--- a/meson.build
+++ b/meson.build
@@ -80,6 +80,7 @@ gupnp = dependency('gupnp-1.6', version : '>= 1.5.0')
 gee = dependency('gee-0.8', version: '>= 0.8.0')
 gssdp = dependency('gssdp-1.6', version : '>= 1.5.0')
 glib = dependency('glib-2.0', version : glib_minimal_version)
+gobject = dependency('gobject-2.0', version : glib_minimal_version)
 gio = dependency('gio-2.0', version : glib_minimal_version)
 gio_unix = dependency('gio-unix-2.0', version : glib_minimal_version)
 gmodule = dependency('gmodule-2.0', version: glib_minimal_version)
diff --git a/meson_options.txt b/meson_options.txt
index 99f99ee2..fd04776a 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -5,7 +5,7 @@ option('systemd-user-units-dir', type : 'string', value : 'auto', description :
 option('plugins', type : 'array', choices : ['external', 'gst-launch', 'lms', 'media-export', 'mpris', 
'playbin', 'ruih', 'tracker3'])
 option('engines', type : 'array', choices : ['simple', 'gstreamer'])
 option('examples', type : 'boolean', value : 'true')
-option('tests', type : 'boolean', value : 'false')
+option('tests', type : 'boolean', value : 'true')
 option('gstreamer', type : 'feature', value : 'enabled')
 option('gtk', type : 'feature', value : 'enabled')
 option('introspection', type: 'feature', value : 'auto')
diff --git a/tests/meson.build b/tests/meson.build
index f24414ec..910bf84a 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -56,15 +56,15 @@ playbin_renderer_test = executable(
     dependencies : [gstreamer, rygel_core, rygel_renderer, rygel_renderer_gst]
 )
 
-#http_time_seek_test = executable(
-#    'rygel-http-time-seek-test',
-#    files(
-#        'time-seek/rygel-http-seek.vala',
-#        'time-seek/rygel-http-time-seek-request.vala',
-#        'time-seek/rygel-http-time-seek-test.vala'
-#    ),
-#    dependencies : [glib, soup]
-#)
+http_time_seek_test = executable(
+    'rygel-http-time-seek-test',
+    files(
+        'time-seek/rygel-http-seek.vala',
+        'time-seek/rygel-http-time-seek-request.vala',
+        'time-seek/rygel-http-time-seek-test.vala'
+    ),
+    dependencies : [glib, gobject]
+)
 
 test('rygel-plugin-loader-test',
     executable(
@@ -101,4 +101,4 @@ test('rygel-playbin-renderer-test', playbin_renderer_test)
 # Up the timeout, the test itself is waiting 10s per round for changes, doing 4 rounds
 test('rygel-user-config-test', user_config_test, timeout : 50)
 
-#test('rygel-http-time-seek-test', http_time_seek_test)
+test('rygel-http-time-seek-test', http_time_seek_test)
diff --git a/tests/time-seek/rygel-http-time-seek-test.vala b/tests/time-seek/rygel-http-time-seek-test.vala
index 880602fb..3c50c51b 100644
--- a/tests/time-seek/rygel-http-time-seek-test.vala
+++ b/tests/time-seek/rygel-http-time-seek-test.vala
@@ -14,18 +14,39 @@ public class HTTPGetHandler : Object {
 }
 
 public class ClientHacks : Object {
-    public static ClientHacks? create (Soup.Message message) throws Error {
+    public static ClientHacks? create (Soup.ServerMessage message) throws Error {
         throw new NumberParserError.INVALID ("");
     }
 
     public bool force_seek () { return false; }
 }
 
+public class Soup.MessageHeaders {
+    private HashTable<string, string> headers;
+    public MessageHeaders(HashTable<string, string> headers) {
+        this.headers = headers;
+    }
+
+    public string? get_one (string header) {
+        return this.headers.lookup (header);
+    }
+}
+
+public class Soup.ServerMessage {
+    public HashTable<string, string> request_headers = new HashTable<string, string> (str_hash, str_equal);
+    public MessageHeaders? get_request_headers () {
+        return new MessageHeaders(request_headers);
+    }
+}
+
+public enum Soup.Status {
+    BAD_REQUEST = 400,
+    REQUESTED_RANGE_NOT_SATISFIABLE = 416
+}
+
 void test_time_seek_malformed_header () {
     // Mock data
-    var message = (Soup.ServerMessage) new Object(typeof(Soup.ServerMessage));
-    message.set_method ("GET");
-    message.set_uri (GLib.Uri.parse ("http://localhost";));
+    var message = new Soup.ServerMessage ();
     var handler = new HTTPGetHandler ();
 
     // Test without the header


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]