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_behavior_misc(void)
29 AdgTableRow
*row
, *row2
;
31 const CpmlExtents
*extents
;
35 table
= adg_table_new();
36 row
= adg_table_row_new(table
);
37 layout
.is_defined
= 0;
40 g_assert_null(adg_table_row_get_table(NULL
));
41 g_assert_null(adg_table_row_new_before(NULL
));
42 g_assert_null(adg_table_row_size_request(NULL
));
43 g_assert_null(adg_table_row_get_extents(NULL
));
44 g_assert_null(adg_table_row_arrange(NULL
, &layout
));
45 g_assert_null(adg_table_row_arrange(row
, &layout
));
46 g_assert_null(adg_table_row_arrange(row
, NULL
));
47 adg_table_row_free(NULL
);
49 g_assert_true(adg_table_row_get_table(row
) == table
);
51 row2
= adg_table_row_new_before(row
);
52 g_assert_true(adg_table_row_get_table(row2
) == table
);
53 adg_table_row_free(row2
);
55 extents
= adg_table_row_get_extents(row
);
56 g_assert_nonnull(extents
);
57 g_assert_false(extents
->is_defined
);
59 size
= adg_table_row_size_request(row
);
60 g_assert_nonnull(size
);
61 adg_assert_isapprox(size
->x
, 0);
62 adg_assert_isapprox(size
->y
, 0);
64 extents
= adg_table_row_get_extents(row
);
65 g_assert_nonnull(extents
);
66 g_assert_false(extents
->is_defined
);
68 adg_table_row_set_height(row
, 12);
70 size
= adg_table_row_size_request(row
);
71 g_assert_nonnull(size
);
72 adg_assert_isapprox(size
->x
, 0);
73 adg_assert_isapprox(size
->y
, 12);
75 cell
= adg_table_cell_new_full(row
, 34, "name", "title", FALSE
);
76 g_assert_nonnull(cell
);
77 size
= adg_table_row_size_request(row
);
78 g_assert_nonnull(size
);
79 adg_assert_isapprox(size
->x
, 34);
80 adg_assert_isapprox(size
->y
, 12);
82 layout
.is_defined
= 1;
87 extents
= adg_table_row_arrange(row
, &layout
);
88 g_assert_nonnull(extents
);
89 g_assert_true(extents
->is_defined
);
90 adg_assert_isapprox(extents
->org
.x
, 12);
91 adg_assert_isapprox(extents
->org
.y
, 34);
92 adg_assert_isapprox(extents
->size
.x
, 34);
93 adg_assert_isapprox(extents
->size
.y
, 12);
96 extents
= adg_table_row_arrange(row
, &layout
);
97 g_assert_nonnull(extents
);
98 g_assert_true(extents
->is_defined
);
99 adg_assert_isapprox(extents
->size
.x
, 56);
100 adg_assert_isapprox(extents
->size
.y
, 12);
104 extents
= adg_table_row_arrange(row
, &layout
);
105 g_assert_nonnull(extents
);
106 g_assert_true(extents
->is_defined
);
107 adg_assert_isapprox(extents
->size
.x
, 56);
108 adg_assert_isapprox(extents
->size
.y
, 78);
110 adg_entity_destroy(ADG_ENTITY(table
));
114 _adg_property_height(void)
120 adg_table_row_set_height(NULL
, 1);
121 adg_table_row_get_height(NULL
);
123 table
= adg_table_new();
124 row
= adg_table_row_new(table
);
126 adg_assert_isapprox(adg_table_row_get_height(row
), 0);
128 adg_table_row_set_height(row
, 123);
129 adg_assert_isapprox(adg_table_row_get_height(row
), 123);
131 adg_table_row_set_height(row
, 0);
132 adg_assert_isapprox(adg_table_row_get_height(row
), 0);
134 adg_table_row_set_height(row
, -123);
135 adg_assert_isapprox(adg_table_row_get_height(row
), -123);
137 adg_entity_destroy(ADG_ENTITY(table
));
142 main(int argc
, char *argv
[])
147 adg_test_init(&argc
, &argv
);
149 /* Create a dummy table, otherwise no row would be instantiable */
150 table
= adg_table_new();
152 adg_test_add_boxed_checks("/adg/table-row/type/boxed", ADG_TYPE_TABLE_ROW
,
153 adg_table_row_new(table
));
155 g_test_add_func("/adg/table-row/behavior/misc", _adg_behavior_misc
);
157 g_test_add_func("/adg/table-row/property/height", _adg_property_height
);
159 result
= g_test_run();
160 adg_entity_destroy(ADG_ENTITY(table
));