[gtk/matthiasc/for-master: 1/2] Add a test for gsk_gl_shader_compile
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/for-master: 1/2] Add a test for gsk_gl_shader_compile
- Date: Fri, 2 Oct 2020 03:45:19 +0000 (UTC)
commit f6bd2f4d3fa81d02b810093378cbf1ad5ea39da4
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Oct 1 21:25:39 2020 -0400
Add a test for gsk_gl_shader_compile
This is not super useful, but at least we can
test that we get an error message including the
shader text.
testsuite/gsk/shader.c | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
---
diff --git a/testsuite/gsk/shader.c b/testsuite/gsk/shader.c
index 7983d94c04..555acb0869 100644
--- a/testsuite/gsk/shader.c
+++ b/testsuite/gsk/shader.c
@@ -201,6 +201,40 @@ test_format_args (void)
g_object_unref (shader);
}
+static void
+test_compile (void)
+{
+ GBytes *bytes;
+ GskGLShader *shader;
+ GdkSurface *surface;
+ GskRenderer *renderer;
+ GError *error = NULL;
+ gboolean ret;
+
+ bytes = g_bytes_new_static ("blaat", 6);
+ shader = gsk_gl_shader_new_from_bytes (bytes);
+ g_assert_nonnull (shader);
+
+ surface = gdk_surface_new_toplevel (gdk_display_get_default ());
+ renderer = gsk_renderer_new_for_surface (surface);
+ g_assert_nonnull (renderer);
+
+ ret = gsk_gl_shader_compile (shader, renderer, &error);
+
+ g_assert_false (ret);
+ g_assert_nonnull (error);
+ if (g_str_equal (G_OBJECT_TYPE_NAME (renderer), "GskGLRenderer"))
+ g_assert_nonnull (strstr (error->message, "blaat"));
+ else
+ g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED);
+ g_clear_error (&error);
+
+ gsk_renderer_unrealize (renderer);
+ g_object_unref (renderer);
+ g_object_unref (surface);
+ g_bytes_unref (bytes);
+}
+
int
main (int argc,
char *argv[])
@@ -210,6 +244,7 @@ main (int argc,
g_test_add_func ("/shader/create/simple", test_create_simple);
g_test_add_func ("/shader/create/data", test_create_data);
g_test_add_func ("/shader/format-args", test_format_args);
+ g_test_add_func ("/shader/compile", test_compile);
return g_test_run ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]