1 /* ADG - Automatic Drawing Generation
2 * Copyright (C) 2007,2008,2009,2010,2011,2012,2013 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.
21 #include "test-internal.h"
25 _adg_test_local_mix(void)
30 /* Check default local mix method */
31 arrow
= adg_arrow_new();
32 entity
= (AdgEntity
*) arrow
;
33 g_assert_cmpint(adg_entity_get_local_mix(entity
), ==, ADG_MIX_PARENT
);
34 adg_entity_destroy(entity
);
36 /* Check local mix method overriding */
37 arrow
= g_object_new(ADG_TYPE_ARROW
, "local-mix", ADG_MIX_DISABLED
, NULL
);
38 entity
= (AdgEntity
*) arrow
;
39 g_assert_cmpint(adg_entity_get_local_mix(entity
), ==, ADG_MIX_DISABLED
);
40 adg_entity_destroy(entity
);
42 /* Check default mix using GObject methods */
43 arrow
= g_object_new(ADG_TYPE_ARROW
, NULL
);
44 entity
= (AdgEntity
*) arrow
;
45 g_assert_cmpint(adg_entity_get_local_mix(entity
), ==, ADG_MIX_PARENT
);
46 adg_entity_destroy(entity
);
53 gdouble valid_value
, invalid_value
;
56 valid_value
= -G_PI_2
;
57 invalid_value
= G_PI
+ 1;
58 arrow
= adg_arrow_new();
60 /* Using the public APIs */
61 adg_arrow_set_angle(arrow
, valid_value
);
62 angle
= adg_arrow_get_angle(arrow
);
63 g_assert_cmpfloat(angle
, ==, valid_value
);
65 adg_arrow_set_angle(arrow
, -G_PI
);
66 angle
= adg_arrow_get_angle(arrow
);
67 g_assert_cmpfloat(angle
, ==, G_PI
);
69 adg_arrow_set_angle(arrow
, invalid_value
);
70 angle
= adg_arrow_get_angle(arrow
);
71 g_assert_cmpfloat(angle
, !=, invalid_value
);
73 /* Using GObject property methods */
74 g_object_set(arrow
, "angle", valid_value
, NULL
);
75 g_object_get(arrow
, "angle", &angle
, NULL
);
76 g_assert_cmpfloat(angle
, ==, valid_value
);
78 g_object_set(arrow
, "angle", -G_PI
, NULL
);
79 g_object_get(arrow
, "angle", &angle
, NULL
);
80 g_assert_cmpfloat(angle
, ==, G_PI
);
82 g_object_set(arrow
, "angle", invalid_value
, NULL
);
83 g_object_get(arrow
, "angle", &angle
, NULL
);
84 g_assert_cmpfloat(angle
, !=, invalid_value
);
86 adg_entity_destroy((AdgEntity
*) arrow
);
91 main(int argc
, char *argv
[])
93 adg_test_init(&argc
, &argv
);
95 adg_test_add_func("/adg/arrow/local-mix", _adg_test_local_mix
);
96 adg_test_add_func("/adg/arrow/angle", _adg_test_angle
);