1 /* ADG - Automatic Drawing Generation
2 * Copyright (C) 2007-2021 Nicola Fontana <ntd at entidi.it>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
26 _adg_property_factor(void)
28 AdgAlignment
*alignment
;
29 CpmlPair null_factor
, identity_factor
;
30 const CpmlPair
*factor
;
33 alignment
= adg_alignment_new(NULL
);
36 identity_factor
.x
= 1;
37 identity_factor
.y
= 1;
39 /* By default, the alignment should be initialized with a null factor */
40 factor
= adg_alignment_get_factor(alignment
);
41 g_assert_true(cpml_pair_equal(factor
, &null_factor
));
43 /* Using the public APIs */
44 adg_alignment_set_factor(alignment
, &identity_factor
);
45 factor
= adg_alignment_get_factor(alignment
);
46 g_assert_true(cpml_pair_equal(factor
, &identity_factor
));
48 adg_alignment_set_factor_explicit(alignment
, 0, 0);
49 factor
= adg_alignment_get_factor(alignment
);
50 g_assert_true(cpml_pair_equal(factor
, &null_factor
));
52 adg_alignment_set_factor(alignment
, NULL
);
53 factor
= adg_alignment_get_factor(alignment
);
54 g_assert_true(cpml_pair_equal(factor
, &null_factor
));
56 /* Using GObject property methods */
57 g_object_set(alignment
, "factor", &identity_factor
, NULL
);
58 g_object_get(alignment
, "factor", &factor_dup
, NULL
);
59 g_assert_true(cpml_pair_equal(factor_dup
, &identity_factor
));
62 g_object_set(alignment
, "factor", NULL
, NULL
);
63 g_object_get(alignment
, "factor", &factor_dup
, NULL
);
64 g_assert_true(cpml_pair_equal(factor_dup
, &identity_factor
));
67 g_object_set(alignment
, "factor", &null_factor
, NULL
);
68 g_object_get(alignment
, "factor", &factor_dup
, NULL
);
69 g_assert_true(cpml_pair_equal(factor_dup
, &null_factor
));
72 g_object_unref(alignment
);
77 main(int argc
, char *argv
[])
79 AdgAlignment
*alignment
;
81 adg_test_init(&argc
, &argv
);
83 adg_test_add_object_checks("/adg/alignment/type/object", ADG_TYPE_ALIGNMENT
);
84 adg_test_add_entity_checks("/adg/alignment/type/entity", ADG_TYPE_ALIGNMENT
);
85 adg_test_add_container_checks("/adg/alignment/type/container", ADG_TYPE_ALIGNMENT
);
87 alignment
= adg_alignment_new_explicit(0.5, 0.5);
88 adg_container_add(ADG_CONTAINER(alignment
), ADG_ENTITY(adg_logo_new()));
89 adg_test_add_global_space_checks("/adg/alignment/behavior/global-space", alignment
);
90 alignment
= adg_alignment_new_explicit(0.5, 0.5);
91 adg_container_add(ADG_CONTAINER(alignment
), ADG_ENTITY(adg_logo_new()));
92 adg_test_add_local_space_checks("/adg/alignment/behavior/local-space", alignment
);
94 g_test_add_func("/adg/alignment/property/factor", _adg_property_factor
);