summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMatthew Waters <matthew@centricular.com>2017-10-28 18:33:44 +1100
committerMatthew Waters <matthew@centricular.com>2017-10-28 18:34:57 +1100
commitf8d751f7b5195dbfd4a76f69bc99d0abbd1a10c1 (patch)
treef9eb45ab040f05027bf2b6d161cc18c6ac5b5f8d /tests
parentc2d34d1e44fbe6c4a0e7792b8d22e1059a4b1db7 (diff)
gl/query: split tests and fix some corresponding issues in usage
Diffstat (limited to 'tests')
-rw-r--r--tests/check/libs/gstglquery.c223
1 files changed, 210 insertions, 13 deletions
diff --git a/tests/check/libs/gstglquery.c b/tests/check/libs/gstglquery.c
index 2dfa24064..8563abbe5 100644
--- a/tests/check/libs/gstglquery.c
+++ b/tests/check/libs/gstglquery.c
@@ -54,21 +54,111 @@ teardown (void)
}
static void
-_test_query_gl (GstGLContext * context, gpointer data)
+_test_query_init_gl (GstGLContext * context, gpointer data)
{
- GstGLQuery *q1, q2;
+ GstGLQuery q1;
+
+ /* no usage */
+ gst_gl_query_init (&q1, context, GST_GL_QUERY_TIMESTAMP);
+ gst_gl_query_unset (&q1);
+}
+
+GST_START_TEST (test_query_init)
+{
+ gst_gl_context_thread_add (context,
+ (GstGLContextThreadFunc) _test_query_init_gl, NULL);
+}
+
+GST_END_TEST;
+
+static void
+_test_query_init_invalid_query_gl (GstGLContext * context, gpointer data)
+{
+ GstGLQuery q1;
+
+ /* no usage */
+ ASSERT_CRITICAL (gst_gl_query_init (&q1, context, GST_GL_QUERY_NONE));
+}
+
+GST_START_TEST (test_query_init_invalid_query)
+{
+ gst_gl_context_thread_add (context,
+ (GstGLContextThreadFunc) _test_query_init_invalid_query_gl, NULL);
+}
+
+GST_END_TEST;
+
+static void
+_test_query_new_gl (GstGLContext * context, gpointer data)
+{
+ GstGLQuery *q1;
+
+ /* no usage */
+ q1 = gst_gl_query_new (context, GST_GL_QUERY_TIMESTAMP);
+ gst_gl_query_free (q1);
+}
+
+GST_START_TEST (test_query_new)
+{
+ gst_gl_context_thread_add (context,
+ (GstGLContextThreadFunc) _test_query_new_gl, NULL);
+}
+
+GST_END_TEST;
+
+static void
+_test_query_time_elapsed_gl (GstGLContext * context, gpointer data)
+{
+ GstGLQuery *q1;
q1 = gst_gl_query_new (context, GST_GL_QUERY_TIME_ELAPSED);
fail_if (q1 == NULL);
- gst_gl_query_start_log (q1, NULL, GST_LEVEL_ERROR, NULL, "%s",
- "1. testing query proxy-logging");
+ gst_gl_query_start (q1);
gst_gl_query_end (q1);
/* GST_GL_QUERY_TIME_ELAPSED doesn't supported counter() */
ASSERT_CRITICAL (gst_gl_query_counter (q1));
gst_gl_query_result (q1);
gst_gl_query_free (q1);
+}
+
+GST_START_TEST (test_query_time_elapsed)
+{
+ gst_gl_context_thread_add (context,
+ (GstGLContextThreadFunc) _test_query_time_elapsed_gl, NULL);
+}
+
+GST_END_TEST;
+
+static void
+_test_query_start_log_gl (GstGLContext * context, gpointer data)
+{
+ GstGLQuery *q1;
+
+ q1 = gst_gl_query_new (context, GST_GL_QUERY_TIME_ELAPSED);
+ fail_if (q1 == NULL);
+
+ gst_gl_query_start_log (q1, NULL, GST_LEVEL_ERROR, NULL, "%s",
+ "testing query proxy-logging for gst_gl_query_start_log()");
+ gst_gl_query_end (q1);
+ gst_gl_query_result (q1);
+
+ gst_gl_query_free (q1);
+}
+
+GST_START_TEST (test_query_start_log)
+{
+ gst_gl_context_thread_add (context,
+ (GstGLContextThreadFunc) _test_query_start_log_gl, NULL);
+}
+
+GST_END_TEST;
+
+static void
+_test_query_timestamp_gl (GstGLContext * context, gpointer data)
+{
+ GstGLQuery q2;
gst_gl_query_init (&q2, context, GST_GL_QUERY_TIMESTAMP);
@@ -76,15 +166,47 @@ _test_query_gl (GstGLContext * context, gpointer data)
ASSERT_CRITICAL (gst_gl_query_start (&q2));
ASSERT_CRITICAL (gst_gl_query_end (&q2));
- gst_gl_query_counter_log (&q2, gst_test_debug_cat, GST_LEVEL_ERROR, NULL,
- "%s", "2. testing query proxy-logging works from _unset()");
+ gst_gl_query_counter (&q2);
gst_gl_query_result (&q2);
gst_gl_query_unset (&q2);
+}
+
+GST_START_TEST (test_query_timestamp)
+{
+ gst_gl_context_thread_add (context,
+ (GstGLContextThreadFunc) _test_query_timestamp_gl, NULL);
+}
+
+GST_END_TEST;
+
+static void
+_test_query_counter_log_gl (GstGLContext * context, gpointer data)
+{
+ GstGLQuery q2;
- /* no usage */
gst_gl_query_init (&q2, context, GST_GL_QUERY_TIMESTAMP);
+
+ gst_gl_query_counter_log (&q2, gst_test_debug_cat, GST_LEVEL_ERROR, NULL,
+ "%s",
+ "testing query proxy-logging works from gst_gl_query_counter_log()");
+ gst_gl_query_result (&q2);
+
gst_gl_query_unset (&q2);
+}
+
+GST_START_TEST (test_query_counter_log)
+{
+ gst_gl_context_thread_add (context,
+ (GstGLContextThreadFunc) _test_query_counter_log_gl, NULL);
+}
+
+GST_END_TEST;
+
+static void
+_test_query_start_free_gl (GstGLContext * context, gpointer data)
+{
+ GstGLQuery *q1;
/* test mismatched start()/free() */
q1 = gst_gl_query_new (context, GST_GL_QUERY_TIME_ELAPSED);
@@ -93,6 +215,20 @@ _test_query_gl (GstGLContext * context, gpointer data)
gst_gl_query_start (q1);
ASSERT_CRITICAL (gst_gl_query_free (q1));
+}
+
+GST_START_TEST (test_query_start_free)
+{
+ gst_gl_context_thread_add (context,
+ (GstGLContextThreadFunc) _test_query_start_free_gl, NULL);
+}
+
+GST_END_TEST;
+
+static void
+_test_query_start_result_gl (GstGLContext * context, gpointer data)
+{
+ GstGLQuery *q1;
/* test mismatched start()/result() */
q1 = gst_gl_query_new (context, GST_GL_QUERY_TIME_ELAPSED);
@@ -103,12 +239,64 @@ _test_query_gl (GstGLContext * context, gpointer data)
gst_gl_query_end (q1);
gst_gl_query_free (q1);
+}
+
+GST_START_TEST (test_query_start_result)
+{
+ gst_gl_context_thread_add (context,
+ (GstGLContextThreadFunc) _test_query_start_result_gl, NULL);
+}
+
+GST_END_TEST;
+
+static void
+_test_query_start_start_gl (GstGLContext * context, gpointer data)
+{
+ GstGLQuery *q1;
+
+ /* test double end() */
+ q1 = gst_gl_query_new (context, GST_GL_QUERY_TIME_ELAPSED);
+ fail_if (q1 == NULL);
+
+ gst_gl_query_start (q1);
+ ASSERT_CRITICAL (gst_gl_query_start (q1));
+ gst_gl_query_end (q1);
+
+ gst_gl_query_free (q1);
+}
+
+GST_START_TEST (test_query_start_start)
+{
+ gst_gl_context_thread_add (context,
+ (GstGLContextThreadFunc) _test_query_start_start_gl, NULL);
+}
+
+GST_END_TEST;
+
+static void
+_test_query_end_gl (GstGLContext * context, gpointer data)
+{
+ GstGLQuery *q1;
/* test mismatched end() */
q1 = gst_gl_query_new (context, GST_GL_QUERY_TIME_ELAPSED);
fail_if (q1 == NULL);
ASSERT_CRITICAL (gst_gl_query_end (q1));
gst_gl_query_free (q1);
+}
+
+GST_START_TEST (test_query_end)
+{
+ gst_gl_context_thread_add (context,
+ (GstGLContextThreadFunc) _test_query_end_gl, NULL);
+}
+
+GST_END_TEST;
+
+static void
+_test_query_end_end_gl (GstGLContext * context, gpointer data)
+{
+ GstGLQuery *q1;
/* test double end() */
q1 = gst_gl_query_new (context, GST_GL_QUERY_TIME_ELAPSED);
@@ -119,14 +307,12 @@ _test_query_gl (GstGLContext * context, gpointer data)
ASSERT_CRITICAL (gst_gl_query_end (q1));
gst_gl_query_free (q1);
-
- /* double start is allowed */
}
-GST_START_TEST (test_query)
+GST_START_TEST (test_query_end_end)
{
- gst_gl_context_thread_add (context, (GstGLContextThreadFunc) _test_query_gl,
- NULL);
+ gst_gl_context_thread_add (context,
+ (GstGLContextThreadFunc) _test_query_end_end_gl, NULL);
}
GST_END_TEST;
@@ -142,7 +328,18 @@ gst_gl_upload_suite (void)
suite_add_tcase (s, tc_chain);
tcase_add_checked_fixture (tc_chain, setup, teardown);
- tcase_add_test (tc_chain, test_query);
+ tcase_add_test (tc_chain, test_query_init);
+ tcase_add_test (tc_chain, test_query_init_invalid_query);
+ tcase_add_test (tc_chain, test_query_new);
+ tcase_add_test (tc_chain, test_query_time_elapsed);
+ tcase_add_test (tc_chain, test_query_timestamp);
+ tcase_add_test (tc_chain, test_query_counter_log);
+ tcase_add_test (tc_chain, test_query_start_log);
+ tcase_add_test (tc_chain, test_query_start_free);
+ tcase_add_test (tc_chain, test_query_start_result);
+ tcase_add_test (tc_chain, test_query_start_start);
+ tcase_add_test (tc_chain, test_query_end);
+ tcase_add_test (tc_chain, test_query_end_end);
return s;
}