mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-16 04:15:51 +00:00
client test: add scale and speed negative tests
Negative tests for scale and speed should be done as well, verify that the response code is "400 Bad request" when a bad request is done.
This commit is contained in:
parent
45e77ecdd7
commit
c2d182de05
1 changed files with 29 additions and 8 deletions
|
@ -1851,7 +1851,8 @@ attach_rate_tweaking_probe (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
do_test_scale_and_speed (const gchar * scale, const gchar * speed)
|
do_test_scale_and_speed (const gchar * scale, const gchar * speed,
|
||||||
|
GstRTSPStatusCode expected_response_code)
|
||||||
{
|
{
|
||||||
GstRTSPClient *client;
|
GstRTSPClient *client;
|
||||||
GstRTSPMessage request = { 0, };
|
GstRTSPMessage request = { 0, };
|
||||||
|
@ -1901,7 +1902,12 @@ do_test_scale_and_speed (const gchar * scale, const gchar * speed)
|
||||||
if (speed != NULL)
|
if (speed != NULL)
|
||||||
gst_rtsp_message_add_header (&request, GST_RTSP_HDR_SPEED, speed);
|
gst_rtsp_message_add_header (&request, GST_RTSP_HDR_SPEED, speed);
|
||||||
|
|
||||||
gst_rtsp_client_set_send_func (client, test_response_scale_speed, NULL, NULL);
|
if (expected_response_code == GST_RTSP_STS_BAD_REQUEST)
|
||||||
|
gst_rtsp_client_set_send_func (client, test_response_400, NULL, NULL);
|
||||||
|
else
|
||||||
|
gst_rtsp_client_set_send_func (client, test_response_scale_speed, NULL,
|
||||||
|
NULL);
|
||||||
|
|
||||||
fail_unless (gst_rtsp_client_handle_message (client,
|
fail_unless (gst_rtsp_client_handle_message (client,
|
||||||
&request) == GST_RTSP_OK);
|
&request) == GST_RTSP_OK);
|
||||||
gst_rtsp_message_unset (&request);
|
gst_rtsp_message_unset (&request);
|
||||||
|
@ -1919,28 +1925,28 @@ GST_START_TEST (test_scale_and_speed)
|
||||||
/* no scale/speed requested, no scale/speed should be received */
|
/* no scale/speed requested, no scale/speed should be received */
|
||||||
expected_scale_header = NULL;
|
expected_scale_header = NULL;
|
||||||
expected_speed_header = NULL;
|
expected_speed_header = NULL;
|
||||||
do_test_scale_and_speed (NULL, NULL);
|
do_test_scale_and_speed (NULL, NULL, GST_RTSP_STS_OK);
|
||||||
|
|
||||||
/* scale requested, scale should be received */
|
/* scale requested, scale should be received */
|
||||||
fake_applied_rate_value = 2;
|
fake_applied_rate_value = 2;
|
||||||
fake_rate_value = 1;
|
fake_rate_value = 1;
|
||||||
expected_scale_header = "2.000";
|
expected_scale_header = "2.000";
|
||||||
expected_speed_header = NULL;
|
expected_speed_header = NULL;
|
||||||
do_test_scale_and_speed ("2.000", NULL);
|
do_test_scale_and_speed ("2.000", NULL, GST_RTSP_STS_OK);
|
||||||
|
|
||||||
/* speed requested, speed should be received */
|
/* speed requested, speed should be received */
|
||||||
fake_applied_rate_value = 0;
|
fake_applied_rate_value = 0;
|
||||||
fake_rate_value = 0;
|
fake_rate_value = 0;
|
||||||
expected_scale_header = NULL;
|
expected_scale_header = NULL;
|
||||||
expected_speed_header = "2.000";
|
expected_speed_header = "2.000";
|
||||||
do_test_scale_and_speed (NULL, "2.000");
|
do_test_scale_and_speed (NULL, "2.000", GST_RTSP_STS_OK);
|
||||||
|
|
||||||
/* both requested, both should be received */
|
/* both requested, both should be received */
|
||||||
fake_applied_rate_value = 2;
|
fake_applied_rate_value = 2;
|
||||||
fake_rate_value = 2;
|
fake_rate_value = 2;
|
||||||
expected_scale_header = "2.000";
|
expected_scale_header = "2.000";
|
||||||
expected_speed_header = "2.000";
|
expected_speed_header = "2.000";
|
||||||
do_test_scale_and_speed ("2", "2");
|
do_test_scale_and_speed ("2", "2", GST_RTSP_STS_OK);
|
||||||
|
|
||||||
/* scale requested but media doesn't handle scaling so both should be
|
/* scale requested but media doesn't handle scaling so both should be
|
||||||
* received, with scale set to 1.000 and speed set to (requested scale
|
* received, with scale set to 1.000 and speed set to (requested scale
|
||||||
|
@ -1949,7 +1955,7 @@ GST_START_TEST (test_scale_and_speed)
|
||||||
fake_rate_value = 5;
|
fake_rate_value = 5;
|
||||||
expected_scale_header = "1.000";
|
expected_scale_header = "1.000";
|
||||||
expected_speed_header = "5.000";
|
expected_speed_header = "5.000";
|
||||||
do_test_scale_and_speed ("5", NULL);
|
do_test_scale_and_speed ("5", NULL, GST_RTSP_STS_OK);
|
||||||
|
|
||||||
/* both requested but media only handles scaling so both should be received,
|
/* both requested but media only handles scaling so both should be received,
|
||||||
* with scale set to (requested scale * requested speed) and speed set to 1.00
|
* with scale set to (requested scale * requested speed) and speed set to 1.00
|
||||||
|
@ -1958,7 +1964,22 @@ GST_START_TEST (test_scale_and_speed)
|
||||||
fake_applied_rate_value = 4.000;
|
fake_applied_rate_value = 4.000;
|
||||||
expected_scale_header = "4.000";
|
expected_scale_header = "4.000";
|
||||||
expected_speed_header = "1.000";
|
expected_speed_header = "1.000";
|
||||||
do_test_scale_and_speed ("2", "2");
|
do_test_scale_and_speed ("2", "2", GST_RTSP_STS_OK);
|
||||||
|
|
||||||
|
/* test invalid values */
|
||||||
|
fake_applied_rate_value = 0;
|
||||||
|
fake_rate_value = 0;
|
||||||
|
expected_scale_header = NULL;
|
||||||
|
expected_speed_header = NULL;
|
||||||
|
|
||||||
|
/* scale or speed not decimal values */
|
||||||
|
do_test_scale_and_speed ("x", NULL, GST_RTSP_STS_BAD_REQUEST);
|
||||||
|
do_test_scale_and_speed (NULL, "y", GST_RTSP_STS_BAD_REQUEST);
|
||||||
|
|
||||||
|
/* scale or speed illegal decimal values */
|
||||||
|
do_test_scale_and_speed ("0", NULL, GST_RTSP_STS_BAD_REQUEST);
|
||||||
|
do_test_scale_and_speed (NULL, "0", GST_RTSP_STS_BAD_REQUEST);
|
||||||
|
do_test_scale_and_speed (NULL, "-2", GST_RTSP_STS_BAD_REQUEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_END_TEST
|
GST_END_TEST
|
||||||
|
|
Loading…
Reference in a new issue