forked from AuroraMiddleware/gtk
Add some more transform tests
Test that gsk_transform_to_affine works.
This commit is contained in:
parent
c391cf38e2
commit
809299f9e4
@ -524,6 +524,49 @@ test_axis_aligned (void)
|
||||
gsk_transform_unref (transform);
|
||||
}
|
||||
|
||||
static void
|
||||
test_to_affine (void)
|
||||
{
|
||||
GskTransform *transform;
|
||||
float sx, sy, dx, dy;
|
||||
|
||||
transform = gsk_transform_scale (NULL, 10.0, 5.0);
|
||||
gsk_transform_to_affine (transform, &sx, &sy, &dx, &dy);
|
||||
gsk_transform_unref (transform);
|
||||
|
||||
g_assert_cmpfloat (sx, ==, 10.0);
|
||||
g_assert_cmpfloat (sy, ==, 5.0);
|
||||
g_assert_cmpfloat (dx, ==, 0.0);
|
||||
g_assert_cmpfloat (dy, ==, 0.0);
|
||||
|
||||
transform = gsk_transform_translate (NULL, &GRAPHENE_POINT_INIT (10.0, 5.0));
|
||||
gsk_transform_to_affine (transform, &sx, &sy, &dx, &dy);
|
||||
gsk_transform_unref (transform);
|
||||
|
||||
g_assert_cmpfloat (sx, ==, 1.0);
|
||||
g_assert_cmpfloat (sy, ==, 1.0);
|
||||
g_assert_cmpfloat (dx, ==, 10.0);
|
||||
g_assert_cmpfloat (dy, ==, 5.0);
|
||||
|
||||
transform = gsk_transform_translate (gsk_transform_scale (NULL, 2.0, 3.0), &GRAPHENE_POINT_INIT (10.0, 5.0));
|
||||
gsk_transform_to_affine (transform, &sx, &sy, &dx, &dy);
|
||||
gsk_transform_unref (transform);
|
||||
|
||||
g_assert_cmpfloat (sx, ==, 2.0);
|
||||
g_assert_cmpfloat (sy, ==, 3.0);
|
||||
g_assert_cmpfloat (dx, ==, 2.0 * 10.0);
|
||||
g_assert_cmpfloat (dy, ==, 3.0 * 5.0);
|
||||
|
||||
transform = gsk_transform_scale (gsk_transform_translate (NULL, &GRAPHENE_POINT_INIT (10.0, 5.0)), 2.0, 3.0);
|
||||
gsk_transform_to_affine (transform, &sx, &sy, &dx, &dy);
|
||||
gsk_transform_unref (transform);
|
||||
|
||||
g_assert_cmpfloat (sx, ==, 2.0);
|
||||
g_assert_cmpfloat (sy, ==, 3.0);
|
||||
g_assert_cmpfloat (dx, ==, 10.0);
|
||||
g_assert_cmpfloat (dy, ==, 5.0);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char *argv[])
|
||||
@ -537,6 +580,7 @@ main (int argc,
|
||||
g_test_add_func ("/transform/invert", test_invert);
|
||||
g_test_add_func ("/transform/print-parse", test_print_parse);
|
||||
g_test_add_func ("/transform/check-axis-aligneness", test_axis_aligned);
|
||||
g_test_add_func ("/transform/to-affine", test_to_affine);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user