| 1 |
|
| 2 |
nn |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 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_peak_channel_test_init_suite(); |
| 33 |
int ags_fx_peak_channel_test_clean_suite(); |
| 34 |
|
| 35 |
void ags_fx_peak_channel_stub_finalize(GObject *gobject); |
| 36 |
|
| 37 |
void ags_fx_peak_channel_test_new(); |
| 38 |
void ags_fx_peak_channel_test_dispose(); |
| 39 |
void ags_fx_peak_channel_test_finalize(); |
| 40 |
void ags_fx_peak_channel_test_input_data_alloc(); |
| 41 |
void ags_fx_peak_channel_test_input_data_free(); |
| 42 |
|
| 43 |
gboolean finalized; |
| 44 |
|
| 45 |
void |
| 46 |
ags_fx_peak_channel_stub_finalize(GObject *gobject) |
| 47 |
{ |
| 48 |
finalized = TRUE; |
| 49 |
} |
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
int |
| 56 |
ags_fx_peak_channel_test_init_suite() |
| 57 |
{ |
| 58 |
ags_audio_application_context_new(); |
| 59 |
|
| 60 |
return(0); |
| 61 |
} |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
int |
| 68 |
ags_fx_peak_channel_test_clean_suite() |
| 69 |
{ |
| 70 |
return(0); |
| 71 |
} |
| 72 |
|
| 73 |
void |
| 74 |
ags_fx_peak_channel_test_new() |
| 75 |
{ |
| 76 |
AgsChannel *channel; |
| 77 |
AgsFxPeakChannel *fx_peak_channel; |
| 78 |
|
| 79 |
guint i; |
| 80 |
gboolean success; |
| 81 |
|
| 82 |
channel = g_object_new(AGS_TYPE_CHANNEL, |
| 83 |
NULL); |
| 84 |
|
| 85 |
fx_peak_channel = ags_fx_peak_channel_new(channel); |
| 86 |
|
| 87 |
CU_ASSERT(fx_peak_channel != NULL); |
| 88 |
CU_ASSERT(AGS_RECALL_CHANNEL(fx_peak_channel)->source == channel); |
| 89 |
|
| 90 |
CU_ASSERT(fx_peak_channel->peak != NULL); |
| 91 |
|
| 92 |
success = TRUE; |
| 93 |
|
| 94 |
for(i = 0; i < AGS_SOUND_SCOPE_LAST; i++){ |
| 95 |
if(fx_peak_channel->input_data[i]->parent == NULL){ |
| 96 |
success = FALSE; |
| 97 |
|
| 98 |
break; |
| 99 |
} |
| 100 |
|
| 101 |
if(fx_peak_channel->input_data[i]->buffer == NULL){ |
| 102 |
success = FALSE; |
| 103 |
|
| 104 |
break; |
| 105 |
} |
| 106 |
} |
| 107 |
|
| 108 |
CU_ASSERT(success == TRUE); |
| 109 |
} |
| 110 |
|
| 111 |
|
| 112 |
void |
| 113 |
ags_fx_peak_channel_test_dispose() |
| 114 |
{ |
| 115 |
AgsChannel *channel; |
| 116 |
AgsFxPeakChannel *fx_peak_channel; |
| 117 |
|
| 118 |
channel = g_object_new(AGS_TYPE_CHANNEL, |
| 119 |
NULL); |
| 120 |
|
| 121 |
fx_peak_channel = ags_fx_peak_channel_new(channel); |
| 122 |
|
| 123 |
g_object_run_dispose(fx_peak_channel); |
| 124 |
|
| 125 |
CU_ASSERT(fx_peak_channel->peak == NULL); |
| 126 |
|
| 127 |
g_object_unref(fx_peak_channel); |
| 128 |
} |
| 129 |
|
| 130 |
void |
| 131 |
ags_fx_peak_channel_test_finalize() |
| 132 |
{ |
| 133 |
AgsChannel *channel; |
| 134 |
AgsFxPeakChannel *fx_peak_channel; |
| 135 |
|
| 136 |
GObjectClass *gobject_class; |
| 137 |
|
| 138 |
gpointer stub; |
| 139 |
|
| 140 |
|
| 141 |
channel = g_object_new(AGS_TYPE_CHANNEL, |
| 142 |
NULL); |
| 143 |
|
| 144 |
fx_peak_channel = ags_fx_peak_channel_new(channel); |
| 145 |
|
| 146 |
gobject_class = (GObjectClass *) g_type_class_ref(AGS_TYPE_FX_PEAK_CHANNEL); |
| 147 |
|
| 148 |
finalized = FALSE; |
| 149 |
|
| 150 |
stub = gobject_class->finalize; |
| 151 |
gobject_class->finalize = ags_fx_peak_channel_stub_finalize; |
| 152 |
|
| 153 |
g_object_run_dispose(fx_peak_channel); |
| 154 |
g_object_unref(fx_peak_channel); |
| 155 |
|
| 156 |
CU_ASSERT(finalized == TRUE); |
| 157 |
|
| 158 |
gobject_class->finalize = stub; |
| 159 |
|
| 160 |
|
| 161 |
channel = g_object_new(AGS_TYPE_CHANNEL, |
| 162 |
NULL); |
| 163 |
|
| 164 |
fx_peak_channel = ags_fx_peak_channel_new(channel); |
| 165 |
|
| 166 |
g_object_run_dispose(fx_peak_channel); |
| 167 |
g_object_unref(fx_peak_channel); |
| 168 |
} |
| 169 |
|
| 170 |
void |
| 171 |
ags_fx_peak_channel_test_input_data_alloc() |
| 172 |
{ |
| 173 |
AgsFxPeakChannelInputData *input_data; |
| 174 |
|
| 175 |
input_data = ags_fx_peak_channel_input_data_alloc(); |
| 176 |
|
| 177 |
CU_ASSERT(input_data != NULL); |
| 178 |
} |
| 179 |
|
| 180 |
void |
| 181 |
ags_fx_peak_channel_test_input_data_free() |
| 182 |
{ |
| 183 |
AgsFxPeakChannelInputData *input_data; |
| 184 |
|
| 185 |
input_data = ags_fx_peak_channel_input_data_alloc(); |
| 186 |
|
| 187 |
CU_ASSERT(input_data != NULL); |
| 188 |
|
| 189 |
ags_fx_peak_channel_input_data_free(input_data); |
| 190 |
} |
| 191 |
|
| 192 |
int |
| 193 |
main(int argc, char **argv) |
| 194 |
{ |
| 195 |
CU_pSuite pSuite = NULL; |
| 196 |
|
| 197 |
putenv("LC_ALL=C"); |
| 198 |
putenv("LANG=C"); |
| 199 |
|
| 200 |
putenv("LADSPA_PATH=\"\""); |
| 201 |
putenv("DSSI_PATH=\"\""); |
| 202 |
putenv("LV2_PATH=\"\""); |
| 203 |
|
| 204 |
|
| 205 |
if(CUE_SUCCESS != CU_initialize_registry()){ |
| 206 |
return CU_get_error(); |
| 207 |
} |
| 208 |
|
| 209 |
|
| 210 |
pSuite = CU_add_suite("AgsFxPeakChannelTest", ags_fx_peak_channel_test_init_suite, ags_fx_peak_channel_test_clean_suite); |
| 211 |
|
| 212 |
if(pSuite == NULL){ |
| 213 |
CU_cleanup_registry(); |
| 214 |
|
| 215 |
return CU_get_error(); |
| 216 |
} |
| 217 |
|
| 218 |
|
| 219 |
if((CU_add_test(pSuite, "test of AgsFxPeakChannel new", ags_fx_peak_channel_test_new) == NULL) || |
| 220 |
(CU_add_test(pSuite, "test of AgsFxPeakChannel dispose", ags_fx_peak_channel_test_dispose) == NULL) || |
| 221 |
(CU_add_test(pSuite, "test of AgsFxPeakChannel finalize", ags_fx_peak_channel_test_finalize) == NULL) || |
| 222 |
(CU_add_test(pSuite, "test of AgsFxPeakChannel input data alloc", ags_fx_peak_channel_test_input_data_alloc) == NULL) || |
| 223 |
(CU_add_test(pSuite, "test of AgsFxPeakChannel input data free", ags_fx_peak_channel_test_input_data_free) == NULL)){ |
| 224 |
CU_cleanup_registry(); |
| 225 |
|
| 226 |
return CU_get_error(); |
| 227 |
} |
| 228 |
|
| 229 |
|
| 230 |
CU_basic_set_mode(CU_BRM_VERBOSE); |
| 231 |
CU_basic_run_tests(); |
| 232 |
|
| 233 |
CU_cleanup_registry(); |
| 234 |
|
| 235 |
return(CU_get_error()); |
| 236 |
} |