1
0
Fork 0

tests/cogl: Migrate framebuffer bits test

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2555>
This commit is contained in:
Jonas Ådahl 2022-08-04 22:15:03 +02:00 committed by Marge Bot
parent 09990f8bcc
commit 3750ed6a26
6 changed files with 56 additions and 47 deletions

View file

@ -1,6 +1,5 @@
cogl_test_conformance_sources = [
'test-conform-main.c',
'test-framebuffer-get-bits.c',
'test-primitive-and-journal.c',
'test-copy-replace-texture.c',
'test-pipeline-cache-unrefs-texture.c',

View file

@ -70,10 +70,6 @@ main (int argc, char **argv)
UNPORTED_TEST (test_vertex_buffer_interleved);
UNPORTED_TEST (test_vertex_buffer_mutability);
ADD_TEST (test_framebuffer_get_bits,
TEST_REQUIREMENT_GL,
0);
ADD_TEST (test_primitive_and_journal, 0, 0);
ADD_TEST (test_copy_replace_texture, 0, 0);

View file

@ -5,7 +5,6 @@ void test_path (void);
void test_path_clip (void);
void test_depth_test (void);
void test_backface_culling (void);
void test_framebuffer_get_bits (void);
void test_primitive_and_journal (void);
void test_copy_replace_texture (void);
void test_pipeline_cache_unrefs_texture (void);

View file

@ -1,41 +0,0 @@
#include <cogl/cogl.h>
#include "test-declarations.h"
#include "test-utils.h"
void
test_framebuffer_get_bits (void)
{
CoglTexture2D *tex_a =
cogl_texture_2d_new_with_size (test_ctx,
16, 16); /* width/height */
CoglOffscreen *offscreen_a =
cogl_offscreen_new_with_texture (tex_a);
CoglFramebuffer *fb_a = COGL_FRAMEBUFFER (offscreen_a);
CoglTexture2D *tex_rgba =
cogl_texture_2d_new_with_size (test_ctx,
16, 16); /* width/height */
CoglOffscreen *offscreen_rgba =
cogl_offscreen_new_with_texture (tex_rgba);
CoglFramebuffer *fb_rgba = COGL_FRAMEBUFFER (offscreen_rgba);
cogl_texture_set_components (tex_a,
COGL_TEXTURE_COMPONENTS_A);
cogl_framebuffer_allocate (fb_a, NULL);
cogl_framebuffer_allocate (fb_rgba, NULL);
g_assert_cmpint (cogl_framebuffer_get_red_bits (fb_a), ==, 0);
g_assert_cmpint (cogl_framebuffer_get_green_bits (fb_a), ==, 0);
g_assert_cmpint (cogl_framebuffer_get_blue_bits (fb_a), ==, 0);
g_assert_cmpint (cogl_framebuffer_get_alpha_bits (fb_a), >=, 1);
g_assert_cmpint (cogl_framebuffer_get_red_bits (fb_rgba), >=, 1);
g_assert_cmpint (cogl_framebuffer_get_green_bits (fb_rgba), >=, 1);
g_assert_cmpint (cogl_framebuffer_get_blue_bits (fb_rgba), >=, 1);
g_assert_cmpint (cogl_framebuffer_get_alpha_bits (fb_rgba), >=, 1);
g_object_unref (fb_rgba);
cogl_object_unref (tex_rgba);
g_object_unref (fb_a);
cogl_object_unref (tex_a);
}

View file

@ -31,6 +31,7 @@ cogl_tests = [
[ 'test-npot-texture', [] ],
[ 'test-alpha-textures', [] ],
[ 'test-texture-get-set-data', [] ],
[ 'test-framebuffer-get-bits', [] ],
]
cogl_test_conformance_includes = [

View file

@ -0,0 +1,55 @@
#include <cogl/cogl.h>
#include "tests/cogl-test-utils.h"
static void
test_framebuffer_get_bits (void)
{
CoglRenderer *renderer;
CoglTexture2D *tex_a;
CoglOffscreen *offscreen_a;
CoglFramebuffer *fb_a;
CoglTexture2D *tex_rgba;
CoglOffscreen *offscreen_rgba;
CoglFramebuffer *fb_rgba;
renderer = cogl_context_get_renderer (test_ctx);
if (cogl_renderer_get_driver (renderer) != COGL_DRIVER_GL &&
cogl_renderer_get_driver (renderer) != COGL_DRIVER_GL3)
{
g_test_skip ("Test requires OpenGL");
return;
}
tex_a = cogl_texture_2d_new_with_size (test_ctx, 16, 16);
offscreen_a = cogl_offscreen_new_with_texture (tex_a);
fb_a = COGL_FRAMEBUFFER (offscreen_a);
tex_rgba = cogl_texture_2d_new_with_size (test_ctx, 16, 16);
offscreen_rgba = cogl_offscreen_new_with_texture (tex_rgba);
fb_rgba = COGL_FRAMEBUFFER (offscreen_rgba);
cogl_texture_set_components (tex_a,
COGL_TEXTURE_COMPONENTS_A);
cogl_framebuffer_allocate (fb_a, NULL);
cogl_framebuffer_allocate (fb_rgba, NULL);
g_assert_cmpint (cogl_framebuffer_get_red_bits (fb_a), ==, 0);
g_assert_cmpint (cogl_framebuffer_get_green_bits (fb_a), ==, 0);
g_assert_cmpint (cogl_framebuffer_get_blue_bits (fb_a), ==, 0);
g_assert_cmpint (cogl_framebuffer_get_alpha_bits (fb_a), >=, 1);
g_assert_cmpint (cogl_framebuffer_get_red_bits (fb_rgba), >=, 1);
g_assert_cmpint (cogl_framebuffer_get_green_bits (fb_rgba), >=, 1);
g_assert_cmpint (cogl_framebuffer_get_blue_bits (fb_rgba), >=, 1);
g_assert_cmpint (cogl_framebuffer_get_alpha_bits (fb_rgba), >=, 1);
g_object_unref (fb_rgba);
cogl_object_unref (tex_rgba);
g_object_unref (fb_a);
cogl_object_unref (tex_a);
}
COGL_TEST_SUITE (
g_test_add_func ("/framebuffer/get-bits", test_framebuffer_get_bits);
)