[mutter] cogl/pipeline/opengl: Move out unit test to separate file



commit 07f8edde228db8c2e13edb711200456ab21cf54e
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Fri Aug 5 11:20:57 2022 +0200

    cogl/pipeline/opengl: Move out unit test to separate file
    
    Also rename the suffix to "-glsl" to not confuse OpenGL with GLES2
    since this test covers both.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2555>

 cogl/cogl/cogl-framebuffer-private.h       |  2 +-
 cogl/cogl/driver/gl/cogl-pipeline-opengl.c | 34 -----------------------
 src/tests/cogl/unit/meson.build            |  1 +
 src/tests/cogl/unit/test-pipeline-glsl.c   | 44 ++++++++++++++++++++++++++++++
 4 files changed, 46 insertions(+), 35 deletions(-)
---
diff --git a/cogl/cogl/cogl-framebuffer-private.h b/cogl/cogl/cogl-framebuffer-private.h
index 5236478199..945af926dd 100644
--- a/cogl/cogl/cogl-framebuffer-private.h
+++ b/cogl/cogl/cogl-framebuffer-private.h
@@ -196,7 +196,7 @@ void
 _cogl_framebuffer_add_dependency (CoglFramebuffer *framebuffer,
                                   CoglFramebuffer *dependency);
 
-void
+COGL_EXPORT_TEST void
 _cogl_framebuffer_flush_journal (CoglFramebuffer *framebuffer);
 
 void
diff --git a/cogl/cogl/driver/gl/cogl-pipeline-opengl.c b/cogl/cogl/driver/gl/cogl-pipeline-opengl.c
index 9d487714bd..8986e04667 100644
--- a/cogl/cogl/driver/gl/cogl-pipeline-opengl.c
+++ b/cogl/cogl/driver/gl/cogl-pipeline-opengl.c
@@ -45,8 +45,6 @@
 
 #include "driver/gl/cogl-pipeline-progend-glsl-private.h"
 
-#include <test-fixtures/test-unit.h>
-
 #include <glib.h>
 #include <string.h>
 
@@ -306,38 +304,6 @@ flush_depth_state (CoglContext *ctx,
     }
 }
 
-UNIT_TEST (check_gl_blend_enable,
-           0 /* no requirements */,
-           0 /* no failure cases */)
-{
-  CoglPipeline *pipeline = cogl_pipeline_new (test_ctx);
-
-  /* By default blending should be disabled */
-  g_assert_cmpint (test_ctx->gl_blend_enable_cache, ==, 0);
-
-  cogl_framebuffer_draw_rectangle (test_fb, pipeline, 0, 0, 1, 1);
-  _cogl_framebuffer_flush_journal (test_fb);
-
-  /* After drawing an opaque rectangle blending should still be
-   * disabled */
-  g_assert_cmpint (test_ctx->gl_blend_enable_cache, ==, 0);
-
-  cogl_pipeline_set_color4f (pipeline, 0, 0, 0, 0);
-  cogl_framebuffer_draw_rectangle (test_fb, pipeline, 0, 0, 1, 1);
-  _cogl_framebuffer_flush_journal (test_fb);
-
-  /* After drawing a transparent rectangle blending should be enabled */
-  g_assert_cmpint (test_ctx->gl_blend_enable_cache, ==, 1);
-
-  cogl_pipeline_set_blend (pipeline, "RGBA=ADD(SRC_COLOR, 0)", NULL);
-  cogl_framebuffer_draw_rectangle (test_fb, pipeline, 0, 0, 1, 1);
-  _cogl_framebuffer_flush_journal (test_fb);
-
-  /* After setting a blend string that effectively disables blending
-   * then blending should be disabled */
-  g_assert_cmpint (test_ctx->gl_blend_enable_cache, ==, 0);
-}
-
 static void
 _cogl_pipeline_flush_color_blend_alpha_depth_state (
                                             CoglPipeline *pipeline,
diff --git a/src/tests/cogl/unit/meson.build b/src/tests/cogl/unit/meson.build
index 4ee20bcc71..16a8169e93 100644
--- a/src/tests/cogl/unit/meson.build
+++ b/src/tests/cogl/unit/meson.build
@@ -3,6 +3,7 @@ cogl_unit_tests = [
   ['test-pipeline-cache', true],
   ['test-pipeline-state-known-failure', false],
   ['test-pipeline-state', true],
+  ['test-pipeline-glsl', true],
 ]
 
 test_env = environment()
diff --git a/src/tests/cogl/unit/test-pipeline-glsl.c b/src/tests/cogl/unit/test-pipeline-glsl.c
new file mode 100644
index 0000000000..6d2ac214f0
--- /dev/null
+++ b/src/tests/cogl/unit/test-pipeline-glsl.c
@@ -0,0 +1,44 @@
+#include "cogl-config.h"
+
+#include "cogl/cogl.h"
+#include "tests/cogl-test-utils.h"
+
+static void
+test_pipeline_opengl_blend_enable (void)
+{
+  CoglPipeline *pipeline;
+
+  pipeline = cogl_pipeline_new (test_ctx);
+
+  /* By default blending should be disabled */
+  g_assert_cmpint (test_ctx->gl_blend_enable_cache, ==, 0);
+
+  cogl_framebuffer_draw_rectangle (test_fb, pipeline, 0, 0, 1, 1);
+  _cogl_framebuffer_flush_journal (test_fb);
+
+  /* After drawing an opaque rectangle blending should still be
+   * disabled */
+  g_assert_cmpint (test_ctx->gl_blend_enable_cache, ==, 0);
+
+  cogl_pipeline_set_color4f (pipeline, 0, 0, 0, 0);
+  cogl_framebuffer_draw_rectangle (test_fb, pipeline, 0, 0, 1, 1);
+  _cogl_framebuffer_flush_journal (test_fb);
+
+  /* After drawing a transparent rectangle blending should be enabled */
+  g_assert_cmpint (test_ctx->gl_blend_enable_cache, ==, 1);
+
+  cogl_pipeline_set_blend (pipeline, "RGBA=ADD(SRC_COLOR, 0)", NULL);
+  cogl_framebuffer_draw_rectangle (test_fb, pipeline, 0, 0, 1, 1);
+  _cogl_framebuffer_flush_journal (test_fb);
+
+  /* After setting a blend string that effectively disables blending
+   * then blending should be disabled */
+  g_assert_cmpint (test_ctx->gl_blend_enable_cache, ==, 0);
+
+  cogl_object_unref (pipeline);
+}
+
+COGL_TEST_SUITE (
+  g_test_add_func ("/pipeline/opengl/blend-enable",
+                   test_pipeline_opengl_blend_enable);
+)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]