diff options
author | Jens Georg <mail@jensge.org> | 2022-05-07 16:17:32 +0200 |
---|---|---|
committer | Jens Georg <mail@jensge.org> | 2022-05-24 18:19:45 +0000 |
commit | 35d22b300a0662fe45c98688828f6f299b30e48d (patch) | |
tree | b91c6e84824da184e45c9252b13bfa61e331968b | |
parent | 1acb418b4db5f21cb6a20b88d4bf9ffc606c38d0 (diff) | |
download | rygel-35d22b300a0662fe45c98688828f6f299b30e48d.tar.gz |
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.
-rw-r--r-- | meson.build | 1 | ||||
-rw-r--r-- | meson_options.txt | 2 | ||||
-rw-r--r-- | tests/meson.build | 20 | ||||
-rw-r--r-- | 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 |