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>
This commit is contained in:
Jonas Ådahl 2022-08-05 11:20:57 +02:00 committed by Marge Bot
parent 16a7f77701
commit 07f8edde22
4 changed files with 46 additions and 35 deletions

View File

@ -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

View File

@ -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,

View File

@ -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()

View File

@ -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);
)