forked from AuroraMiddleware/gtk
Merge branch 'transform-tests' into 'master'
Transform tests See merge request GNOME/gtk!910
This commit is contained in:
commit
206970c1e8
@ -173,7 +173,7 @@ static void
|
||||
gsk_identity_transform_print (GskTransform *transform,
|
||||
GString *string)
|
||||
{
|
||||
g_string_append (string, "identity");
|
||||
g_string_append (string, "none");
|
||||
}
|
||||
|
||||
static GskTransform *
|
||||
@ -1412,7 +1412,7 @@ gsk_transform_to_matrix (GskTransform *self,
|
||||
* |[<!-- language="plain" -->
|
||||
* | xx yx | | a b 0 |
|
||||
* | xy yy | = | c d 0 |
|
||||
* | x0 y0 | | tx ty 1 |
|
||||
* | dx dy | | tx ty 1 |
|
||||
* ]|
|
||||
*
|
||||
* This function can be used to convert between a #GskTransform
|
||||
|
@ -165,3 +165,36 @@ foreach test : node_parser_tests
|
||||
suite: 'gsk')
|
||||
endif
|
||||
endforeach
|
||||
|
||||
tests = [
|
||||
['transform'],
|
||||
]
|
||||
|
||||
test_cargs = []
|
||||
|
||||
foreach t : tests
|
||||
test_name = t.get(0)
|
||||
test_srcs = ['@0@.c'.format(test_name)] + t.get(1, [])
|
||||
test_extra_cargs = t.get(2, [])
|
||||
test_extra_ldflags = t.get(3, [])
|
||||
|
||||
test_exe = executable(test_name, test_srcs,
|
||||
c_args : test_cargs + test_extra_cargs,
|
||||
link_args : test_extra_ldflags,
|
||||
dependencies : libgtk_dep,
|
||||
install: get_option('install-tests'),
|
||||
install_dir: testexecdir)
|
||||
|
||||
test(test_name, test_exe,
|
||||
args: [ '--tap', '-k' ],
|
||||
env: [ 'GIO_USE_VOLUME_MONITOR=unix',
|
||||
'GSETTINGS_BACKEND=memory',
|
||||
'GTK_CSD=1',
|
||||
'G_ENABLE_DIAGNOSTIC=0',
|
||||
'GSK_RENDERER=cairo',
|
||||
'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
|
||||
'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()),
|
||||
'GSETTINGS_SCHEMA_DIR=@0@'.format(gtk_schema_build_dir),
|
||||
],
|
||||
suite: 'gsk')
|
||||
endforeach
|
||||
|
@ -279,6 +279,59 @@ test_invert (void)
|
||||
}
|
||||
}
|
||||
|
||||
/* some trivialities around identity transforms */
|
||||
static void
|
||||
test_identity (void)
|
||||
{
|
||||
GskTransform *s, *t, *u, *v, *w, *x;
|
||||
char *string;
|
||||
float a, b, c, d, tx, ty;
|
||||
gboolean res;
|
||||
|
||||
s = gsk_transform_new ();
|
||||
t = gsk_transform_new ();
|
||||
u = gsk_transform_transform (gsk_transform_ref (s), NULL);
|
||||
|
||||
g_assert_cmpint (gsk_transform_get_category (s), ==, GSK_TRANSFORM_CATEGORY_IDENTITY);
|
||||
g_assert_cmpint (gsk_transform_get_category (t), ==, GSK_TRANSFORM_CATEGORY_IDENTITY);
|
||||
g_assert_cmpint (gsk_transform_get_category (u), ==, GSK_TRANSFORM_CATEGORY_IDENTITY);
|
||||
|
||||
g_assert_true (gsk_transform_equal (s, t));
|
||||
g_assert_true (gsk_transform_equal (t, u));
|
||||
g_assert_true (gsk_transform_equal (s, u));
|
||||
|
||||
v = gsk_transform_transform (gsk_transform_ref (s), t);
|
||||
|
||||
g_assert_cmpint (gsk_transform_get_category (v), ==, GSK_TRANSFORM_CATEGORY_IDENTITY);
|
||||
|
||||
w = gsk_transform_invert (gsk_transform_ref (v));
|
||||
g_assert_cmpint (gsk_transform_get_category (w), ==, GSK_TRANSFORM_CATEGORY_IDENTITY);
|
||||
|
||||
string = gsk_transform_to_string (s);
|
||||
res = gsk_transform_parse (string, &x);
|
||||
|
||||
g_assert_true (res);
|
||||
g_assert_cmpint (gsk_transform_get_category (x), ==, GSK_TRANSFORM_CATEGORY_IDENTITY);
|
||||
|
||||
gsk_transform_to_2d (s, &a, &b, &c, &d, &tx, &ty);
|
||||
|
||||
g_assert_cmpfloat (a, ==, 1.0f);
|
||||
g_assert_cmpfloat (b, ==, 0.0f);
|
||||
g_assert_cmpfloat (c, ==, 0.0f);
|
||||
g_assert_cmpfloat (d, ==, 1.0f);
|
||||
g_assert_cmpfloat (tx, ==, 0.0f);
|
||||
g_assert_cmpfloat (ty, ==, 0.f);
|
||||
|
||||
gsk_transform_unref (s);
|
||||
gsk_transform_unref (t);
|
||||
gsk_transform_unref (u);
|
||||
gsk_transform_unref (v);
|
||||
gsk_transform_unref (w);
|
||||
gsk_transform_unref (x);
|
||||
|
||||
g_free (string);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char *argv[])
|
||||
@ -288,6 +341,7 @@ main (int argc,
|
||||
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/invert", test_invert);
|
||||
g_test_add_func ("/transform/identity", test_identity);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
@ -54,7 +54,6 @@ tests = [
|
||||
['textbuffer'],
|
||||
['textiter'],
|
||||
['theme-validate'],
|
||||
['transform'],
|
||||
['treelistmodel'],
|
||||
['treemodel', ['treemodel.c', 'liststore.c', 'treestore.c', 'filtermodel.c',
|
||||
'modelrefcount.c', 'sortmodel.c', 'gtktreemodelrefcount.c']],
|
||||
|
Loading…
Reference in New Issue
Block a user