Compare commits

...

2 Commits

Author SHA1 Message Date
Matthias Clasen
c445db8f62 tests: Less linking
Build just a few binaries for the gsk tests,
avoiding the overhead of linking each one.
2023-01-12 20:43:58 -05:00
Matthias Clasen
9b635cae28 tests: Less linking
Build just a few binaries for the gdk tests,
avoiding the overhead of linking each one.
2023-01-12 20:11:14 -05:00
34 changed files with 408 additions and 296 deletions

View File

@@ -21,6 +21,8 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "gdktests.h"
static void static void
int_free_func (int data) int_free_func (int data)
{ {
@@ -78,12 +80,9 @@ int_free_func (int data)
#define GDK_ARRAY_NULL_TERMINATED 1 #define GDK_ARRAY_NULL_TERMINATED 1
#include "arrayimpl.c" #include "arrayimpl.c"
int void
main (int argc, char *argv[]) add_array_tests (void)
{ {
(g_test_init) (&argc, &argv, NULL);
setlocale (LC_ALL, "C");
g_test_add_func ("/intarray/simple", int_array_test_simple); g_test_add_func ("/intarray/simple", int_array_test_simple);
g_test_add_func ("/intarray/prealloc/simple", pre_int_array_test_simple); g_test_add_func ("/intarray/prealloc/simple", pre_int_array_test_simple);
g_test_add_func ("/intarray/freefunc/simple", free_int_array_test_simple); g_test_add_func ("/intarray/freefunc/simple", free_int_array_test_simple);
@@ -100,6 +99,4 @@ main (int argc, char *argv[])
g_test_add_func ("/intarray/null/prealloc/splice", null_pre_int_array_test_splice); g_test_add_func ("/intarray/null/prealloc/splice", null_pre_int_array_test_splice);
g_test_add_func ("/intarray/null/freefunc/splice", null_free_int_array_test_splice); g_test_add_func ("/intarray/null/freefunc/splice", null_free_int_array_test_splice);
g_test_add_func ("/intarray/null/prealloc/freefunc/splice", null_pre_free_int_array_test_splice); g_test_add_func ("/intarray/null/prealloc/freefunc/splice", null_pre_free_int_array_test_splice);
return g_test_run ();
} }

View File

@@ -1,4 +1,5 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "gdktests.h"
static void static void
test_set_source_big_pixbuf (void) test_set_source_big_pixbuf (void)
@@ -28,13 +29,8 @@ test_set_source_big_pixbuf (void)
cairo_surface_destroy (surface); cairo_surface_destroy (surface);
} }
int void
main (int argc, char *argv[]) add_cairo_tests (void)
{ {
(g_test_init) (&argc, &argv, NULL);
gtk_init ();
g_test_add_func ("/drawing/set-source-big-pixbuf", test_set_source_big_pixbuf); g_test_add_func ("/drawing/set-source-big-pixbuf", test_set_source_big_pixbuf);
return g_test_run ();
} }

View File

@@ -2,6 +2,8 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "gdktests.h"
static GType static GType
string_type (void) string_type (void)
{ {
@@ -218,17 +220,11 @@ test_parse_fail (void)
} }
} }
int void
main (int argc, char *argv[]) add_content_formats_tests (void)
{ {
gsize i;
(g_test_init) (&argc, &argv, NULL);
gtk_init ();
/* Ensure all the types we care about to exist */ /* Ensure all the types we care about to exist */
for (i = 0; i < G_N_ELEMENTS(possible_types); i++) for (gsize i = 0; i < G_N_ELEMENTS(possible_types); i++)
{ {
if (possible_types[i].type_func) if (possible_types[i].type_func)
g_type_ensure (possible_types[i].type_func ()); g_type_ensure (possible_types[i].type_func ());
@@ -238,6 +234,4 @@ main (int argc, char *argv[])
g_test_add_func ("/contentformats/parse_fail", test_parse_fail); g_test_add_func ("/contentformats/parse_fail", test_parse_fail);
g_test_add_func ("/contentformats/print_and_parse", test_print_and_parse); g_test_add_func ("/contentformats/print_and_parse", test_print_and_parse);
g_test_add_func ("/contentformats/union", test_union); g_test_add_func ("/contentformats/union", test_union);
return g_test_run ();
} }

View File

@@ -2,6 +2,8 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "gdktests.h"
typedef gboolean (* ValueCompareFunc) (GValue *v1, GValue *v2); typedef gboolean (* ValueCompareFunc) (GValue *v1, GValue *v2);
typedef struct { typedef struct {
@@ -463,13 +465,9 @@ test_custom_format (void)
g_free (data); g_free (data);
} }
int void
main (int argc, char *argv[]) add_content_serializer_tests (void)
{ {
(g_test_init) (&argc, &argv, NULL);
gtk_init ();
g_test_add_func ("/content/text_plain_utf8", test_content_text_plain_utf8); g_test_add_func ("/content/text_plain_utf8", test_content_text_plain_utf8);
g_test_add_func ("/content/text_plain", test_content_text_plain); g_test_add_func ("/content/text_plain", test_content_text_plain);
g_test_add_func ("/content/color", test_content_color); g_test_add_func ("/content/color", test_content_color);
@@ -478,6 +476,4 @@ main (int argc, char *argv[])
g_test_add_func ("/content/file", test_content_file); g_test_add_func ("/content/file", test_content_file);
g_test_add_func ("/content/files", test_content_files); g_test_add_func ("/content/files", test_content_files);
g_test_add_func ("/content/custom", test_custom_format); g_test_add_func ("/content/custom", test_custom_format);
return g_test_run ();
} }

View File

@@ -1,6 +1,8 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <cairo-gobject.h> #include <cairo-gobject.h>
#include "gdktests.h"
static void static void
test_cursor_named (void) test_cursor_named (void)
{ {
@@ -54,16 +56,10 @@ test_cursor_fallback (void)
g_object_unref (fallback); g_object_unref (fallback);
} }
int void
main (int argc, char *argv[]) add_cursor_tests (void)
{ {
(g_test_init) (&argc, &argv, NULL);
gtk_init ();
g_test_add_func ("/cursor/named", test_cursor_named); g_test_add_func ("/cursor/named", test_cursor_named);
g_test_add_func ("/cursor/texture", test_cursor_texture); g_test_add_func ("/cursor/texture", test_cursor_texture);
g_test_add_func ("/cursor/fallback", test_cursor_fallback); g_test_add_func ("/cursor/fallback", test_cursor_fallback);
return g_test_run ();
} }

View File

@@ -2,11 +2,14 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "gdktests.h"
static void static void
test_unset_display_subprocess1 (void) test_unset_display_subprocess1 (void)
{ {
GdkDisplayManager *manager; GdkDisplayManager *manager;
gdk_set_allowed_backends ("x11");
g_unsetenv ("DISPLAY"); g_unsetenv ("DISPLAY");
g_assert_false (gtk_init_check ()); g_assert_false (gtk_init_check ());
@@ -18,6 +21,7 @@ test_unset_display_subprocess1 (void)
static void static void
test_unset_display_subprocess2 (void) test_unset_display_subprocess2 (void)
{ {
gdk_set_allowed_backends ("x11");
g_unsetenv ("DISPLAY"); g_unsetenv ("DISPLAY");
gtk_init (); gtk_init ();
@@ -39,6 +43,7 @@ test_bad_display_subprocess1 (void)
{ {
GdkDisplayManager *manager; GdkDisplayManager *manager;
gdk_set_allowed_backends ("x11");
g_setenv ("DISPLAY", "poo", TRUE); g_setenv ("DISPLAY", "poo", TRUE);
g_assert_false (gtk_init_check ()); g_assert_false (gtk_init_check ());
@@ -50,6 +55,7 @@ test_bad_display_subprocess1 (void)
static void static void
test_bad_display_subprocess2 (void) test_bad_display_subprocess2 (void)
{ {
gdk_set_allowed_backends ("x11");
g_setenv ("DISPLAY", "poo", TRUE); g_setenv ("DISPLAY", "poo", TRUE);
gtk_init (); gtk_init ();
} }
@@ -65,19 +71,13 @@ test_bad_display (void)
g_test_trap_assert_stderr ("*cannot open display*"); g_test_trap_assert_stderr ("*cannot open display*");
} }
int void
main (int argc, char *argv[]) add_display_tests (void)
{ {
(g_test_init) (&argc, &argv, NULL);
gdk_set_allowed_backends ("x11");
g_test_add_func ("/display/unset-display", test_unset_display); g_test_add_func ("/display/unset-display", test_unset_display);
g_test_add_func ("/display/unset-display/subprocess/1", test_unset_display_subprocess1); g_test_add_func ("/display/unset-display/subprocess/1", test_unset_display_subprocess1);
g_test_add_func ("/display/unset-display/subprocess/2", test_unset_display_subprocess2); g_test_add_func ("/display/unset-display/subprocess/2", test_unset_display_subprocess2);
g_test_add_func ("/display/bad-display", test_bad_display); g_test_add_func ("/display/bad-display", test_bad_display);
g_test_add_func ("/display/bad-display/subprocess/1", test_bad_display_subprocess1); g_test_add_func ("/display/bad-display/subprocess/1", test_bad_display_subprocess1);
g_test_add_func ("/display/bad-display/subprocess/2", test_bad_display_subprocess2); g_test_add_func ("/display/bad-display/subprocess/2", test_bad_display_subprocess2);
return g_test_run ();
} }

View File

@@ -1,5 +1,7 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "gdktests.h"
static void static void
test_basic (void) test_basic (void)
{ {
@@ -40,16 +42,9 @@ test_set_default (void)
g_assert_true (d == d2); g_assert_true (d == d2);
} }
int void
main (int argc, char *argv[]) add_display_manager_tests (void)
{ {
(g_test_init) (&argc, &argv, NULL);
/* Open default display */
gdk_display_open (NULL);
g_test_add_func ("/displaymanager/basic", test_basic); g_test_add_func ("/displaymanager/basic", test_basic);
g_test_add_func ("/displaymanager/set-default", test_set_default); g_test_add_func ("/displaymanager/set-default", test_set_default);
return g_test_run ();
} }

View File

@@ -3,6 +3,8 @@
#include <gdk/x11/gdkx.h> #include <gdk/x11/gdkx.h>
#endif #endif
#include "gdktests.h"
static void static void
test_to_text_list (void) test_to_text_list (void)
{ {
@@ -34,13 +36,8 @@ test_to_text_list (void)
#endif #endif
} }
int void
main (int argc, char *argv[]) add_encoding_tests (void)
{ {
(g_test_init) (&argc, &argv, NULL);
gtk_init ();
g_test_add_func ("/encoding/to-text-list", test_to_text_list); g_test_add_func ("/encoding/to-text-list", test_to_text_list);
return g_test_run ();
} }

View File

@@ -0,0 +1,34 @@
/*
* Copyright © 2023 Matthias Clasen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include <locale.h>
#include <gtk/gtk.h>
#include "gdkinternaltests.h"
int
main (int argc, char *argv[])
{
(g_test_init) (&argc, &argv, NULL);
gtk_init ();
add_image_tests ();
add_texture_tests ();
return g_test_run ();
}

View File

@@ -0,0 +1,4 @@
#pragma once
void add_image_tests (void);
void add_texture_tests (void);

51
testsuite/gdk/gdktests.c Normal file
View File

@@ -0,0 +1,51 @@
/*
* Copyright © 2023 Matthias Clasen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include <locale.h>
#include <gtk/gtk.h>
#include "gdktests.h"
int
main (int argc, char *argv[])
{
(g_test_init) (&argc, &argv, NULL);
/* display tests need this */
if (!g_test_subprocess ())
gtk_init ();
add_array_tests ();
add_cairo_tests ();
add_content_formats_tests ();
add_content_serializer_tests ();
add_cursor_tests ();
add_display_tests ();
add_display_manager_tests ();
add_encoding_tests ();
add_glcontext_tests ();
add_keysyms_tests ();
add_memory_texture_tests ();
add_pixbuf_tests ();
add_rectangle_tests ();
add_rgba_tests ();
add_seat_tests ();
add_texture_threads_tests ();
return g_test_run ();
}

18
testsuite/gdk/gdktests.h Normal file
View File

@@ -0,0 +1,18 @@
#pragma once
void add_array_tests (void);
void add_cairo_tests (void);
void add_content_formats_tests (void);
void add_content_serializer_tests (void);
void add_cursor_tests (void);
void add_display_tests (void);
void add_display_manager_tests (void);
void add_encoding_tests (void);
void add_glcontext_tests (void);
void add_keysyms_tests (void);
void add_memory_texture_tests (void);
void add_pixbuf_tests (void);
void add_rectangle_tests (void);
void add_rgba_tests (void);
void add_seat_tests (void);
void add_texture_threads_tests (void);

View File

@@ -1,5 +1,7 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "gdktests.h"
#define ALL_APIS (GDK_GL_API_GL | GDK_GL_API_GLES) #define ALL_APIS (GDK_GL_API_GL | GDK_GL_API_GLES)
static GdkGLAPI static GdkGLAPI
@@ -68,15 +70,11 @@ test_allowed_backends (gconstpointer data)
g_object_unref (context); g_object_unref (context);
} }
int void
main (int argc, char *argv[]) add_glcontext_tests (void)
{ {
gtk_test_init (&argc, &argv, NULL);
g_test_add_data_func ("/allowed-apis/none", GSIZE_TO_POINTER (0), test_allowed_backends); g_test_add_data_func ("/allowed-apis/none", GSIZE_TO_POINTER (0), test_allowed_backends);
g_test_add_data_func ("/allowed-apis/gl", GSIZE_TO_POINTER (GDK_GL_API_GL), test_allowed_backends); g_test_add_data_func ("/allowed-apis/gl", GSIZE_TO_POINTER (GDK_GL_API_GL), test_allowed_backends);
g_test_add_data_func ("/allowed-apis/gles", GSIZE_TO_POINTER (GDK_GL_API_GLES), test_allowed_backends); g_test_add_data_func ("/allowed-apis/gles", GSIZE_TO_POINTER (GDK_GL_API_GLES), test_allowed_backends);
g_test_add_data_func ("/allowed-apis/all", GSIZE_TO_POINTER (GDK_GL_API_GL | GDK_GL_API_GLES), test_allowed_backends); g_test_add_data_func ("/allowed-apis/all", GSIZE_TO_POINTER (GDK_GL_API_GL | GDK_GL_API_GLES), test_allowed_backends);
return g_test_run ();
} }

View File

@@ -3,6 +3,8 @@
#include "gdk/loaders/gdktiffprivate.h" #include "gdk/loaders/gdktiffprivate.h"
#include "gdk/loaders/gdkjpegprivate.h" #include "gdk/loaders/gdkjpegprivate.h"
#include "gdkinternaltests.h"
static void static void
assert_texture_equal (GdkTexture *t1, assert_texture_equal (GdkTexture *t1,
GdkTexture *t2) GdkTexture *t2)
@@ -118,11 +120,9 @@ test_save_image (gconstpointer test_data)
g_free (path); g_free (path);
} }
int void
main (int argc, char *argv[]) add_image_tests (void)
{ {
(g_test_init) (&argc, &argv, NULL);
g_test_add_data_func ("/image/load/png", "image.png", test_load_image); g_test_add_data_func ("/image/load/png", "image.png", test_load_image);
g_test_add_data_func ("/image/load/png2", "image-gray.png", test_load_image); g_test_add_data_func ("/image/load/png2", "image-gray.png", test_load_image);
g_test_add_data_func ("/image/load/png3", "image-palette.png", test_load_image); g_test_add_data_func ("/image/load/png3", "image-palette.png", test_load_image);
@@ -136,6 +136,4 @@ main (int argc, char *argv[])
g_test_add_data_func ("/image/save/png", "image.png", test_save_image); g_test_add_data_func ("/image/save/png", "image.png", test_save_image);
g_test_add_data_func ("/image/save/tiff", "image.tiff", test_save_image); g_test_add_data_func ("/image/save/tiff", "image.tiff", test_save_image);
g_test_add_data_func ("/image/save/jpeg", "image.jpeg", test_save_image); g_test_add_data_func ("/image/save/jpeg", "image.jpeg", test_save_image);
return g_test_run ();
} }

View File

@@ -1,6 +1,8 @@
#include <locale.h> #include <locale.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "gdktests.h"
static void static void
test_keysyms_basic (void) test_keysyms_basic (void)
{ {
@@ -123,19 +125,12 @@ test_key_unicode (void)
} }
} }
int void
main (int argc, char *argv[]) add_keysyms_tests (void)
{ {
setlocale (LC_ALL, "");
(g_test_init) (&argc, &argv, NULL);
gtk_init ();
g_test_add_func ("/keysyms/basic", test_keysyms_basic); g_test_add_func ("/keysyms/basic", test_keysyms_basic);
g_test_add_func ("/keysyms/void", test_keysyms_void); g_test_add_func ("/keysyms/void", test_keysyms_void);
g_test_add_func ("/keysyms/xf86", test_keysyms_xf86); g_test_add_func ("/keysyms/xf86", test_keysyms_xf86);
g_test_add_func ("/keys/case", test_key_case); g_test_add_func ("/keys/case", test_key_case);
g_test_add_func ("/keys/unicode", test_key_unicode); g_test_add_func ("/keys/unicode", test_key_unicode);
return g_test_run ();
} }

View File

@@ -2,6 +2,8 @@
#include "gsk/gl/gskglrenderer.h" #include "gsk/gl/gskglrenderer.h"
#include "gdktests.h"
#define N 20 #define N 20
static GskRenderer *gl_renderer = NULL; static GskRenderer *gl_renderer = NULL;
@@ -636,31 +638,30 @@ add_test (const char *name,
} }
} }
int static void
main (int argc, char *argv[]) clear_gl_renderer (void)
{ {
int result;
gtk_test_init (&argc, &argv, NULL);
add_test ("/memorytexture/download_1x1", test_download_1x1);
add_test ("/memorytexture/download_4x4", test_download_4x4);
add_test ("/memorytexture/download_192x192", test_download_192x192);
gl_renderer = gsk_gl_renderer_new ();
if (!gsk_renderer_realize (gl_renderer, NULL, NULL))
{
g_clear_object (&gl_renderer);
}
result = g_test_run ();
if (gl_renderer) if (gl_renderer)
{ {
gsk_renderer_unrealize (gl_renderer); gsk_renderer_unrealize (gl_renderer);
g_clear_object (&gl_renderer); g_clear_object (&gl_renderer);
} }
gdk_gl_context_clear_current (); gdk_gl_context_clear_current ();
}
return result;
void
add_memory_texture_tests (void)
{
add_test ("/memorytexture/download_1x1", test_download_1x1);
add_test ("/memorytexture/download_4x4", test_download_4x4);
add_test ("/memorytexture/download_192x192", test_download_192x192);
if (!g_test_subprocess ())
{
gl_renderer = gsk_gl_renderer_new ();
if (!gsk_renderer_realize (gl_renderer, NULL, NULL))
g_clear_object (&gl_renderer);
atexit (clear_gl_renderer);
}
} }

View File

@@ -6,70 +6,84 @@ clipboard_client = executable('clipboard-client',
install: false, install: false,
) )
tests = [ clipboard_test = executable('clipboard',
{ 'name': 'array' }, sources: 'clipboard.c',
{ 'name': 'cairo' }, c_args: common_cflags,
{ 'name': 'clipboard', 'parallel': false, }, dependencies: libgtk_dep,
{ 'name': 'contentformats' }, install: false,
{ 'name': 'contentserializer' }, )
{ 'name': 'cursor' },
{ 'name': 'display' },
{ 'name': 'displaymanager' },
{ 'name': 'encoding' },
{ 'name': 'glcontext' },
{ 'name': 'keysyms' },
{ 'name': 'memorytexture' },
{ 'name': 'pixbuf' },
{ 'name': 'rectangle' },
{ 'name': 'rgba' },
{ 'name': 'seat' },
{ 'name': 'texture-threads' },
]
foreach t : tests test('clipboard', clipboard_test,
test_name = t.get('name') args: [ '--tap', '-k' ],
test_exe = executable(test_name, protocol: 'tap',
sources: '@0@.c'.format(test_name), is_parallel: false,
c_args: common_cflags, env: [
dependencies: libgtk_dep,
install: false,
)
suites = ['gdk'] + t.get('suites', [])
test(test_name, test_exe,
args: [ '--tap', '-k' ],
protocol: 'tap',
is_parallel: t.get('parallel', false),
env: [
'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()), 'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()), 'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()),
'DBUS_SESSION_BUS_ADDRESS=', 'DBUS_SESSION_BUS_ADDRESS=',
], ],
suite: suites, suite: 'gdk',
) )
endforeach
internal_tests = [ test_sources = [
'image', 'array.c',
'texture', 'cairo.c',
'contentformats.c',
'contentserializer.c',
'cursor.c',
'display.c',
'displaymanager.c',
'encoding.c',
'glcontext.c',
'keysyms.c',
'memorytexture.c',
'pixbuf.c',
'rectangle.c',
'rgba.c',
'seat.c',
'texture-threads.c',
'gdktests.c'
] ]
foreach t : internal_tests gdktests = executable('gdktests',
test_exe = executable(t, '@0@.c'.format(t), sources: test_sources,
c_args: common_cflags, c_args: common_cflags,
dependencies: libgtk_static_dep, dependencies: libgtk_dep,
install: false, install: false,
) )
test(t, test_exe, test('gdktests', gdktests,
args: [ '--tap', '-k' ], args: [ '--tap', '-k' ],
protocol: 'tap', protocol: 'tap',
env: [ is_parallel: true,
env: [
'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()), 'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()), 'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()),
'DBUS_SESSION_BUS_ADDRESS=', 'DBUS_SESSION_BUS_ADDRESS=',
], ],
suite: 'gdk', suite: 'gdk',
) )
endforeach
internal_test_sources = [
'image.c',
'texture.c',
'gdkinternaltests.c',
]
gdkinternaltests = executable('gdkinternaltests',
sources: internal_test_sources,
c_args: common_cflags,
dependencies: libgtk_static_dep,
install: false,
)
test('gdkinternaltests', gdkinternaltests,
args: [ '--tap', '-k' ],
protocol: 'tap',
env: [
'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()),
'DBUS_SESSION_BUS_ADDRESS=',
],
suite: 'gdk',
)

View File

@@ -1,5 +1,7 @@
#include <gdk-pixbuf/gdk-pixbuf.h> #include <gdk-pixbuf/gdk-pixbuf.h>
#include "gdktests.h"
static void static void
test_format (gconstpointer d) test_format (gconstpointer d)
{ {
@@ -29,14 +31,9 @@ test_format (gconstpointer d)
g_assert_true (found); g_assert_true (found);
} }
void
int add_pixbuf_tests (void)
main (int argc, char *argv[])
{ {
(g_test_init) (&argc, &argv, NULL);
g_test_add_data_func ("/pixbuf/format/png", "png", test_format); g_test_add_data_func ("/pixbuf/format/png", "png", test_format);
g_test_add_data_func ("/pixbuf/format/jpeg", "jpeg", test_format); g_test_add_data_func ("/pixbuf/format/jpeg", "jpeg", test_format);
return g_test_run ();
} }

View File

@@ -1,6 +1,8 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <cairo-gobject.h> #include <cairo-gobject.h>
#include "gdktests.h"
static void static void
test_rectangle_equal (void) test_rectangle_equal (void)
{ {
@@ -107,18 +109,12 @@ test_rectangle_contains (void)
g_assert_false (gdk_rectangle_contains_point (&b, 10, 6)); g_assert_false (gdk_rectangle_contains_point (&b, 10, 6));
} }
int void
main (int argc, char *argv[]) add_rectangle_tests (void)
{ {
(g_test_init) (&argc, &argv, NULL);
gtk_init ();
g_test_add_func ("/rectangle/equal", test_rectangle_equal); g_test_add_func ("/rectangle/equal", test_rectangle_equal);
g_test_add_func ("/rectangle/intersect", test_rectangle_intersect); g_test_add_func ("/rectangle/intersect", test_rectangle_intersect);
g_test_add_func ("/rectangle/union", test_rectangle_union); g_test_add_func ("/rectangle/union", test_rectangle_union);
g_test_add_func ("/rectangle/type", test_rectangle_type); g_test_add_func ("/rectangle/type", test_rectangle_type);
g_test_add_func ("/rectangle/contains", test_rectangle_contains); g_test_add_func ("/rectangle/contains", test_rectangle_contains);
return g_test_run ();
} }

View File

@@ -1,6 +1,8 @@
#include <locale.h> #include <locale.h>
#include <gdk/gdk.h> #include <gdk/gdk.h>
#include "gdktests.h"
static void static void
test_color_parse (void) test_color_parse (void)
{ {
@@ -207,16 +209,12 @@ test_color_hash (void)
g_assert_cmpuint (hash1, !=, hash2); g_assert_cmpuint (hash1, !=, hash2);
} }
int void
main (int argc, char *argv[]) add_rgba_tests (void)
{ {
(g_test_init) (&argc, &argv, NULL);
g_test_add_func ("/rgba/parse", test_color_parse); g_test_add_func ("/rgba/parse", test_color_parse);
g_test_add_func ("/rgba/parse/nonsense", test_color_parse_nonsense); g_test_add_func ("/rgba/parse/nonsense", test_color_parse_nonsense);
g_test_add_func ("/rgba/to-string", test_color_to_string); g_test_add_func ("/rgba/to-string", test_color_to_string);
g_test_add_func ("/rgba/copy", test_color_copy); g_test_add_func ("/rgba/copy", test_color_copy);
g_test_add_func ("/rgba/hash", test_color_hash); g_test_add_func ("/rgba/hash", test_color_hash);
return g_test_run ();
} }

View File

@@ -1,5 +1,7 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "gdktests.h"
static void static void
test_list_seats (void) test_list_seats (void)
{ {
@@ -124,15 +126,9 @@ test_default_seat (void)
g_list_free (tools); g_list_free (tools);
} }
int void
main (int argc, char *argv[]) add_seat_tests (void)
{ {
(g_test_init) (&argc, &argv, NULL);
gtk_init ();
g_test_add_func ("/seat/list", test_list_seats); g_test_add_func ("/seat/list", test_list_seats);
g_test_add_func ("/seat/default", test_default_seat); g_test_add_func ("/seat/default", test_default_seat);
return g_test_run ();
} }

View File

@@ -2,6 +2,8 @@
#include "gsk/gl/gskglrenderer.h" #include "gsk/gl/gskglrenderer.h"
#include "gdktests.h"
/* This function will be called from a thread and/or the main loop. /* This function will be called from a thread and/or the main loop.
* Textures are threadsafe after all. */ * Textures are threadsafe after all. */
static void static void
@@ -111,12 +113,8 @@ texture_threads (void)
gdk_gl_context_clear_current (); gdk_gl_context_clear_current ();
} }
int void
main (int argc, char *argv[]) add_texture_threads_tests (void)
{ {
gtk_test_init (&argc, &argv, NULL);
g_test_add_func ("/texture-threads", texture_threads); g_test_add_func ("/texture-threads", texture_threads);
return g_test_run ();
} }

View File

@@ -2,6 +2,8 @@
#include "gdk/gdkmemorytextureprivate.h" #include "gdk/gdkmemorytextureprivate.h"
#include "gdkinternaltests.h"
static void static void
compare_pixels (int width, compare_pixels (int width,
int height, int height,
@@ -160,16 +162,11 @@ test_texture_subtexture (void)
g_object_unref (texture); g_object_unref (texture);
} }
int void
main (int argc, char *argv[]) add_texture_tests (void)
{ {
/* We want to use resources from libgtk, so we need gtk initialized */
gtk_test_init (&argc, &argv, NULL);
g_test_add_func ("/texture/from-pixbuf", test_texture_from_pixbuf); g_test_add_func ("/texture/from-pixbuf", test_texture_from_pixbuf);
g_test_add_func ("/texture/from-resource", test_texture_from_resource); g_test_add_func ("/texture/from-resource", test_texture_from_resource);
g_test_add_func ("/texture/save-to-png", test_texture_save_to_png); g_test_add_func ("/texture/save-to-png", test_texture_save_to_png);
g_test_add_func ("/texture/subtexture", test_texture_subtexture); g_test_add_func ("/texture/subtexture", test_texture_subtexture);
return g_test_run ();
} }

View File

@@ -20,6 +20,8 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "gsk/gskrendernodeprivate.h" #include "gsk/gskrendernodeprivate.h"
#include "gskinternaltests.h"
static void static void
test_can_diff_basic (void) test_can_diff_basic (void)
{ {
@@ -95,14 +97,9 @@ test_can_diff_transform (void)
gsk_transform_unref (t2); gsk_transform_unref (t2);
} }
int void
main (int argc, add_diff_tests (void)
char *argv[])
{ {
gtk_test_init (&argc, &argv, NULL);
g_test_add_func ("/node/can-diff/basic", test_can_diff_basic); g_test_add_func ("/node/can-diff/basic", test_can_diff_basic);
g_test_add_func ("/node/can-diff/transform", test_can_diff_transform); g_test_add_func ("/node/can-diff/transform", test_can_diff_transform);
return g_test_run ();
} }

View File

@@ -0,0 +1,36 @@
/*
* Copyright © 2023 Matthias Clasen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gtk/gtk.h>
#include "gskinternaltests.h"
int
main (int argc,
char *argv[])
{
gtk_test_init (&argc, &argv, NULL);
add_diff_tests ();
add_half_float_tests ();
add_rounded_rect_tests ();
add_misc_tests ();
return g_test_run ();
}

View File

@@ -0,0 +1,6 @@
#pragma once
void add_diff_tests (void);
void add_half_float_tests (void);
void add_rounded_rect_tests (void);
void add_misc_tests (void);

34
testsuite/gsk/gsktests.c Normal file
View File

@@ -0,0 +1,34 @@
/*
* Copyright © 2023 Matthias Clasen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gtk/gtk.h>
#include "gsktests.h"
int
main (int argc,
char *argv[])
{
gtk_test_init (&argc, &argv, NULL);
add_transform_tests ();
add_shader_tests ();
return g_test_run ();
}

4
testsuite/gsk/gsktests.h Normal file
View File

@@ -0,0 +1,4 @@
#pragma once
void add_transform_tests (void);
void add_shader_tests (void);

View File

@@ -2,6 +2,8 @@
#include "gsk/gl/fp16private.h" #include "gsk/gl/fp16private.h"
#include "gskinternaltests.h"
static void static void
test_constants (void) test_constants (void)
{ {
@@ -95,14 +97,10 @@ test_many (void)
} }
} }
int void
main (int argc, char *argv[]) add_half_float_tests (void)
{ {
(g_test_init) (&argc, &argv, NULL);
g_test_add_func ("/half-float/constants", test_constants); g_test_add_func ("/half-float/constants", test_constants);
g_test_add_func ("/half-float/roundtrip", test_roundtrip); g_test_add_func ("/half-float/roundtrip", test_roundtrip);
g_test_add_func ("/half-float/many", test_many); g_test_add_func ("/half-float/many", test_many);
return g_test_run ();
} }

View File

@@ -242,69 +242,52 @@ foreach test : node_parser_tests
endif endif
endforeach endforeach
tests = [ test_sources = [
['transform'], 'transform.c',
['shader'], 'shader.c',
'gsktests.c',
] ]
test_cargs = [] gsktests = executable('gsktests',
test_sources,
dependencies: libgtk_dep,
c_args: common_cflags,
)
foreach t : tests test('gsktests', gsktests,
test_name = t.get(0) args: [ '--tap', '-k' ],
test_srcs = ['@0@.c'.format(test_name)] + t.get(1, []) protocol: 'tap',
test_extra_cargs = t.get(2, []) env: [
test_extra_ldflags = t.get(3, [])
test_exe = executable(test_name, test_srcs,
dependencies : libgtk_dep,
c_args : test_cargs + test_extra_cargs + common_cflags,
link_args : test_extra_ldflags,
)
test(test_name, test_exe,
args: [ '--tap', '-k' ],
protocol: 'tap',
env: [
'GSK_RENDERER=cairo', 'GSK_RENDERER=cairo',
'GTK_A11Y=test', 'GTK_A11Y=test',
'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()), 'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()) 'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir())
], ],
suite: 'gsk', suite: 'gsk',
) )
endforeach
internal_tests = [ internal_test_sources = [
[ 'diff' ], 'diff',
[ 'half-float' ], 'half-float',
['rounded-rect'], 'rounded-rect',
['misc'], 'misc',
'gskinternaltests.c',
] ]
foreach t : internal_tests gskinternaltests = executable('gskinternaltests',
test_name = t.get(0) test_sources,
test_srcs = ['@0@.c'.format(test_name)] + t.get(1, []) dependencies: libgtk_static_dep,
test_extra_cargs = t.get(2, []) c_args: common_cflags,
test_extra_ldflags = t.get(3, []) )
test_exe = executable(test_name, test('gskinternaltests', gskinternaltests,
sources: test_srcs, args: [ '--tap', '-k' ],
dependencies : libgtk_static_dep, protocol: 'tap',
c_args : test_cargs + test_extra_cargs + common_cflags, env: [
link_args : test_extra_ldflags,
)
test(test_name, test_exe,
args: [ '--tap', '-k' ],
protocol: 'tap',
env: [
'GSK_RENDERER=cairo', 'GSK_RENDERER=cairo',
'GTK_A11Y=test', 'GTK_A11Y=test',
'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()), 'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()) 'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir())
], ],
suite: 'gsk', suite: 'gsk',
) )
endforeach

View File

@@ -1,6 +1,8 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "gsk/gskrendernodeprivate.h" #include "gsk/gskrendernodeprivate.h"
#include "gskinternaltests.h"
static void static void
test_rendernode_gvalue (void) test_rendernode_gvalue (void)
{ {
@@ -82,15 +84,10 @@ test_conic_gradient_angle (void)
gsk_render_node_unref (node); gsk_render_node_unref (node);
} }
int void
main (int argc, char *argv[]) add_misc_tests (void)
{ {
(g_test_init) (&argc, &argv, NULL);
gtk_init ();
g_test_add_func ("/rendernode/gvalue", test_rendernode_gvalue); g_test_add_func ("/rendernode/gvalue", test_rendernode_gvalue);
g_test_add_func ("/rendernode/border/uniform", test_bordernode_uniform); g_test_add_func ("/rendernode/border/uniform", test_bordernode_uniform);
g_test_add_func ("/rendernode/conic-gradient/angle", test_conic_gradient_angle); g_test_add_func ("/rendernode/conic-gradient/angle", test_conic_gradient_angle);
return g_test_run ();
} }

View File

@@ -22,6 +22,8 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <gsk/gskroundedrectprivate.h> #include <gsk/gskroundedrectprivate.h>
#include "gskinternaltests.h"
static void static void
test_contains_rect (void) test_contains_rect (void)
{ {
@@ -160,17 +162,12 @@ test_to_float (void)
g_assert_true (flt[10] == 9. && flt[11] == 11.); g_assert_true (flt[10] == 9. && flt[11] == 11.);
} }
int void
main (int argc, add_rounded_rect_tests (void)
char *argv[])
{ {
gtk_test_init (&argc, &argv, NULL);
g_test_add_func ("/rounded-rect/contains-rect", test_contains_rect); g_test_add_func ("/rounded-rect/contains-rect", test_contains_rect);
g_test_add_func ("/rounded-rect/intersects-rect", test_intersects_rect); g_test_add_func ("/rounded-rect/intersects-rect", test_intersects_rect);
g_test_add_func ("/rounded-rect/contains-point", test_contains_point); g_test_add_func ("/rounded-rect/contains-point", test_contains_point);
g_test_add_func ("/rounded-rect/is-circular", test_is_circular); g_test_add_func ("/rounded-rect/is-circular", test_is_circular);
g_test_add_func ("/rounded-rect/to-float", test_to_float); g_test_add_func ("/rounded-rect/to-float", test_to_float);
return g_test_run ();
} }

View File

@@ -19,6 +19,8 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "gsktests.h"
/* shader fragment as found in nature */ /* shader fragment as found in nature */
const char shader0[] = const char shader0[] =
"// author: bobylito\n" "// author: bobylito\n"
@@ -290,16 +292,11 @@ test_compile (void)
g_bytes_unref (bytes); g_bytes_unref (bytes);
} }
int void
main (int argc, add_shader_tests (void)
char *argv[])
{ {
gtk_test_init (&argc, &argv, NULL);
g_test_add_func ("/shader/create/simple", test_create_simple); 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/create/data", test_create_data);
g_test_add_func ("/shader/format-args", test_format_args); g_test_add_func ("/shader/format-args", test_format_args);
g_test_add_func ("/shader/compile", test_compile); g_test_add_func ("/shader/compile", test_compile);
return g_test_run ();
} }

View File

@@ -21,6 +21,8 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "gsktests.h"
#define EPSILON (1.f / 1024 / 32) /* 2^-15 */ #define EPSILON (1.f / 1024 / 32) /* 2^-15 */
/* macros stolen from graphene testsuite, so they get to keep their names */ /* macros stolen from graphene testsuite, so they get to keep their names */
@@ -843,12 +845,9 @@ test_rotate3d_transform (void)
gsk_transform_unref (t2); gsk_transform_unref (t2);
} }
int void
main (int argc, add_transform_tests (void)
char *argv[])
{ {
gtk_test_init (&argc, &argv, NULL);
g_test_add_func ("/transform/conversions/simple", test_conversions_simple); g_test_add_func ("/transform/conversions/simple", test_conversions_simple);
g_test_add_func ("/transform/conversions/transformed", test_conversions_transformed); g_test_add_func ("/transform/conversions/transformed", test_conversions_transformed);
g_test_add_func ("/transform/identity", test_identity); g_test_add_func ("/transform/identity", test_identity);
@@ -865,6 +864,4 @@ main (int argc,
g_test_add_func ("/transform/perspective", test_perspective_transform); g_test_add_func ("/transform/perspective", test_perspective_transform);
g_test_add_func ("/transform/rotate", test_rotate_transform); g_test_add_func ("/transform/rotate", test_rotate_transform);
g_test_add_func ("/transform/rotate3d", test_rotate3d_transform); g_test_add_func ("/transform/rotate3d", test_rotate3d_transform);
return g_test_run ();
} }