[mutter] tests/cogl: Migrate framebuffer bits test



commit 3750ed6a269149f62caea3d2e41369c8f4c0ff02
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Thu Aug 4 22:15:03 2022 +0200

    tests/cogl: Migrate framebuffer bits test
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2555>

 cogl/tests/conform/meson.build                     |  1 -
 cogl/tests/conform/test-conform-main.c             |  4 --
 cogl/tests/conform/test-declarations.h             |  1 -
 cogl/tests/conform/test-framebuffer-get-bits.c     | 41 ----------------
 src/tests/cogl/conform/meson.build                 |  1 +
 src/tests/cogl/conform/test-framebuffer-get-bits.c | 55 ++++++++++++++++++++++
 6 files changed, 56 insertions(+), 47 deletions(-)
---
diff --git a/cogl/tests/conform/meson.build b/cogl/tests/conform/meson.build
index 78a3fc6a87..e4558be50c 100644
--- a/cogl/tests/conform/meson.build
+++ b/cogl/tests/conform/meson.build
@@ -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',
diff --git a/cogl/tests/conform/test-conform-main.c b/cogl/tests/conform/test-conform-main.c
index b2f06ff2f8..a048dbb096 100644
--- a/cogl/tests/conform/test-conform-main.c
+++ b/cogl/tests/conform/test-conform-main.c
@@ -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);
diff --git a/cogl/tests/conform/test-declarations.h b/cogl/tests/conform/test-declarations.h
index 9d138f6fec..c4018ce521 100644
--- a/cogl/tests/conform/test-declarations.h
+++ b/cogl/tests/conform/test-declarations.h
@@ -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);
diff --git a/src/tests/cogl/conform/meson.build b/src/tests/cogl/conform/meson.build
index 301ad8e128..c7603e7e9a 100644
--- a/src/tests/cogl/conform/meson.build
+++ b/src/tests/cogl/conform/meson.build
@@ -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 = [
diff --git a/src/tests/cogl/conform/test-framebuffer-get-bits.c 
b/src/tests/cogl/conform/test-framebuffer-get-bits.c
new file mode 100644
index 0000000000..461d395005
--- /dev/null
+++ b/src/tests/cogl/conform/test-framebuffer-get-bits.c
@@ -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);
+)


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