Merge branch 'test-protocol' into 'master'

Test protocol: TAP

See merge request GNOME/gtk!1543
This commit is contained in:
Matthias Clasen
2020-03-20 18:12:09 +00:00
16 changed files with 92 additions and 48 deletions

View File

@@ -566,13 +566,12 @@ get_renderer_fallback (GdkSurface *surface)
}
static struct {
gboolean verbose;
GType (* get_renderer) (GdkSurface *surface);
} renderer_possibilities[] = {
{ TRUE, get_renderer_for_display },
{ TRUE, get_renderer_for_env_var },
{ FALSE, get_renderer_for_backend },
{ FALSE, get_renderer_fallback },
{ get_renderer_for_display },
{ get_renderer_for_env_var },
{ get_renderer_for_backend },
{ get_renderer_fallback },
};
/**
@@ -591,7 +590,6 @@ gsk_renderer_new_for_surface (GdkSurface *surface)
GType renderer_type;
GskRenderer *renderer;
GError *error = NULL;
gboolean verbose = FALSE;
guint i;
g_return_val_if_fail (GDK_IS_SURFACE (surface), NULL);
@@ -602,30 +600,22 @@ gsk_renderer_new_for_surface (GdkSurface *surface)
if (renderer_type == G_TYPE_INVALID)
continue;
/* If a renderer is selected that's marked as verbose, start printing
* information to stdout.
*/
verbose |= renderer_possibilities[i].verbose;
renderer = g_object_new (renderer_type, NULL);
if (gsk_renderer_realize (renderer, surface, &error))
{
if (verbose || GSK_RENDERER_DEBUG_CHECK (renderer, RENDERER))
{
g_print ("Using renderer of type '%s' for surface '%s'\n",
G_OBJECT_TYPE_NAME (renderer),
G_OBJECT_TYPE_NAME (surface));
}
GSK_RENDERER_NOTE (renderer, RENDERER,
g_message ("Using renderer of type '%s' for surface '%s'\n",
G_OBJECT_TYPE_NAME (renderer),
G_OBJECT_TYPE_NAME (surface)));
return renderer;
}
if (verbose || GSK_RENDERER_DEBUG_CHECK (renderer, RENDERER))
{
g_print ("Failed to realize renderer of type '%s' for surface '%s': %s\n",
GSK_RENDERER_NOTE (renderer, RENDERER,
g_message ("Failed to realize renderer of type '%s' for surface '%s': %s\n",
G_OBJECT_TYPE_NAME (renderer),
G_OBJECT_TYPE_NAME (surface),
error->message);
}
error->message));
g_object_unref (renderer);
g_clear_error (&error);
}

View File

@@ -57,17 +57,24 @@ my_button_class_init (MyButtonClass *class)
my_button_accessible_get_type ());
}
int main (int argc, char *argv[])
static void
test_derive (void)
{
GtkWidget *widget;
GtkAccessible *accessible;
gtk_init ();
widget = GTK_WIDGET (g_object_new (my_button_get_type (), NULL));
accessible = GTK_ACCESSIBLE (gtk_widget_get_accessible (widget));
g_assert (G_TYPE_CHECK_INSTANCE_TYPE (accessible, my_button_accessible_get_type ()));
return 0;
}
int
main (int argc, char *argv[])
{
gtk_test_init (&argc, &argv, NULL);
g_test_add_func ("/derive", test_derive);
return g_test_run ();
}

View File

@@ -52,6 +52,7 @@ foreach t: a11y_state_tests
test (t + ' state',
a11y_dump_bin,
args: [ '--tap', '-k', ui_path ],
protocol: 'tap',
env: [
'GIO_USE_VOLUME_MONITOR=unix',
'GSETTINGS_BACKEND=memory',
@@ -86,6 +87,7 @@ foreach t: a11y_tests
install_dir: testexecdir,
dependencies: libgtk_dep),
args: [ '--tap', '-k', ],
protocol: 'tap',
timeout: 120,
env: [ 'GIO_USE_VOLUME_MONITOR=unix',
'GSETTINGS_BACKEND=memory',

View File

@@ -11,6 +11,7 @@ test_change = executable(
)
test('change', test_change,
args: [ '--tap', '-k' ],
protocol: 'tap',
env: [ 'GIO_USE_VOLUME_MONITOR=unix',
'GSETTINGS_BACKEND=memory',
'GDK_DEBUG=default-settings',

View File

@@ -13,6 +13,7 @@ test_api = executable('api', 'api.c',
install_dir: testexecdir)
test('api', test_api,
args: ['--tap', '-k' ],
protocol: 'tap',
env: [ 'GIO_USE_VOLUME_MONITOR=unix',
'GSETTINGS_BACKEND=memory',
'GDK_DEBUG=default-settings',
@@ -31,6 +32,7 @@ test_data = executable('data', ['data.c', '../../gtk/css/gtkcssdataurl.c'],
install_dir: testexecdir)
test('data', test_data,
args: ['--tap', '-k' ],
protocol: 'tap',
env: [ 'GIO_USE_VOLUME_MONITOR=unix',
'GSETTINGS_BACKEND=memory',
'GDK_DEBUG=default-settings',
@@ -50,7 +52,7 @@ if get_option('install-tests')
install_dir: testdatadir)
endif
if get_option ('profiler')
if false and get_option ('profiler')
test('performance-adwaita', test_performance,
args: [ '--mark', 'css validation',

View File

@@ -8,6 +8,7 @@ test_nodes = executable('test-css-nodes', 'test-css-nodes.c',
dependencies: libgtk_dep)
test('nodes', test_nodes,
args: [ '--tap', '-k' ],
protocol: 'tap',
env: [ 'GIO_USE_VOLUME_MONITOR=unix',
'GSETTINGS_BACKEND=memory',
'GDK_DEBUG=default-settings',

View File

@@ -465,6 +465,7 @@ foreach testname : test_data
'-k',
join_paths(meson.current_source_dir(), testname),
],
protocol: 'tap',
env: [ 'GIO_USE_VOLUME_MONITOR=unix',
'GSETTINGS_BACKEND=memory',
'GDK_DEBUG=default-settings',

View File

@@ -18,6 +18,7 @@ test_style = executable(
)
test('style', test_style,
args: [ '--tap', '-k' ],
protocol: 'tap',
env: [ 'GIO_USE_VOLUME_MONITOR=unix',
'GSETTINGS_BACKEND=memory',
'GDK_DEBUG=default-settings',

View File

@@ -21,6 +21,7 @@ foreach t : tests
test(t, test_exe,
args: [ '--tap', '-k' ],
protocol: 'tap',
env: [ 'GIO_USE_VOLUME_MONITOR=unix',
'GSETTINGS_BACKEND=memory',
'GDK_DEBUG=default-settings',

View File

@@ -205,6 +205,7 @@ foreach t : tests
test(test_name, test_exe,
args: [ '--tap', '-k' ],
protocol: 'tap',
env: [ 'GIO_USE_VOLUME_MONITOR=unix',
'GSETTINGS_BACKEND=memory',
'GDK_DEBUG=default-settings',

View File

@@ -1,21 +1,22 @@
#include <gtk/gtk.h>
static void
test_type (GType t)
test_type (gconstpointer data)
{
GType t = *(GType *)data;
GtkWidget *w;
AtkObject *a;
if (g_type_is_a (t, GTK_TYPE_WIDGET))
{
w = (GtkWidget *)g_object_new (t, NULL);
a = gtk_widget_get_accessible (w);
w = (GtkWidget *)g_object_new (t, NULL);
if (g_type_is_a (t, G_TYPE_INITIALLY_UNOWNED))
g_object_ref_sink (w);
g_assert (GTK_IS_ACCESSIBLE (a));
g_assert (gtk_accessible_get_widget (GTK_ACCESSIBLE (a)) == w);
a = gtk_widget_get_accessible (w);
g_object_unref (w);
}
g_assert (GTK_IS_ACCESSIBLE (a));
g_assert (gtk_accessible_get_widget (GTK_ACCESSIBLE (a)) == w);
g_object_unref (w);
}
int
@@ -24,12 +25,25 @@ main (int argc, char *argv[])
const GType *tp;
guint i, n;
gtk_init ();
gtk_test_init (&argc, &argv, NULL);
gtk_test_register_all_types ();
tp = gtk_test_list_all_types (&n);
for (i = 0; i < n; i++)
test_type (tp[i]);
{
char *testname;
return 0;
if (!g_type_is_a (tp[i], GTK_TYPE_WIDGET) ||
G_TYPE_IS_ABSTRACT (tp[i]) ||
!G_TYPE_IS_INSTANTIATABLE (tp[i]))
continue;
testname = g_strdup_printf ("/Accessible/%s", g_type_name (tp[i]));
g_test_add_data_func (testname, &tp[i], test_type);
g_free (testname);
}
return g_test_run ();
}

View File

@@ -109,6 +109,7 @@ foreach t : tests
test(test_name, test_exe,
args: [ '--tap', '-k' ],
#protocol: 'tap',
env: [ 'GIO_USE_VOLUME_MONITOR=unix',
'GSETTINGS_BACKEND=memory',
'GDK_DEBUG=default-settings',
@@ -134,6 +135,7 @@ if add_languages('cpp', required: false)
install_dir: testexecdir)
test('c++ keywords', test_exe,
args: [ '--tap', '-k' ],
#protocol: 'tap',
env: [ 'GIO_USE_VOLUME_MONITOR=unix',
'GSETTINGS_BACKEND=memory',
'GDK_DEBUG=default-settings',
@@ -206,7 +208,7 @@ if get_option('install-tests')
endif
if get_option ('profiler')
if false and get_option ('profiler')
test('performance-layout', test_performance,
args: [ '--mark', 'size allocation', join_paths(meson.current_build_dir(), '../../demos/widget-factory/gtk4-widget-factory') ],
@@ -214,10 +216,6 @@ if get_option ('profiler')
'GSETTINGS_SCHEMA_DIR=@0@'.format(gtk_schema_build_dir) ],
suite: [ 'gtk' ])
endif
if get_option ('profiler')
test('performance-snapshot', test_performance,
args: [ '--mark', 'widget snapshot', join_paths(meson.current_build_dir(), '../../demos/widget-factory/gtk4-widget-factory') ],
env: [ 'GTK_THEME=Empty',

View File

@@ -110,6 +110,7 @@ delete (GtkRbTree *tree,
gtk_rb_tree_remove (tree, node);
}
#if 0
static guint
print_node (GtkRbTree *tree,
Node *node,
@@ -136,6 +137,7 @@ print (GtkRbTree *tree)
{
print_node (tree, gtk_rb_tree_get_root (tree), 0, "", 0);
}
#endif
static void
test_crash (void)
@@ -147,7 +149,7 @@ test_crash (void)
for (i = 0; i < 300; i++)
add (tree, i);
print (tree);
//print (tree);
delete (tree, 144);
add (tree, 56);
delete (tree, 113);
@@ -267,7 +269,7 @@ test_crash (void)
delete (tree, 12);
add (tree, 20);
delete (tree, 68);
print (tree);
//print (tree);
delete (tree, 102);
gtk_rb_tree_unref (tree);

View File

@@ -45,8 +45,10 @@
<property name="width_request">144</property>
<property name="height_request">70</property>
<layout>
<!-- FIXME: these don't exist anymore
<property name="x">0</property>
<property name="y">0</property>
-->
</layout>
</object>
</child>
@@ -58,8 +60,10 @@
<property name="width_request">120</property>
<property name="height_request">46</property>
<layout>
<!-- FIXME: these don't exist anymore
<property name="x">12</property>
<property name="y">12</property>
-->
</layout>
</object>
</child>
@@ -77,8 +81,10 @@
<property name="width_request">144</property>
<property name="height_request">70</property>
<layout>
<!-- FIXME: these don't exist anymore
<property name="x">0</property>
<property name="y">0</property>
-->
</layout>
</object>
</child>
@@ -90,8 +96,10 @@
<property name="width_request">120</property>
<property name="height_request">46</property>
<layout>
<!-- FIXME: these don't exist anymore
<property name="x">12</property>
<property name="y">12</property>
-->
</layout>
</object>
</child>

View File

@@ -57,11 +57,14 @@ static const GOptionEntry test_args[] = {
{ NULL }
};
static gboolean using_tap;
static gboolean
parse_command_line (int *argc, char ***argv)
{
GError *error = NULL;
GOptionContext *context;
int i;
context = g_option_context_new ("- run GTK reftests");
g_option_context_add_main_entries (context, test_args, NULL);
@@ -73,6 +76,12 @@ parse_command_line (int *argc, char ***argv)
return FALSE;
}
for (i = 0; i < *argc; i++)
{
if (strcmp ((*argv)[i], "--tap") == 0)
using_tap = TRUE;
}
gtk_test_init (argc, argv);
if (g_strcmp0 (arg_direction, "rtl") == 0)
@@ -379,6 +388,7 @@ int
main (int argc, char **argv)
{
const char *basedir;
int result;
/* I don't want to fight fuzzy scaling algorithms in GPUs,
* so unless you explicitly set it to something else, we
@@ -424,6 +434,11 @@ main (int argc, char **argv)
*/
chdir (basedir);
return g_test_run ();
result = g_test_run ();
if (using_tap)
return 0;
return result;
}

View File

@@ -436,10 +436,10 @@ foreach testname : testdata
test('reftest ' + testname, gtk_reftest,
args: [ '--tap',
'-k',
'--verbose',
'-o', join_paths(meson.current_build_dir(), 'output'),
join_paths(meson.current_source_dir(), testname),
],
protocol: 'tap',
env: [ 'GIO_USE_VOLUME_MONITOR=unix',
'GSETTINGS_BACKEND=memory',
'GSETTINGS_SCHEMA_DIR=@0@'.format(gtk_schema_build_dir),