1 /* GSequencer - Advanced GTK Sequencer
2 * Copyright (C) 2005-2015 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 int ags_audio_signal_test_init_suite();
31 int ags_audio_signal_test_clean_suite();
32
33 void ags_audio_signal_test_add_stream();
34 void ags_audio_signal_test_resize_stream();
35 void ags_audio_signal_test_realloc_buffer_size();
36 void ags_audio_signal_test_copy_buffer_to_buffer();
37 void ags_audio_signal_test_copy_double_buffer_to_buffer();
38 void ags_audio_signal_test_duplicate_stream();
39 void ags_audio_signal_test_get_template();
40 void ags_audio_signal_test_get_stream_current();
41 void ags_audio_signal_test_get_by_recall_id();
42 void ags_audio_signal_test_tile();
43 void ags_audio_signal_test_scale();
44
45 #define AGS_AUDIO_SIGNAL_TEST_GET_TEMPLATE_N_AUDIO_SIGNAL (3)
46 #define AGS_AUDIO_SIGNAL_TEST_GET_STREAM_CURRENT_N_AUDIO_SIGNAL (6)
47
48 AgsDevout *devout;
49
50 /* The suite initialization function.
51 * Opens the temporary file used by the tests.
52 * Returns zero on success, non-zero otherwise.
53 */
54 int
ags_audio_signal_test_init_suite()55 ags_audio_signal_test_init_suite()
56 {
57 devout = ags_devout_new(NULL);
58 g_object_ref(devout);
59
60 return(0);
61 }
62
63 /* The suite cleanup function.
64 * Closes the temporary file used by the tests.
65 * Returns zero on success, non-zero otherwise.
66 */
67 int
ags_audio_signal_test_clean_suite()68 ags_audio_signal_test_clean_suite()
69 {
70 g_object_unref(devout);
71
72 return(0);
73 }
74
75 void
ags_audio_signal_test_add_stream()76 ags_audio_signal_test_add_stream()
77 {
78 AgsAudioSignal *audio_signal;
79
80 /* instantiate audio signal */
81 audio_signal = ags_audio_signal_new(G_OBJECT(devout),
82 NULL,
83 NULL);
84
85 /* assert add stream */
86 CU_ASSERT(audio_signal->stream == NULL);
87
88 ags_audio_signal_add_stream(audio_signal);
89 CU_ASSERT(audio_signal->stream != NULL);
90 CU_ASSERT(g_list_length(audio_signal->stream) == 1);
91 }
92
93 void
ags_audio_signal_test_resize_stream()94 ags_audio_signal_test_resize_stream()
95 {
96 AgsAudioSignal *audio_signal;
97
98 /* instantiate audio signal */
99 audio_signal = ags_audio_signal_new(G_OBJECT(devout),
100 NULL,
101 NULL);
102
103 /* assert resize stream */
104 CU_ASSERT(audio_signal->stream == NULL);
105
106 ags_audio_signal_stream_resize(audio_signal,
107 5);
108 CU_ASSERT(audio_signal->stream != NULL);
109 CU_ASSERT(g_list_length(audio_signal->stream) == 5);
110 }
111
112 void
ags_audio_signal_test_realloc_buffer_size()113 ags_audio_signal_test_realloc_buffer_size()
114 {
115 //TODO:JK: implement me
116 }
117
118 void
ags_audio_signal_test_copy_buffer_to_buffer()119 ags_audio_signal_test_copy_buffer_to_buffer()
120 {
121 //TODO:JK: implement me
122 }
123
124 void
ags_audio_signal_test_copy_double_buffer_to_buffer()125 ags_audio_signal_test_copy_double_buffer_to_buffer()
126 {
127 //TODO:JK: implement me
128 }
129
130 void
ags_audio_signal_test_duplicate_stream()131 ags_audio_signal_test_duplicate_stream()
132 {
133 //TODO:JK: implement me
134 }
135
136 void
ags_audio_signal_test_get_template()137 ags_audio_signal_test_get_template()
138 {
139 //TODO:JK: implement me
140 }
141
142 void
ags_audio_signal_test_get_stream_current()143 ags_audio_signal_test_get_stream_current()
144 {
145 //TODO:JK: implement me
146 }
147
148 void
ags_audio_signal_test_get_by_recall_id()149 ags_audio_signal_test_get_by_recall_id()
150 {
151 //TODO:JK: implement me
152 }
153
154 void
ags_audio_signal_test_tile()155 ags_audio_signal_test_tile()
156 {
157 //TODO:JK: implement me
158 }
159
160 void
ags_audio_signal_test_scale()161 ags_audio_signal_test_scale()
162 {
163 //TODO:JK: implement me
164 }
165
166 int
main(int argc,char ** argv)167 main(int argc, char **argv)
168 {
169 CU_pSuite pSuite = NULL;
170
171 putenv("LC_ALL=C");
172 putenv("LANG=C");
173
174 /* initialize the CUnit test registry */
175 if(CUE_SUCCESS != CU_initialize_registry()){
176 return CU_get_error();
177 }
178
179 /* add a suite to the registry */
180 pSuite = CU_add_suite("AgsAudioSignalTest", ags_audio_signal_test_init_suite, ags_audio_signal_test_clean_suite);
181
182 if(pSuite == NULL){
183 CU_cleanup_registry();
184
185 return CU_get_error();
186 }
187
188 /* add the tests to the suite */
189 if((CU_add_test(pSuite, "test of AgsAudioSignal add stream", ags_audio_signal_test_add_stream) == NULL) ||
190 (CU_add_test(pSuite, "test of AgsAudioSignal resize stream", ags_audio_signal_test_resize_stream) == NULL)
191 /* ||
192 (CU_add_test(pSuite, "test of AgsAudioSignal realloc buffer size", ags_audio_signal_test_realloc_buffer_size) == NULL) ||
193 (CU_add_test(pSuite, "test of AgsAudioSignal copy buffer to buffer", ags_audio_signal_test_copy_buffer_to_buffer) == NULL) ||
194 (CU_add_test(pSuite, "test of AgsAudioSignal copy double buffer to buffer", ags_audio_signal_test_copy_double_buffer_to_buffer) == NULL) ||
195 (CU_add_test(pSuite, "test of AgsAudioSignal duplicate stream", ags_audio_signal_test_duplicate_stream) == NULL) ||
196 (CU_add_test(pSuite, "test of AgsAudioSignal get template", ags_audio_signal_test_get_template) == NULL) ||
197 (CU_add_test(pSuite, "test of AgsAudioSignal get stream current", ags_audio_signal_test_get_stream_current) == NULL) ||
198 (CU_add_test(pSuite, "test of AgsAudioSignal get by recall id", ags_audio_signal_test_get_by_recall_id) == NULL) ||
199 (CU_add_test(pSuite, "test of AgsAudioSignal tile", ags_audio_signal_test_tile) == NULL) ||
200 (CU_add_test(pSuite, "test of AgsAudioSignal scale", ags_audio_signal_test_scale) == NULL)
201 */ ){
202 CU_cleanup_registry();
203
204 return CU_get_error();
205 }
206
207 /* Run all tests using the CUnit Basic interface */
208 CU_basic_set_mode(CU_BRM_VERBOSE);
209 CU_basic_run_tests();
210
211 CU_cleanup_registry();
212
213 return(CU_get_error());
214 }
215
216