Debian Codegraph @

ags/test/audio/fx/ags_fx_lv2_channel_test.c

raw symbols SCIP
1 /* GSequencer - Advanced GTK Sequencer
2 * Copyright (C) 2005-2025 Joël Krähemann
3 *
4 * This file is part of GSequencer.
5 *
6 * GSequencer is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * GSequencer is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with GSequencer. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include <glib.h>
21 #include <glib-object.h>
22
23 #include <CUnit/CUnit.h>
24 #include <CUnit/Automated.h>
25 #include <CUnit/Basic.h>
26
27 #include <ags/libags.h>
28 #include <ags/libags-audio.h>
29
30 #include <math.h>
31
32 int ags_fx_lv2_channel_test_init_suite();
33 int ags_fx_lv2_channel_test_clean_suite();
34
35 void ags_fx_lv2_channel_stub_finalize(GObject *gobject);
36
37 void ags_fx_lv2_channel_test_new();
38 void ags_fx_lv2_channel_test_dispose();
39 void ags_fx_lv2_channel_test_finalize();
40 void ags_fx_lv2_channel_test_input_data_alloc();
41 void ags_fx_lv2_channel_test_input_data_free();
42
43 gboolean finalized;
44
45 void
46 ags_fx_lv2_channel_stub_finalize(GObject *gobject)
47 {
48 finalized = TRUE;
49 }
50
51 /* The suite initialization function.
52 * Opens the temporary file used by the tests.
53 * Returns zero on success, non-zero otherwise.
54 */
55 int
56 ags_fx_lv2_channel_test_init_suite()
57 {
58 return(0);
59 }
60
61 /* The suite cleanup function.
62 * Closes the temporary file used by the tests.
63 * Returns zero on success, non-zero otherwise.
64 */
65 int
66 ags_fx_lv2_channel_test_clean_suite()
67 {
68 return(0);
69 }
70
71 void
72 ags_fx_lv2_channel_test_new()
73 {
74 AgsChannel *channel;
75 AgsFxLv2Channel *fx_lv2_channel;
76
77 guint i;
78 gboolean success;
79
80 channel = g_object_new(AGS_TYPE_CHANNEL,
81 NULL);
82
83 fx_lv2_channel = ags_fx_lv2_channel_new(channel);
84
85 CU_ASSERT(fx_lv2_channel != NULL);
86 CU_ASSERT(AGS_RECALL_CHANNEL(fx_lv2_channel)->source == channel);
87
88
89 success = TRUE;
90
91 for(i = 0; i < AGS_SOUND_SCOPE_LAST; i++){
92 if(fx_lv2_channel->input_data[i]->parent == NULL){
93 success = FALSE;
94
95 break;
96 }
97
98 if(fx_lv2_channel->input_data[i]->output != NULL){
99 success = FALSE;
100
101 break;
102 }
103
104 if(fx_lv2_channel->input_data[i]->input != NULL){
105 success = FALSE;
106
107 break;
108 }
109
110 if(fx_lv2_channel->input_data[i]->lv2_handle != NULL){
111 success = FALSE;
112
113 break;
114 }
115 }
116
117 CU_ASSERT(success == TRUE);
118 }
119
120 void
121 ags_fx_lv2_channel_test_dispose()
122 {
123 AgsChannel *channel;
124 AgsFxLv2Channel *fx_lv2_channel;
125
126 channel = g_object_new(AGS_TYPE_CHANNEL,
127 NULL);
128
129 fx_lv2_channel = ags_fx_lv2_channel_new(channel);
130
131 g_object_run_dispose(fx_lv2_channel);
132
133 g_object_unref(fx_lv2_channel);
134 }
135
136 void
137 ags_fx_lv2_channel_test_finalize()
138 {
139 AgsChannel *channel;
140 AgsFxLv2Channel *fx_lv2_channel;
141
142 GObjectClass *gobject_class;
143
144 gpointer stub;
145
146 /* attempt #0 */
147 channel = g_object_new(AGS_TYPE_CHANNEL,
148 NULL);
149
150 fx_lv2_channel = ags_fx_lv2_channel_new(channel);
151
152 gobject_class = (GObjectClass *) g_type_class_ref(AGS_TYPE_FX_LV2_CHANNEL);
153
154 finalized = FALSE;
155
156 stub = gobject_class->finalize;
157 gobject_class->finalize = ags_fx_lv2_channel_stub_finalize;
158
159 g_object_unref(fx_lv2_channel);
160
161 CU_ASSERT(finalized == TRUE);
162
163 gobject_class->finalize = stub;
164
165 /* attempt #1 */
166 channel = g_object_new(AGS_TYPE_CHANNEL,
167 NULL);
168
169 fx_lv2_channel = ags_fx_lv2_channel_new(channel);
170
171 g_object_unref(fx_lv2_channel);
172 }
173
174 void
175 ags_fx_lv2_channel_test_input_data_alloc()
176 {
177 AgsFxLv2ChannelInputData *input_data;
178
179 input_data = ags_fx_lv2_channel_input_data_alloc();
180
181 CU_ASSERT(input_data != NULL);
182 }
183
184 void
185 ags_fx_lv2_channel_test_input_data_free()
186 {
187 AgsFxLv2ChannelInputData *input_data;
188
189 input_data = ags_fx_lv2_channel_input_data_alloc();
190
191 CU_ASSERT(input_data != NULL);
192
193 ags_fx_lv2_channel_input_data_free(input_data);
194 }
195
196 int
197 main(int argc, char **argv)
198 {
199 CU_pSuite pSuite = NULL;
200
201 putenv("LC_ALL=C");
202 putenv("LANG=C");
203
204 putenv("LV2_PATH=\"\"");
205 putenv("DSSI_PATH=\"\"");
206 putenv("LV2_PATH=\"\"");
207
208 /* initialize the CUnit test registry */
209 if(CUE_SUCCESS != CU_initialize_registry()){
210 return CU_get_error();
211 }
212
213 /* add a suite to the registry */
214 pSuite = CU_add_suite("AgsFxLv2ChannelTest", ags_fx_lv2_channel_test_init_suite, ags_fx_lv2_channel_test_clean_suite);
215
216 if(pSuite == NULL){
217 CU_cleanup_registry();
218
219 return CU_get_error();
220 }
221
222 /* add the tests to the suite */
223 if((CU_add_test(pSuite, "test of AgsFxLv2Channel new", ags_fx_lv2_channel_test_new) == NULL) ||
224 (CU_add_test(pSuite, "test of AgsFxLv2Channel dispose", ags_fx_lv2_channel_test_dispose) == NULL) ||
225 (CU_add_test(pSuite, "test of AgsFxLv2Channel finalize", ags_fx_lv2_channel_test_finalize) == NULL) ||
226 (CU_add_test(pSuite, "test of AgsFxLv2Channel input data alloc", ags_fx_lv2_channel_test_input_data_alloc) == NULL) ||
227 (CU_add_test(pSuite, "test of AgsFxLv2Channel input data free", ags_fx_lv2_channel_test_input_data_free) == NULL)){
228 CU_cleanup_registry();
229
230 return CU_get_error();
231 }
232
233 /* Run all tests using the CUnit Basic interface */
234 CU_basic_set_mode(CU_BRM_VERBOSE);
235 CU_basic_run_tests();
236
237 CU_cleanup_registry();
238
239 return(CU_get_error());
240 }