adg: removed AdgPattern
[adg.git] / src / adg / tests / test-fill-style.c
blob9e550b4a527590c351b8a817d5ccc3d71d9c953f
1 /* ADG - Automatic Drawing Generation
2 * Copyright (C) 2010,2011,2012 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"
24 static void
25 _adg_test_pattern(void)
27 AdgFillStyle *fill_style;
28 cairo_pattern_t *valid_pattern_1, *valid_pattern_2;
29 const cairo_pattern_t *pattern;
30 cairo_pattern_t *pattern_dup;
32 fill_style = ADG_FILL_STYLE(adg_ruled_fill_new());
33 valid_pattern_1 = cairo_pattern_create_rgba(0, 0, 0, 0);
34 valid_pattern_2 = cairo_pattern_create_linear(1, 2, 3, 4);
36 /* Using the public APIs */
37 adg_fill_style_set_pattern(fill_style, valid_pattern_1);
38 pattern = adg_fill_style_get_pattern(fill_style);
39 g_assert(pattern == valid_pattern_1);
41 adg_fill_style_set_pattern(fill_style, NULL);
42 pattern = adg_fill_style_get_pattern(fill_style);
43 g_assert(pattern == NULL);
45 adg_fill_style_set_pattern(fill_style, valid_pattern_2);
46 pattern = adg_fill_style_get_pattern(fill_style);
47 g_assert(pattern == valid_pattern_2);
49 /* Using GObject property methods */
50 g_object_set(fill_style, "pattern", valid_pattern_1, NULL);
51 g_object_get(fill_style, "pattern", &pattern_dup, NULL);
52 g_assert(pattern_dup == valid_pattern_1);
53 cairo_pattern_destroy(pattern_dup);
55 g_object_set(fill_style, "pattern", NULL, NULL);
56 g_object_get(fill_style, "pattern", &pattern_dup, NULL);
57 g_assert(pattern_dup == NULL);
58 cairo_pattern_destroy(pattern_dup);
60 g_object_set(fill_style, "pattern", valid_pattern_2, NULL);
61 g_object_get(fill_style, "pattern", &pattern_dup, NULL);
62 g_assert(pattern_dup == valid_pattern_2);
63 cairo_pattern_destroy(pattern_dup);
65 cairo_pattern_destroy(valid_pattern_1);
66 cairo_pattern_destroy(valid_pattern_2);
67 g_object_unref(fill_style);
71 int
72 main(int argc, char *argv[])
74 adg_test_init(&argc, &argv);
76 adg_test_add_func("/adg/fill-style/pattern", _adg_test_pattern);
78 return g_test_run();