1 /* ADG - Automatic Drawing Generation
2 * Copyright (C) 2010 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_parent(void)
28 AdgEntity
*valid_container
, *invalid_container
;
31 entity
= ADG_ENTITY(adg_logo_new());
32 valid_container
= ADG_ENTITY(adg_container_new());
33 invalid_container
= adg_test_invalid_pointer();
35 /* Using the public APIs */
36 adg_entity_set_parent(entity
, valid_container
);
37 parent
= adg_entity_get_parent(entity
);
38 g_assert(parent
== valid_container
);
40 adg_entity_set_parent(entity
, invalid_container
);
41 parent
= adg_entity_get_parent(entity
);
42 g_assert(parent
== valid_container
);
44 adg_entity_set_parent(entity
, NULL
);
45 parent
= adg_entity_get_parent(entity
);
46 g_assert(parent
== NULL
);
48 /* Using GObject property methods */
49 g_object_set(entity
, "parent", valid_container
, NULL
);
50 g_object_get(entity
, "parent", &parent
, NULL
);
51 g_assert(parent
== valid_container
);
53 g_object_set(entity
, "parent", invalid_container
, NULL
);
54 g_object_get(entity
, "parent", &parent
, NULL
);
55 g_assert(parent
== valid_container
);
57 g_object_set(entity
, "parent", NULL
, NULL
);
58 g_object_get(entity
, "parent", &parent
, NULL
);
59 g_assert(parent
== NULL
);
61 g_object_unref(entity
);
62 g_object_unref(valid_container
);
67 main(int argc
, char *argv
[])
69 adg_test_init(&argc
, &argv
);
71 g_test_add_func("/adg/entity/parent", _adg_test_parent
);