adaptivedemux: tests: use macro to define names of request and response structs
authorFlorin Apostol <florin.apostol@oregan.net>
Tue, 16 Feb 2016 14:26:55 +0000 (14:26 +0000)
committerThiago Santos <thiagoss@osg.samsung.com>
Fri, 22 Apr 2016 20:33:15 +0000 (17:33 -0300)
Following the Don't Repeat Yourself principle, define macros
for the structures that contain the request and response headers,
so that the name is not repeated in multiple places in multiple files.

https://bugzilla.gnome.org/show_bug.cgi?id=762144

tests/check/elements/test_http_src.c
tests/check/elements/test_http_src.h

index 09fc9b1..14f2043 100644 (file)
@@ -314,7 +314,8 @@ gst_test_http_src_start (GstBaseSrc * basesrc)
   http_headers = gst_structure_new_empty ("http-headers");
   gst_structure_set (http_headers, "uri", G_TYPE_STRING, src->uri, NULL);
   if (!src->input.request_headers) {
-    src->input.request_headers = gst_structure_new_empty ("request-headers");
+    src->input.request_headers =
+        gst_structure_new_empty (TEST_HTTP_SRC_REQUEST_HEADERS_NAME);
   }
   if (!gst_structure_has_field_typed (src->input.request_headers,
           "User-Agent", G_TYPE_STRING)) {
@@ -334,10 +335,11 @@ gst_test_http_src_start (GstBaseSrc * basesrc)
     gst_structure_set (src->input.request_headers, "Accept-Encoding",
         G_TYPE_STRING, "compress, gzip", NULL);
   }
-  gst_structure_set (http_headers, "request-headers", GST_TYPE_STRUCTURE,
-      src->input.request_headers, NULL);
+  gst_structure_set (http_headers, TEST_HTTP_SRC_REQUEST_HEADERS_NAME,
+      GST_TYPE_STRUCTURE, src->input.request_headers, NULL);
   if (!src->input.response_headers) {
-    src->input.response_headers = gst_structure_new_empty ("response-headers");
+    src->input.response_headers =
+        gst_structure_new_empty (TEST_HTTP_SRC_RESPONSE_HEADERS_NAME);
   }
   if (!gst_structure_has_field_typed (src->input.response_headers,
           "Connection", G_TYPE_STRING)) {
@@ -359,8 +361,8 @@ gst_test_http_src_start (GstBaseSrc * basesrc)
     g_free (date_str);
     g_date_time_unref (now);
   }
-  gst_structure_set (http_headers, "response-headers", GST_TYPE_STRUCTURE,
-      src->input.response_headers, NULL);
+  gst_structure_set (http_headers, TEST_HTTP_SRC_RESPONSE_HEADERS_NAME,
+      GST_TYPE_STRUCTURE, src->input.response_headers, NULL);
   if (src->http_headers_event) {
     gst_event_unref (src->http_headers_event);
   }
index 61161af..3a83e25 100644 (file)
@@ -27,6 +27,20 @@ G_BEGIN_DECLS
 
 #define GST_TYPE_TEST_HTTP_SRC            (gst_test_http_src_get_type ())
 
+/**
+ * TEST_HTTP_SRC_REQUEST_HEADERS_NAME:
+ * The name of the #GstStructure that will contain all the HTTP request
+ * headers
+ */
+#define TEST_HTTP_SRC_REQUEST_HEADERS_NAME "request-headers"
+
+/**
+ * TEST_HTTP_SRC_RESPONSE_HEADERS_NAME:
+ * The name of the #GstStructure that will contain all the HTTP response
+ * headers
+ */
+#define TEST_HTTP_SRC_RESPONSE_HEADERS_NAME "response-headers"
+
 /* structure used by src_start function to configure the
  * GstTestHTTPSrc plugin.
  * It specifies information about a given URI.