[test/mqtt] Fix and add negative testcases for mqttsink's invalid prop
authorYongjoo Ahn <yongjoo1.ahn@samsung.com>
Fri, 1 Oct 2021 05:20:45 +0000 (14:20 +0900)
committerwooksong <wook16.song@samsung.com>
Fri, 1 Oct 2021 12:59:49 +0000 (21:59 +0900)
- Test invalid properties of mqttsink with `gst_harness_new_parse`
  instead of `g_object_set`.

Signed-off-by: Yongjoo Ahn <yongjoo1.ahn@samsung.com>
tests/gstreamer_mqtt/unittest_mqtt.cc

index 1d42137..d959069 100644 (file)
 TEST (testMqttSink, sinkPushWrongurl_n)
 {
   const static gsize data_size = 1024;
-  GstHarness *h = gst_harness_new ("mqttsink");
+  GstHarness *h = gst_harness_new_parse ("mqttsink host=invalid_host");
+  GstBuffer *in_buf;
+  GstFlowReturn ret;
+
+  ASSERT_TRUE (h != NULL);
+
+  in_buf = gst_harness_create_buffer (h, data_size);
+  ret = gst_harness_push (h, in_buf);
+
+  EXPECT_EQ (ret, GST_FLOW_ERROR);
+
+  gst_harness_teardown (h);
+}
+
+/**
+ * @brief Test for mqttsink with invalid port
+ */
+TEST (testMqttSink, sinkPushWrongPort_n)
+{
+  const static gsize data_size = 1024;
+  GstHarness *h = gst_harness_new_parse ("mqttsink port=-1");
   GstBuffer *in_buf;
   GstFlowReturn ret;
 
   ASSERT_TRUE (h != NULL);
 
-  g_object_set (h->element, "host", "tcp:://0.0.0.0", "port", "0",
-      "enable-last-sample", (gboolean) FALSE, NULL);
   in_buf = gst_harness_create_buffer (h, data_size);
   ret = gst_harness_push (h, in_buf);
 
@@ -36,7 +54,7 @@ TEST (testMqttSink, sinkPushWrongurl_n)
 }
 
 /**
- * @brief Test for mqttsink without broker (Push an EOS event)
+ * @brief Test pushing EOS event to mqttsink
  */
 TEST (testMqttSink, sinkPushEvent)
 {