From 35d22b300a0662fe45c98688828f6f299b30e48d Mon Sep 17 00:00:00 2001 From: Jens Georg Date: Sat, 7 May 2022 16:17:32 +0200 Subject: 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. --- tests/meson.build | 20 +++++++++--------- tests/time-seek/rygel-http-time-seek-test.vala | 29 ++++++++++++++++++++++---- 2 files changed, 35 insertions(+), 14 deletions(-) (limited to 'tests') 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 headers; + public MessageHeaders(HashTable headers) { + this.headers = headers; + } + + public string? get_one (string header) { + return this.headers.lookup (header); + } +} + +public class Soup.ServerMessage { + public HashTable request_headers = new HashTable (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 -- cgit v1.2.1