gl/tests: add extension/version parsing checks
authorMatthew Waters <matthew@centricular.com>
Fri, 15 Jun 2018 03:14:12 +0000 (13:14 +1000)
committerMatthew Waters <matthew@centricular.com>
Fri, 15 Jun 2018 03:17:14 +0000 (13:17 +1000)
tests/check/Makefile.am
tests/check/libs/.gitignore
tests/check/libs/gstglfeature.c [new file with mode: 0644]
tests/check/meson.build

index d3e14c7..bae1cf3 100644 (file)
@@ -43,6 +43,7 @@ check_gl=\
     libs/gstglshader \
     libs/gstglheaders \
     libs/gstglformat \
+    libs/gstglfeature \
     elements/glimagesink \
     elements/glbin \
     pipelines/gl-launch-lines
@@ -513,6 +514,14 @@ libs_gstglformat_LDADD = \
        $(top_builddir)/gst-libs/gst/gl/libgstgl-@GST_API_VERSION@.la \
        $(GST_BASE_LIBS) $(GST_LIBS) $(LDADD)
 
+libs_gstglfeature_CFLAGS = \
+       $(GST_PLUGINS_BASE_CFLAGS) \
+       $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(GL_CFLAGS) $(AM_CFLAGS)
+
+libs_gstglfeature_LDADD = \
+       $(top_builddir)/gst-libs/gst/gl/libgstgl-@GST_API_VERSION@.la \
+       $(GST_BASE_LIBS) $(GST_LIBS) $(LDADD)
+
 elements_glimagesink_CFLAGS = \
        $(GST_PLUGINS_BASE_CFLAGS) \
        $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(GL_CFLAGS) $(AM_CFLAGS)
index f883967..64a1eb6 100644 (file)
@@ -10,6 +10,7 @@ fft
 gstglcolorconvert
 gstglcontext
 gstglheaders
+gstglfeature
 gstglformat
 gstglmatrix
 gstglmemory
diff --git a/tests/check/libs/gstglfeature.c b/tests/check/libs/gstglfeature.c
new file mode 100644 (file)
index 0000000..beffb87
--- /dev/null
@@ -0,0 +1,161 @@
+/* GStreamer
+ *
+ * Copyright (C) 2018 Matthew Waters <matthew@centricular.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include <gst/check/gstcheck.h>
+
+#include <gst/gl/gl.h>
+
+GST_START_TEST (test_same_version)
+{
+  fail_unless_equals_int (GST_GL_CHECK_GL_VERSION (2, 2, 2, 2), TRUE);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_greater_major_version)
+{
+  fail_unless_equals_int (GST_GL_CHECK_GL_VERSION (3, 2, 2, 2), TRUE);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_greater_minor_version)
+{
+  fail_unless_equals_int (GST_GL_CHECK_GL_VERSION (2, 3, 2, 2), TRUE);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_greater_major_minor_version)
+{
+  fail_unless_equals_int (GST_GL_CHECK_GL_VERSION (3, 3, 2, 2), TRUE);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_lesser_major_version)
+{
+  fail_unless_equals_int (GST_GL_CHECK_GL_VERSION (2, 2, 3, 2), FALSE);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_lesser_minor_version)
+{
+  fail_unless_equals_int (GST_GL_CHECK_GL_VERSION (2, 2, 2, 3), FALSE);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_lesser_major_minor_version)
+{
+  fail_unless_equals_int (GST_GL_CHECK_GL_VERSION (2, 2, 3, 3), FALSE);
+}
+
+GST_END_TEST;
+
+static const gchar *dummy_extensions = "start middle end";
+
+GST_START_TEST (test_extension_start)
+{
+  fail_unless_equals_int (gst_gl_check_extension ("start", dummy_extensions),
+      TRUE);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_extension_middle)
+{
+  fail_unless_equals_int (gst_gl_check_extension ("middle", dummy_extensions),
+      TRUE);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_extension_end)
+{
+  fail_unless_equals_int (gst_gl_check_extension ("end", dummy_extensions),
+      TRUE);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_extension_non_existent)
+{
+  fail_unless_equals_int (gst_gl_check_extension ("ZZZZZZ", dummy_extensions),
+      FALSE);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_extension_non_existent_start)
+{
+  fail_unless_equals_int (gst_gl_check_extension ("start1", dummy_extensions),
+      FALSE);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_extension_non_existent_middle)
+{
+  fail_unless_equals_int (gst_gl_check_extension ("middle1", dummy_extensions),
+      FALSE);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_extension_non_existent_end)
+{
+  fail_unless_equals_int (gst_gl_check_extension ("1end", dummy_extensions),
+      FALSE);
+}
+
+GST_END_TEST;
+
+static Suite *
+gst_gl_format_suite (void)
+{
+  Suite *s = suite_create ("Gst GL Feature");
+  TCase *tc_chain = tcase_create ("general");
+
+  suite_add_tcase (s, tc_chain);
+  tcase_add_test (tc_chain, test_same_version);
+  tcase_add_test (tc_chain, test_greater_major_version);
+  tcase_add_test (tc_chain, test_greater_minor_version);
+  tcase_add_test (tc_chain, test_greater_major_minor_version);
+  tcase_add_test (tc_chain, test_lesser_major_version);
+  tcase_add_test (tc_chain, test_lesser_minor_version);
+  tcase_add_test (tc_chain, test_lesser_major_minor_version);
+  tcase_add_test (tc_chain, test_extension_start);
+  tcase_add_test (tc_chain, test_extension_middle);
+  tcase_add_test (tc_chain, test_extension_end);
+  tcase_add_test (tc_chain, test_extension_non_existent);
+  tcase_add_test (tc_chain, test_extension_non_existent_start);
+  tcase_add_test (tc_chain, test_extension_non_existent_middle);
+  tcase_add_test (tc_chain, test_extension_non_existent_end);
+
+  return s;
+}
+
+GST_CHECK_MAIN (gst_gl_format);
index 3e4b306..0e42f7f 100644 (file)
@@ -75,6 +75,7 @@ if build_gstgl
   base_tests += [
     [ 'libs/gstglcolorconvert.c', not build_gstgl, [gstgl_dep]],
     [ 'libs/gstglcontext.c', not build_gstgl, [gstgl_dep]],
+    [ 'libs/gstglfeature.c', not build_gstgl, [gstgl_dep]],
     [ 'libs/gstglformat.c', not build_gstgl, [gstgl_dep]],
     [ 'libs/gstglheaders.c', not build_gstgl, [gstgl_dep]],
     [ 'libs/gstglmatrix.c', not build_gstgl, [gstgl_dep]],