1 /* GSequencer - Advanced GTK Sequencer
2 * Copyright (C) 2016 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 <stdlib.h>
31
32 int ags_automation_test_init_suite();
33 int ags_automation_test_clean_suite();
34
35 void ags_automation_test_find_port();
36 void ags_automation_test_find_near_timestamp();
37 void ags_automation_test_add_acceleration();
38 void ags_automation_test_remove_acceleration_at_position();
39 void ags_automation_test_is_acceleration_selected();
40 void ags_automation_test_find_point();
41 void ags_automation_test_find_region();
42 void ags_automation_test_free_selection();
43 void ags_automation_test_add_all_to_selection();
44 void ags_automation_test_add_point_to_selection();
45 void ags_automation_test_remove_point_from_selection();
46 void ags_automation_test_add_region_to_selection();
47 void ags_automation_test_remove_region_from_selection();
48 void ags_automation_test_copy_selection();
49 void ags_automation_test_cut_selection();
50 void ags_automation_test_insert_from_clipboard();
51 void ags_automation_test_get_current();
52 void ags_automation_test_get_specifier_unique();
53 void ags_automation_test_find_specifier();
54 void ags_automation_test_find_specifier_with_type_and_line();
55 void ags_automation_test_get_value();
56
57 #define AGS_AUTOMATION_TEST_CONTROL_NAME "./ags-test-control"
58
59 #define AGS_AUTOMATION_TEST_FIND_PORT_N_AUTOMATION (8)
60
61 #define AGS_AUTOMATION_TEST_FIND_NEAR_TIMESTAMP_N_AUTOMATION (8)
62
63 #define AGS_AUTOMATION_TEST_ADD_ACCELERATION_WIDTH (4096)
64 #define AGS_AUTOMATION_TEST_ADD_ACCELERATION_HEIGHT (128)
65 #define AGS_AUTOMATION_TEST_ADD_ACCELERATION_STEPS (127)
66 #define AGS_AUTOMATION_TEST_ADD_ACCELERATION_LOWER (0.0)
67 #define AGS_AUTOMATION_TEST_ADD_ACCELERATION_UPPER (127.0)
68 #define AGS_AUTOMATION_TEST_ADD_ACCELERATION_DEFAULT_VALUE (1.0)
69 #define AGS_AUTOMATION_TEST_ADD_ACCELERATION_COUNT (1024)
70
71 #define AGS_AUTOMATION_TEST_REMOVE_ACCELERATION_AT_POSITION_WIDTH (4096)
72 #define AGS_AUTOMATION_TEST_REMOVE_ACCELERATION_AT_POSITION_HEIGHT (128)
73 #define AGS_AUTOMATION_TEST_REMOVE_ACCELERATION_AT_POSITION_STEPS (127)
74 #define AGS_AUTOMATION_TEST_REMOVE_ACCELERATION_AT_POSITION_LOWER (0.0)
75 #define AGS_AUTOMATION_TEST_REMOVE_ACCELERATION_AT_POSITION_UPPER (127.0)
76 #define AGS_AUTOMATION_TEST_REMOVE_ACCELERATION_AT_POSITION_DEFAULT_VALUE (1.0)
77 #define AGS_AUTOMATION_TEST_REMOVE_ACCELERATION_AT_POSITION_COUNT (1024)
78
79 #define AGS_AUTOMATION_TEST_IS_ACCELERATION_SELECTED_WIDTH (4096)
80 #define AGS_AUTOMATION_TEST_IS_ACCELERATION_SELECTED_HEIGHT (88)
81 #define AGS_AUTOMATION_TEST_IS_ACCELERATION_SELECTED_STEPS (127)
82 #define AGS_AUTOMATION_TEST_IS_ACCELERATION_SELECTED_LOWER (0.0)
83 #define AGS_AUTOMATION_TEST_IS_ACCELERATION_SELECTED_UPPER (127.0)
84 #define AGS_AUTOMATION_TEST_IS_ACCELERATION_SELECTED_DEFAULT_VALUE (1.0)
85 #define AGS_AUTOMATION_TEST_IS_ACCELERATION_SELECTED_COUNT (1024)
86 #define AGS_AUTOMATION_TEST_IS_ACCELERATION_SELECTED_SELECTION_COUNT (128)
87
88 #define AGS_AUTOMATION_TEST_FIND_POINT_WIDTH (4096)
89 #define AGS_AUTOMATION_TEST_FIND_POINT_HEIGHT (128)
90 #define AGS_AUTOMATION_TEST_FIND_POINT_STEPS (127)
91 #define AGS_AUTOMATION_TEST_FIND_POINT_LOWER (0.0)
92 #define AGS_AUTOMATION_TEST_FIND_POINT_UPPER (127.0)
93 #define AGS_AUTOMATION_TEST_FIND_POINT_DEFAULT_VALUE (1.0)
94 #define AGS_AUTOMATION_TEST_FIND_POINT_COUNT (1024)
95 #define AGS_AUTOMATION_TEST_FIND_POINT_N_ATTEMPTS (128)
96
97 #define AGS_AUTOMATION_TEST_FIND_REGION_WIDTH (4096)
98 #define AGS_AUTOMATION_TEST_FIND_REGION_HEIGHT (88)
99 #define AGS_AUTOMATION_TEST_FIND_REGION_STEPS (127)
100 #define AGS_AUTOMATION_TEST_FIND_REGION_LOWER (0.0)
101 #define AGS_AUTOMATION_TEST_FIND_REGION_UPPER (127.0)
102 #define AGS_AUTOMATION_TEST_FIND_REGION_DEFAULT_VALUE (1.0)
103 #define AGS_AUTOMATION_TEST_FIND_REGION_COUNT (1024)
104 #define AGS_AUTOMATION_TEST_FIND_REGION_N_ATTEMPTS (128)
105 #define AGS_AUTOMATION_TEST_FIND_REGION_SELECTION_WIDTH (128)
106 #define AGS_AUTOMATION_TEST_FIND_REGION_SELECTION_HEIGHT (24)
107
108 #define AGS_AUTOMATION_TEST_FREE_SELECTION_WIDTH (4096)
109 #define AGS_AUTOMATION_TEST_FREE_SELECTION_HEIGHT (88)
110 #define AGS_AUTOMATION_TEST_FREE_SELECTION_STEPS (127)
111 #define AGS_AUTOMATION_TEST_FREE_SELECTION_LOWER (0.0)
112 #define AGS_AUTOMATION_TEST_FREE_SELECTION_UPPER (127.0)
113 #define AGS_AUTOMATION_TEST_FREE_SELECTION_DEFAULT_VALUE (1.0)
114 #define AGS_AUTOMATION_TEST_FREE_SELECTION_COUNT (1024)
115 #define AGS_AUTOMATION_TEST_FREE_SELECTION_SELECTION_COUNT (64)
116
117 #define AGS_AUTOMATION_TEST_ADD_ALL_TO_SELECTION_WIDTH (4096)
118 #define AGS_AUTOMATION_TEST_ADD_ALL_TO_SELECTION_HEIGHT (88)
119 #define AGS_AUTOMATION_TEST_ADD_ALL_TO_SELECTION_STEPS (127)
120 #define AGS_AUTOMATION_TEST_ADD_ALL_TO_SELECTION_LOWER (0.0)
121 #define AGS_AUTOMATION_TEST_ADD_ALL_TO_SELECTION_UPPER (127.0)
122 #define AGS_AUTOMATION_TEST_ADD_ALL_TO_SELECTION_DEFAULT_VALUE (1.0)
123 #define AGS_AUTOMATION_TEST_ADD_ALL_TO_SELECTION_COUNT (1024)
124
125 #define AGS_AUTOMATION_TEST_ADD_POINT_TO_SELECTION_WIDTH (4096)
126 #define AGS_AUTOMATION_TEST_ADD_POINT_TO_SELECTION_HEIGHT (88)
127 #define AGS_AUTOMATION_TEST_ADD_POINT_TO_SELECTION_STEPS (127)
128 #define AGS_AUTOMATION_TEST_ADD_POINT_TO_SELECTION_LOWER (0.0)
129 #define AGS_AUTOMATION_TEST_ADD_POINT_TO_SELECTION_UPPER (127.0)
130 #define AGS_AUTOMATION_TEST_ADD_POINT_TO_SELECTION_DEFAULT_VALUE (1.0)
131 #define AGS_AUTOMATION_TEST_ADD_POINT_TO_SELECTION_COUNT (1024)
132 #define AGS_AUTOMATION_TEST_ADD_POINT_TO_SELECTION_N_ATTEMPTS (128)
133
134 #define AGS_AUTOMATION_TEST_REMOVE_POINT_FROM_SELECTION_WIDTH (4096)
135 #define AGS_AUTOMATION_TEST_REMOVE_POINT_FROM_SELECTION_HEIGHT (88)
136 #define AGS_AUTOMATION_TEST_REMOVE_POINT_FROM_SELECTION_STEPS (127)
137 #define AGS_AUTOMATION_TEST_REMOVE_POINT_FROM_SELECTION_LOWER (0.0)
138 #define AGS_AUTOMATION_TEST_REMOVE_POINT_FROM_SELECTION_UPPER (127.0)
139 #define AGS_AUTOMATION_TEST_REMOVE_POINT_FROM_SELECTION_DEFAULT_VALUE (1.0)
140 #define AGS_AUTOMATION_TEST_REMOVE_POINT_FROM_SELECTION_COUNT (1024)
141 #define AGS_AUTOMATION_TEST_REMOVE_POINT_FROM_SELECTION_SELECTION_COUNT (128)
142 #define AGS_AUTOMATION_TEST_REMOVE_POINT_FROM_SELECTION_N_ATTEMPTS (64)
143
144 #define AGS_AUTOMATION_TEST_GET_SPECIFIER_UNIQUE_STEPS (127)
145 #define AGS_AUTOMATION_TEST_GET_SPECIFIER_UNIQUE_LOWER (0.0)
146 #define AGS_AUTOMATION_TEST_GET_SPECIFIER_UNIQUE_UPPER (127.0)
147 #define AGS_AUTOMATION_TEST_GET_SPECIFIER_UNIQUE_DEFAULT_VALUE (1.0)
148 #define AGS_AUTOMATION_TEST_GET_SPECIFIER_UNIQUE_COUNT (28)
149
150 #define AGS_AUTOMATION_TEST_FIND_SPECIFIER_STEPS (127)
151 #define AGS_AUTOMATION_TEST_FIND_SPECIFIER_LOWER (0.0)
152 #define AGS_AUTOMATION_TEST_FIND_SPECIFIER_UPPER (127.0)
153 #define AGS_AUTOMATION_TEST_FIND_SPECIFIER_DEFAULT_VALUE (1.0)
154 #define AGS_AUTOMATION_TEST_FIND_SPECIFIER_COUNT (28)
155
156 AgsAudio *audio;
157
158 /* The suite initialization function.
159 * Opens the temporary file used by the tests.
160 * Returns zero on success, non-zero otherwise.
161 */
162 int
ags_automation_test_init_suite()163 ags_automation_test_init_suite()
164 {
165 audio = ags_audio_new(NULL);
166 g_object_ref(audio);
167
168 return(0);
169 }
170
171 /* The suite cleanup function.
172 * Closes the temporary file used by the tests.
173 * Returns zero on success, non-zero otherwise.
174 */
175 int
ags_automation_test_clean_suite()176 ags_automation_test_clean_suite()
177 {
178 g_object_unref(audio);
179
180 return(0);
181 }
182
183 void
ags_automation_test_find_port()184 ags_automation_test_find_port()
185 {
186 AgsAutomation **automation;
187 AgsPort **port;
188
189 GList *list, *current;
190
191 guint i;
192
193 automation = (AgsAutomation **) malloc(AGS_AUTOMATION_TEST_FIND_PORT_N_AUTOMATION * sizeof(AgsAutomation *));
194 port = (AgsAutomation **) malloc(AGS_AUTOMATION_TEST_FIND_PORT_N_AUTOMATION * sizeof(AgsPort *));
195 list = NULL;
196
197 for(i = 0; i < AGS_AUTOMATION_TEST_FIND_PORT_N_AUTOMATION; i++){
198 /* nth automation */
199 automation[i] = ags_automation_new(audio,
200 0,
201 AGS_TYPE_INPUT,
202 AGS_AUTOMATION_TEST_CONTROL_NAME);
203
204 port[i] = ags_port_new();
205 g_object_set(automation[i],
206 "port", port[i],
207 NULL);
208
209 list = g_list_prepend(list,
210 automation[i]);
211 }
212
213 /* assert find */
214 for(i = 0; i < AGS_AUTOMATION_TEST_FIND_PORT_N_AUTOMATION; i++){
215 current = list;
216 current = ags_automation_find_port(current,
217 port[i]);
218
219 CU_ASSERT(current != NULL && AGS_AUTOMATION(current->data)->port == port[i]);
220 }
221 }
222
223 void
ags_automation_test_find_near_timestamp()224 ags_automation_test_find_near_timestamp()
225 {
226 AgsAutomation **automation;
227 AgsTimestamp *timestamp;
228
229 GList *list, *current;
230
231 guint i;
232
233 automation = (AgsAutomation **) malloc(AGS_AUTOMATION_TEST_FIND_NEAR_TIMESTAMP_N_AUTOMATION * sizeof(AgsAutomation *));
234 list = NULL;
235
236 for(i = 0; i < AGS_AUTOMATION_TEST_FIND_NEAR_TIMESTAMP_N_AUTOMATION; i++){
237 /* nth automation */
238 automation[i] = ags_automation_new(audio,
239 0,
240 AGS_TYPE_INPUT,
241 AGS_AUTOMATION_TEST_CONTROL_NAME);
242 timestamp = automation[i]->timestamp;
243
244 timestamp->timer.ags_offset.offset = i * AGS_AUTOMATION_DEFAULT_OFFSET;
245
246 list = g_list_prepend(list,
247 automation[i]);
248 }
249
250 list = g_list_reverse(list);
251
252 /* instantiate timestamp to check against */
253 timestamp = ags_timestamp_new();
254
255 timestamp->flags &= (~AGS_TIMESTAMP_UNIX);
256 timestamp->flags |= AGS_TIMESTAMP_OFFSET;
257
258 /* assert find */
259 for(i = 0; i < AGS_AUTOMATION_TEST_FIND_NEAR_TIMESTAMP_N_AUTOMATION; i++){
260 timestamp->timer.ags_offset.offset = i * AGS_AUTOMATION_DEFAULT_OFFSET;
261 current = ags_automation_find_near_timestamp(list, 0,
262 timestamp);
263
264 CU_ASSERT(current != NULL && current->data == automation[i]);
265 }
266 }
267
268 void
ags_automation_test_add_acceleration()269 ags_automation_test_add_acceleration()
270 {
271 AgsAutomation *automation;
272 AgsAcceleration *acceleration;
273
274 GList *list;
275
276 gdouble range;
277 guint x, y;
278 guint i;
279 gboolean success;
280
281 automation = ags_automation_new(audio,
282 0,
283 AGS_TYPE_INPUT,
284 AGS_AUTOMATION_TEST_CONTROL_NAME);
285 automation->steps = AGS_AUTOMATION_TEST_ADD_ACCELERATION_STEPS;
286 automation->lower = AGS_AUTOMATION_TEST_ADD_ACCELERATION_LOWER;
287 automation->upper = AGS_AUTOMATION_TEST_ADD_ACCELERATION_UPPER;
288 automation->default_value = AGS_AUTOMATION_TEST_ADD_ACCELERATION_DEFAULT_VALUE;
289
290 range = (AGS_AUTOMATION_TEST_ADD_ACCELERATION_UPPER - AGS_AUTOMATION_TEST_ADD_ACCELERATION_LOWER);
291
292 for(i = 0; i < AGS_AUTOMATION_TEST_ADD_ACCELERATION_COUNT; i++){
293 x = rand() % AGS_AUTOMATION_TEST_ADD_ACCELERATION_WIDTH;
294 y = rand() % AGS_AUTOMATION_TEST_ADD_ACCELERATION_HEIGHT;
295
296 acceleration = ags_acceleration_new();
297 acceleration->x = x;
298 acceleration->y = AGS_AUTOMATION_TEST_ADD_ACCELERATION_LOWER + ((y / AGS_AUTOMATION_TEST_ADD_ACCELERATION_HEIGHT) * range);
299
300 ags_automation_add_acceleration(automation,
301 acceleration,
302 FALSE);
303 }
304
305 /* assert position */
306 list = automation->acceleration;
307 success = TRUE;
308
309 for(i = 0; i < AGS_AUTOMATION_TEST_ADD_ACCELERATION_COUNT; i++){
310 if(list->prev != NULL){
311 if(AGS_ACCELERATION(list->prev->data)->x > AGS_ACCELERATION(list->data)->x){
312 success = FALSE;
313
314 break;
315 }
316 }
317
318 list = list->next;
319 }
320
321 CU_ASSERT(success == TRUE);
322 }
323
324 void
ags_automation_test_remove_acceleration_at_position()325 ags_automation_test_remove_acceleration_at_position()
326 {
327 AgsAutomation *automation;
328 AgsAcceleration *acceleration;
329
330 GList *list, *current;
331
332 gdouble range;
333 guint x, y;
334 guint nth;
335 guint i;
336 gboolean success;
337
338 automation = ags_automation_new(audio,
339 0,
340 AGS_TYPE_INPUT,
341 AGS_AUTOMATION_TEST_CONTROL_NAME);
342 automation->steps = AGS_AUTOMATION_TEST_REMOVE_ACCELERATION_AT_POSITION_STEPS;
343 automation->lower = AGS_AUTOMATION_TEST_REMOVE_ACCELERATION_AT_POSITION_LOWER;
344 automation->upper = AGS_AUTOMATION_TEST_REMOVE_ACCELERATION_AT_POSITION_UPPER;
345 automation->default_value = AGS_AUTOMATION_TEST_REMOVE_ACCELERATION_AT_POSITION_DEFAULT_VALUE;
346
347 range = (AGS_AUTOMATION_TEST_REMOVE_ACCELERATION_AT_POSITION_UPPER - AGS_AUTOMATION_TEST_REMOVE_ACCELERATION_AT_POSITION_LOWER);
348
349 for(i = 0; i < AGS_AUTOMATION_TEST_REMOVE_ACCELERATION_AT_POSITION_COUNT; i++){
350 x = rand() % AGS_AUTOMATION_TEST_REMOVE_ACCELERATION_AT_POSITION_WIDTH;
351 y = rand() % AGS_AUTOMATION_TEST_REMOVE_ACCELERATION_AT_POSITION_HEIGHT;
352
353 acceleration = ags_acceleration_new();
354 acceleration->x = x;
355 acceleration->y = AGS_AUTOMATION_TEST_REMOVE_ACCELERATION_AT_POSITION_LOWER + ((y / AGS_AUTOMATION_TEST_REMOVE_ACCELERATION_AT_POSITION_HEIGHT) * range);
356
357 ags_automation_add_acceleration(automation,
358 acceleration,
359 FALSE);
360 }
361
362 for(i = 0; i < AGS_AUTOMATION_TEST_REMOVE_ACCELERATION_AT_POSITION_COUNT; i++){
363 nth = rand() % (AGS_AUTOMATION_TEST_REMOVE_ACCELERATION_AT_POSITION_COUNT - i);
364 current = g_list_nth(automation->acceleration,
365 nth);
366
367 ags_automation_remove_acceleration_at_position(automation,
368 AGS_ACCELERATION(current->data)->x,
369 AGS_ACCELERATION(current->data)->y);
370 }
371
372 /* assert position */
373 list = automation->acceleration;
374 success = TRUE;
375
376 for(i = 0; i < AGS_AUTOMATION_TEST_REMOVE_ACCELERATION_AT_POSITION_COUNT - AGS_AUTOMATION_TEST_REMOVE_ACCELERATION_AT_POSITION_COUNT; i++){
377 if(list->prev != NULL){
378 if(AGS_ACCELERATION(list->prev->data)->x > AGS_ACCELERATION(list->data)->x){
379 success = FALSE;
380
381 break;
382 }
383 }
384
385 list = list->next;
386 }
387
388 CU_ASSERT(success == TRUE);
389 }
390
391 void
ags_automation_test_is_acceleration_selected()392 ags_automation_test_is_acceleration_selected()
393 {
394 AgsAutomation *automation;
395 AgsAcceleration *acceleration;
396
397 GList *list, *current;
398
399 gdouble range;
400 guint x, y;
401 guint nth;
402 guint i;
403 gboolean success;
404
405 /* create automation */
406 automation = ags_automation_new(audio,
407 0,
408 AGS_TYPE_INPUT,
409 AGS_AUTOMATION_TEST_CONTROL_NAME);
410 automation->steps = AGS_AUTOMATION_TEST_IS_ACCELERATION_SELECTED_STEPS;
411 automation->lower = AGS_AUTOMATION_TEST_IS_ACCELERATION_SELECTED_LOWER;
412 automation->upper = AGS_AUTOMATION_TEST_IS_ACCELERATION_SELECTED_UPPER;
413 automation->default_value = AGS_AUTOMATION_TEST_IS_ACCELERATION_SELECTED_DEFAULT_VALUE;
414
415 range = (AGS_AUTOMATION_TEST_IS_ACCELERATION_SELECTED_UPPER - AGS_AUTOMATION_TEST_IS_ACCELERATION_SELECTED_LOWER);
416
417 for(i = 0; i < AGS_AUTOMATION_TEST_IS_ACCELERATION_SELECTED_COUNT; i++){
418 x = rand() % AGS_AUTOMATION_TEST_IS_ACCELERATION_SELECTED_WIDTH;
419 y = rand() % AGS_AUTOMATION_TEST_IS_ACCELERATION_SELECTED_HEIGHT;
420
421 acceleration = ags_acceleration_new();
422 acceleration->x = x;
423 acceleration->y = AGS_AUTOMATION_TEST_IS_ACCELERATION_SELECTED_LOWER + ((y / AGS_AUTOMATION_TEST_IS_ACCELERATION_SELECTED_HEIGHT) * range);
424
425 ags_automation_add_acceleration(automation,
426 acceleration,
427 FALSE);
428 }
429
430 /* select acceleration */
431 for(i = 0; i < AGS_AUTOMATION_TEST_IS_ACCELERATION_SELECTED_SELECTION_COUNT; i++){
432 nth = rand() % (AGS_AUTOMATION_TEST_IS_ACCELERATION_SELECTED_COUNT - i);
433 current = g_list_nth(automation->acceleration,
434 nth);
435
436 ags_automation_add_acceleration(automation,
437 current->data,
438 TRUE);
439 }
440
441 /* assert position */
442 list = automation->selection;
443 success = TRUE;
444
445 for(i = 0; i < AGS_AUTOMATION_TEST_IS_ACCELERATION_SELECTED_SELECTION_COUNT; i++){
446 if(list->prev != NULL){
447 if(AGS_ACCELERATION(list->prev->data)->x > AGS_ACCELERATION(list->data)->x){
448 success = FALSE;
449
450 break;
451 }
452 }
453
454 list = list->next;
455 }
456
457 CU_ASSERT(success == TRUE);
458 }
459
460 void
ags_automation_test_find_point()461 ags_automation_test_find_point()
462 {
463 AgsAutomation *automation;
464 AgsAcceleration *acceleration;
465
466 GList *list, *current;
467
468 gdouble range;
469 guint count;
470 guint nth;
471 guint x, y;
472 guint i;
473 gboolean success;
474
475 automation = ags_automation_new(audio,
476 0,
477 AGS_TYPE_INPUT,
478 AGS_AUTOMATION_TEST_CONTROL_NAME);
479 automation->steps = AGS_AUTOMATION_TEST_FIND_POINT_STEPS;
480 automation->lower = AGS_AUTOMATION_TEST_FIND_POINT_LOWER;
481 automation->upper = AGS_AUTOMATION_TEST_FIND_POINT_UPPER;
482 automation->default_value = AGS_AUTOMATION_TEST_FIND_POINT_DEFAULT_VALUE;
483
484 range = (AGS_AUTOMATION_TEST_FIND_POINT_UPPER - AGS_AUTOMATION_TEST_FIND_POINT_LOWER);
485
486 count = 0;
487
488 for(i = 0; i < AGS_AUTOMATION_TEST_FIND_POINT_COUNT; i++){
489 x = rand() % AGS_AUTOMATION_TEST_FIND_POINT_WIDTH;
490 y = rand() % AGS_AUTOMATION_TEST_FIND_POINT_HEIGHT;
491
492 if(ags_automation_find_point(automation,
493 x,
494 y,
495 FALSE) == NULL){
496 acceleration = ags_acceleration_new();
497 acceleration->x = x;
498 acceleration->y = AGS_AUTOMATION_TEST_FIND_POINT_LOWER + ((y / AGS_AUTOMATION_TEST_FIND_POINT_HEIGHT) * range);
499
500 ags_automation_add_acceleration(automation,
501 acceleration,
502 FALSE);
503
504 count++;
505 }
506 }
507
508 /* assert find point */
509 success = TRUE;
510
511 for(i = 0; i < AGS_AUTOMATION_TEST_FIND_POINT_N_ATTEMPTS; i++){
512 nth = rand() % count;
513 current = g_list_nth(automation->acceleration,
514 nth);
515
516 acceleration = ags_automation_find_point(automation,
517 AGS_ACCELERATION(current->data)->x,
518 AGS_ACCELERATION(current->data)->y,
519 FALSE);
520
521 if(acceleration->x != AGS_ACCELERATION(current->data)->x ||
522 acceleration->y != AGS_ACCELERATION(current->data)->y){
523 success = FALSE;
524
525 break;
526 }
527 }
528
529 CU_ASSERT(success == TRUE);
530 }
531
532 void
ags_automation_test_find_region()533 ags_automation_test_find_region()
534 {
535 AgsAutomation *automation;
536 AgsAcceleration *acceleration;
537
538 GList *list, *current, *region;
539
540 gdouble range;
541 guint count;
542 guint nth;
543 guint x, y;
544 guint i;
545 gboolean success;
546
547 automation = ags_automation_new(audio,
548 0,
549 AGS_TYPE_INPUT,
550 AGS_AUTOMATION_TEST_CONTROL_NAME);
551 automation->steps = AGS_AUTOMATION_TEST_FIND_REGION_STEPS;
552 automation->lower = AGS_AUTOMATION_TEST_FIND_REGION_LOWER;
553 automation->upper = AGS_AUTOMATION_TEST_FIND_REGION_UPPER;
554 automation->default_value = AGS_AUTOMATION_TEST_FIND_REGION_DEFAULT_VALUE;
555
556 range = (AGS_AUTOMATION_TEST_FIND_REGION_UPPER - AGS_AUTOMATION_TEST_FIND_REGION_LOWER);
557
558 count = 0;
559
560 for(i = 0; i < AGS_AUTOMATION_TEST_FIND_REGION_COUNT; i++){
561 x = rand() % AGS_AUTOMATION_TEST_FIND_REGION_WIDTH;
562 y = rand() % AGS_AUTOMATION_TEST_FIND_REGION_HEIGHT;
563
564 if(ags_automation_find_point(automation,
565 x,
566 y,
567 FALSE) == NULL){
568 acceleration = ags_acceleration_new();
569 acceleration->x = x;
570 acceleration->y = AGS_AUTOMATION_TEST_FIND_REGION_LOWER + ((y / AGS_AUTOMATION_TEST_FIND_REGION_HEIGHT) * range);
571
572 ags_automation_add_acceleration(automation,
573 acceleration,
574 FALSE);
575
576 count++;
577 }
578 }
579
580 /* assert find region */
581 success = TRUE;
582
583 for(i = 0;
584 i < AGS_AUTOMATION_TEST_FIND_REGION_N_ATTEMPTS &&
585 success;
586 i++){
587 nth = rand() % count;
588 current = g_list_nth(automation->acceleration,
589 nth);
590
591 region = ags_automation_find_region(automation,
592 AGS_ACCELERATION(current->data)->x,
593 AGS_ACCELERATION(current->data)->y,
594 AGS_ACCELERATION(current->data)->x + AGS_AUTOMATION_TEST_FIND_REGION_SELECTION_WIDTH,
595 AGS_ACCELERATION(current->data)->y + AGS_AUTOMATION_TEST_FIND_REGION_SELECTION_HEIGHT,
596 FALSE);
597 while(region != NULL){
598 if(!(AGS_ACCELERATION(region->data)->x >= AGS_ACCELERATION(current->data)->x &&
599 AGS_ACCELERATION(current->data)->x < AGS_ACCELERATION(current->data)->x + AGS_AUTOMATION_TEST_FIND_REGION_SELECTION_WIDTH &&
600 AGS_ACCELERATION(region->data)->y >= AGS_ACCELERATION(current->data)->y &&
601 AGS_ACCELERATION(current->data)->y < AGS_ACCELERATION(current->data)->y + AGS_AUTOMATION_TEST_FIND_REGION_SELECTION_HEIGHT)){
602 success = FALSE;
603
604 break;
605 }
606
607 region = region->next;
608 }
609 }
610
611 CU_ASSERT(success == TRUE);
612 }
613
614 void
ags_automation_test_free_selection()615 ags_automation_test_free_selection()
616 {
617 AgsAutomation *automation;
618 AgsAcceleration *acceleration;
619
620 GList *list, *current;
621
622 gdouble range;
623 guint count;
624 guint x, y;
625 guint nth;
626 guint i;
627
628 /* create automation */
629 automation = ags_automation_new(audio,
630 0,
631 AGS_TYPE_INPUT,
632 AGS_AUTOMATION_TEST_CONTROL_NAME);
633 automation->steps = AGS_AUTOMATION_TEST_FREE_SELECTION_STEPS;
634 automation->lower = AGS_AUTOMATION_TEST_FREE_SELECTION_LOWER;
635 automation->upper = AGS_AUTOMATION_TEST_FREE_SELECTION_UPPER;
636 automation->default_value = AGS_AUTOMATION_TEST_FREE_SELECTION_DEFAULT_VALUE;
637
638 range = (AGS_AUTOMATION_TEST_FREE_SELECTION_UPPER - AGS_AUTOMATION_TEST_FREE_SELECTION_LOWER);
639
640 count = 0;
641
642 for(i = 0; i < AGS_AUTOMATION_TEST_FREE_SELECTION_COUNT; i++){
643 x = rand() % AGS_AUTOMATION_TEST_FREE_SELECTION_WIDTH;
644 y = rand() % AGS_AUTOMATION_TEST_FREE_SELECTION_HEIGHT;
645
646 if(ags_automation_find_point(automation,
647 x,
648 y,
649 FALSE) == NULL){
650 acceleration = ags_acceleration_new();
651 acceleration->x = x;
652 acceleration->y = AGS_AUTOMATION_TEST_FREE_SELECTION_LOWER + ((y / AGS_AUTOMATION_TEST_FREE_SELECTION_HEIGHT) * range);
653
654 ags_automation_add_acceleration(automation,
655 acceleration,
656 FALSE);
657
658 count++;
659 }
660 }
661
662 /* select acceleration */
663 for(i = 0; i < AGS_AUTOMATION_TEST_FREE_SELECTION_SELECTION_COUNT &&
664 i < count; i++){
665 nth = rand() % (count - i);
666 current = g_list_nth(automation->acceleration,
667 nth);
668
669 ags_automation_add_acceleration(automation,
670 current->data,
671 TRUE);
672 }
673
674 /* assert free slection */
675 CU_ASSERT(automation->selection != NULL);
676
677 ags_automation_free_selection(automation);
678
679 CU_ASSERT(automation->selection == NULL);
680 }
681
682 void
ags_automation_test_add_all_to_selection()683 ags_automation_test_add_all_to_selection()
684 {
685 AgsAutomation *automation;
686 AgsAcceleration *acceleration;
687
688 GList *list, *current, *current_selection;
689
690 gdouble range;
691 guint count;
692 guint x, y;
693 guint nth;
694 guint i;
695 gboolean success;
696
697 /* create automation */
698 automation = ags_automation_new(audio,
699 0,
700 AGS_TYPE_INPUT,
701 AGS_AUTOMATION_TEST_CONTROL_NAME);
702 automation->steps = AGS_AUTOMATION_TEST_ADD_ALL_TO_SELECTION_STEPS;
703 automation->lower = AGS_AUTOMATION_TEST_ADD_ALL_TO_SELECTION_LOWER;
704 automation->upper = AGS_AUTOMATION_TEST_ADD_ALL_TO_SELECTION_UPPER;
705 automation->default_value = AGS_AUTOMATION_TEST_ADD_ALL_TO_SELECTION_DEFAULT_VALUE;
706
707 range = (AGS_AUTOMATION_TEST_ADD_ALL_TO_SELECTION_UPPER - AGS_AUTOMATION_TEST_ADD_ALL_TO_SELECTION_LOWER);
708
709 count = 0;
710
711 for(i = 0; i < AGS_AUTOMATION_TEST_ADD_ALL_TO_SELECTION_COUNT; i++){
712 x = rand() % AGS_AUTOMATION_TEST_ADD_ALL_TO_SELECTION_WIDTH;
713 y = rand() % AGS_AUTOMATION_TEST_ADD_ALL_TO_SELECTION_HEIGHT;
714
715 if(ags_automation_find_point(automation,
716 x,
717 y,
718 FALSE) == NULL){
719 acceleration = ags_acceleration_new();
720 acceleration->x = x;
721 acceleration->y = AGS_AUTOMATION_TEST_ADD_ALL_TO_SELECTION_LOWER + ((y / AGS_AUTOMATION_TEST_ADD_ALL_TO_SELECTION_HEIGHT) * range);
722
723 ags_automation_add_acceleration(automation,
724 acceleration,
725 FALSE);
726
727 count++;
728 }
729 }
730
731 /* assert all present */
732 current = automation->acceleration;
733 current_selection = automation->selection;
734
735 success = TRUE;
736
737 while(current != NULL &&
738 current_selection != NULL){
739 if(current->data != current_selection->data){
740 success = FALSE;
741
742 break;
743 }
744
745 current = current->next;
746 current_selection = current_selection->next;
747 }
748
749 CU_ASSERT(success == TRUE);
750 }
751
752 void
ags_automation_test_add_point_to_selection()753 ags_automation_test_add_point_to_selection()
754 {
755 AgsAutomation *automation;
756 AgsAcceleration *acceleration;
757
758 GList *list, *current;
759
760 gdouble range;
761 guint count;
762 guint x, y;
763 guint nth;
764 guint i;
765 gboolean success;
766
767 /* create automation */
768 automation = ags_automation_new(audio,
769 0,
770 AGS_TYPE_INPUT,
771 AGS_AUTOMATION_TEST_CONTROL_NAME);
772 automation->steps = AGS_AUTOMATION_TEST_ADD_POINT_TO_SELECTION_STEPS;
773 automation->lower = AGS_AUTOMATION_TEST_ADD_POINT_TO_SELECTION_LOWER;
774 automation->upper = AGS_AUTOMATION_TEST_ADD_POINT_TO_SELECTION_UPPER;
775 automation->default_value = AGS_AUTOMATION_TEST_ADD_POINT_TO_SELECTION_DEFAULT_VALUE;
776
777 range = (AGS_AUTOMATION_TEST_ADD_POINT_TO_SELECTION_UPPER - AGS_AUTOMATION_TEST_ADD_POINT_TO_SELECTION_LOWER);
778
779 count = 0;
780
781 for(i = 0; i < AGS_AUTOMATION_TEST_ADD_POINT_TO_SELECTION_COUNT; i++){
782 x = rand() % AGS_AUTOMATION_TEST_ADD_POINT_TO_SELECTION_WIDTH;
783 y = rand() % AGS_AUTOMATION_TEST_ADD_POINT_TO_SELECTION_HEIGHT;
784
785 if(ags_automation_find_point(automation,
786 x,
787 y,
788 FALSE) == NULL){
789 acceleration = ags_acceleration_new();
790 acceleration->x = x;
791 acceleration->y = AGS_AUTOMATION_TEST_ADD_POINT_TO_SELECTION_LOWER + ((y / AGS_AUTOMATION_TEST_ADD_POINT_TO_SELECTION_HEIGHT) * range);
792
793 ags_automation_add_acceleration(automation,
794 acceleration,
795 FALSE);
796
797 count++;
798 }
799 }
800
801 /* assert add point to selection */
802 success = TRUE;
803
804 for(i = 0; i < AGS_AUTOMATION_TEST_ADD_POINT_TO_SELECTION_N_ATTEMPTS; i++){
805 nth = rand() % count;
806 current = g_list_nth(automation->acceleration,
807 nth);
808
809 if(current->prev != NULL &&
810 current->next != NULL){
811 ags_automation_add_point_to_selection(automation,
812 AGS_ACCELERATION(current->data)->x, AGS_ACCELERATION(current->data)->y,
813 FALSE);
814
815 if(ags_automation_find_point(automation,
816 AGS_ACCELERATION(current->data)->x, AGS_ACCELERATION(current->data)->y,
817 TRUE) == NULL){
818 success = FALSE;
819
820 break;
821 }
822 }
823 }
824
825 CU_ASSERT(success == TRUE);
826 }
827
828 void
ags_automation_test_remove_point_from_selection()829 ags_automation_test_remove_point_from_selection()
830 {
831 AgsAutomation *automation;
832 AgsAcceleration *acceleration, *match;
833
834 GList *list, *current, *iter, *next;
835
836 gdouble range;
837 guint count;
838 guint x, y;
839 guint nth;
840 guint n_matches;
841 guint i;
842
843 gboolean success;
844
845 /* create automation */
846 automation = ags_automation_new(audio,
847 0,
848 AGS_TYPE_INPUT,
849 AGS_AUTOMATION_TEST_CONTROL_NAME);
850 automation->steps = AGS_AUTOMATION_TEST_REMOVE_POINT_FROM_SELECTION_STEPS;
851 automation->lower = AGS_AUTOMATION_TEST_REMOVE_POINT_FROM_SELECTION_LOWER;
852 automation->upper = AGS_AUTOMATION_TEST_REMOVE_POINT_FROM_SELECTION_UPPER;
853 automation->default_value = AGS_AUTOMATION_TEST_REMOVE_POINT_FROM_SELECTION_DEFAULT_VALUE;
854
855 range = (AGS_AUTOMATION_TEST_REMOVE_POINT_FROM_SELECTION_UPPER - AGS_AUTOMATION_TEST_REMOVE_POINT_FROM_SELECTION_LOWER);
856
857 count = 0;
858
859 for(i = 0; i < AGS_AUTOMATION_TEST_REMOVE_POINT_FROM_SELECTION_COUNT; i++){
860 x = rand() % AGS_AUTOMATION_TEST_REMOVE_POINT_FROM_SELECTION_WIDTH;
861 y = rand() % AGS_AUTOMATION_TEST_REMOVE_POINT_FROM_SELECTION_HEIGHT;
862
863 if(ags_automation_find_point(automation,
864 x,
865 y,
866 FALSE) == NULL){
867 acceleration = ags_acceleration_new();
868 acceleration->x = x;
869 acceleration->y = AGS_AUTOMATION_TEST_REMOVE_POINT_FROM_SELECTION_LOWER + ((y / AGS_AUTOMATION_TEST_REMOVE_POINT_FROM_SELECTION_HEIGHT) * range);
870
871 ags_automation_add_acceleration(automation,
872 acceleration,
873 FALSE);
874
875 count++;
876 }
877 }
878
879 /* add point to selection */
880 for(i = 0; i < AGS_AUTOMATION_TEST_REMOVE_POINT_FROM_SELECTION_SELECTION_COUNT; i++){
881 nth = rand() % count;
882 current = g_list_nth(automation->acceleration,
883 nth);
884
885 ags_automation_add_point_to_selection(automation,
886 AGS_ACCELERATION(current->data)->x, AGS_ACCELERATION(current->data)->y,
887 FALSE);
888 }
889
890 /* assert remove point from selection */
891 success = TRUE;
892
893 for(i = 0; i < AGS_AUTOMATION_TEST_REMOVE_POINT_FROM_SELECTION_N_ATTEMPTS; i++){
894 nth = rand() % (AGS_AUTOMATION_TEST_REMOVE_POINT_FROM_SELECTION_N_ATTEMPTS);
895 current = g_list_nth(automation->selection,
896 nth);
897
898 if(current == NULL){
899 continue;
900 }
901
902 iter = current->next;
903 n_matches = 0;
904
905 while(iter != NULL &&
906 AGS_ACCELERATION(iter->data)->x == AGS_ACCELERATION(current->data)->x &&
907 AGS_ACCELERATION(iter->data)->y == AGS_ACCELERATION(current->data)->y){
908 n_matches++;
909
910 iter = iter->next;
911 }
912
913 acceleration = AGS_ACCELERATION(current->data);
914 ags_automation_remove_point_from_selection(automation,
915 acceleration->x, acceleration->y);
916
917
918 if((match = ags_automation_find_point(automation,
919 acceleration->x, acceleration->y,
920 TRUE)) != NULL){
921 if(n_matches == 0){
922 success = FALSE;
923
924 break;
925 }else{
926 next = g_list_find(automation->selection,
927 match);
928
929 while(next != NULL &&
930 AGS_ACCELERATION(next->data)->x == acceleration->x &&
931 AGS_ACCELERATION(next->data)->y == acceleration->y){
932 n_matches--;
933
934 next = next->next;
935 }
936
937 if(n_matches != 0){
938 success = FALSE;
939
940 break;
941 }
942 }
943 }
944 }
945
946 CU_ASSERT(success == TRUE);
947 }
948
949 void
ags_automation_test_add_region_to_selection()950 ags_automation_test_add_region_to_selection()
951 {
952 //TODO:JK: implement me
953 }
954
955 void
ags_automation_test_remove_region_from_selection()956 ags_automation_test_remove_region_from_selection()
957 {
958 //TODO:JK: implement me
959 }
960
961 void
ags_automation_test_copy_selection()962 ags_automation_test_copy_selection()
963 {
964 //TODO:JK: implement me
965 }
966
967 void
ags_automation_test_cut_selection()968 ags_automation_test_cut_selection()
969 {
970 //TODO:JK: implement me
971 }
972
973 void
ags_automation_test_insert_from_clipboard()974 ags_automation_test_insert_from_clipboard()
975 {
976 //TODO:JK: implement me
977 }
978
979 void
ags_automation_test_get_current()980 ags_automation_test_get_current()
981 {
982 //TODO:JK: implement me
983 }
984
985 void
ags_automation_test_get_specifier_unique()986 ags_automation_test_get_specifier_unique()
987 {
988 AgsAutomation *automation;
989
990 GList *start;
991
992 gchar **specifier_unique;
993 gchar **iter;
994 gboolean *found_index;
995
996 guint specifier_count;
997 guint nth;
998 guint i;
999 gboolean success;
1000
1001 static const gchar *specifier[] = {
1002 "delay",
1003 "feedback",
1004 "resonance",
1005 "osc1",
1006 "osc2",
1007 NULL,
1008 };
1009
1010 /* count specifiers */
1011 iter = specifier;
1012
1013 for(specifier_count = 0; *iter != NULL; specifier_count++, iter++);
1014
1015 /* create automation */
1016 start = NULL;
1017
1018 found_index = (gboolean *) malloc(specifier_count * sizeof(gboolean));
1019 memset(found_index, 0, specifier_count * sizeof(gboolean));
1020
1021 for(i = 0; i < AGS_AUTOMATION_TEST_GET_SPECIFIER_UNIQUE_COUNT; i++){
1022 nth = rand() % specifier_count;
1023 found_index[nth] = TRUE;
1024
1025 automation = ags_automation_new(audio,
1026 0,
1027 AGS_TYPE_INPUT,
1028 specifier[nth]);
1029 automation->steps = AGS_AUTOMATION_TEST_GET_SPECIFIER_UNIQUE_STEPS;
1030 automation->lower = AGS_AUTOMATION_TEST_GET_SPECIFIER_UNIQUE_LOWER;
1031 automation->upper = AGS_AUTOMATION_TEST_GET_SPECIFIER_UNIQUE_UPPER;
1032 automation->default_value = AGS_AUTOMATION_TEST_GET_SPECIFIER_UNIQUE_DEFAULT_VALUE;
1033
1034 start = g_list_prepend(start,
1035 automation);
1036 }
1037
1038 /* verify each specifier available */
1039 for(i = 0; i < specifier_count; i++){
1040 if(!found_index[i]){
1041 automation = ags_automation_new(audio,
1042 0,
1043 AGS_TYPE_INPUT,
1044 specifier[i]);
1045 automation->steps = AGS_AUTOMATION_TEST_GET_SPECIFIER_UNIQUE_STEPS;
1046 automation->lower = AGS_AUTOMATION_TEST_GET_SPECIFIER_UNIQUE_LOWER;
1047 automation->upper = AGS_AUTOMATION_TEST_GET_SPECIFIER_UNIQUE_UPPER;
1048 automation->default_value = AGS_AUTOMATION_TEST_GET_SPECIFIER_UNIQUE_DEFAULT_VALUE;
1049
1050 start = g_list_prepend(start,
1051 automation);
1052 }
1053 }
1054
1055 /* assert */
1056 success = TRUE;
1057
1058 specifier_unique = ags_automation_get_specifier_unique(start);
1059
1060 for(i = 0; i < specifier_count; i++){
1061 if(!g_strv_contains(specifier,
1062 specifier_unique[i])){
1063 success = FALSE;
1064
1065 break;
1066 }
1067 }
1068
1069 CU_ASSERT(success == TRUE && specifier_unique[specifier_count] == NULL);
1070 }
1071
1072 void
ags_automation_test_find_specifier()1073 ags_automation_test_find_specifier()
1074 {
1075 AgsAutomation *automation;
1076
1077 GList *start;
1078 GList *current;
1079
1080 gchar **specifier_unique;
1081 gchar **iter;
1082 guint *n_index;
1083
1084 guint specifier_count;
1085 guint nth;
1086 guint i;
1087 guint n_match;
1088 gboolean success;
1089
1090 static const gchar *unavailable_specifier = "unavailable";
1091 static const gchar *specifier[] = {
1092 "delay",
1093 "feedback",
1094 "resonance",
1095 "osc1",
1096 "osc2",
1097 NULL,
1098 };
1099
1100 /* count specifiers */
1101 iter = specifier;
1102
1103 for(specifier_count = 0; *iter != NULL; specifier_count++, iter++);
1104
1105 /* create automation */
1106 start = NULL;
1107
1108 n_index = (guint *) malloc(specifier_count * sizeof(guint));
1109 memset(n_index, 0, specifier_count * sizeof(guint));
1110
1111 for(i = 0; i < AGS_AUTOMATION_TEST_FIND_SPECIFIER_COUNT; i++){
1112 nth = rand() % specifier_count;
1113 n_index[nth] += 1;
1114
1115 automation = ags_automation_new(audio,
1116 0,
1117 AGS_TYPE_INPUT,
1118 specifier[nth]);
1119 automation->steps = AGS_AUTOMATION_TEST_FIND_SPECIFIER_STEPS;
1120 automation->lower = AGS_AUTOMATION_TEST_FIND_SPECIFIER_LOWER;
1121 automation->upper = AGS_AUTOMATION_TEST_FIND_SPECIFIER_UPPER;
1122 automation->default_value = AGS_AUTOMATION_TEST_FIND_SPECIFIER_DEFAULT_VALUE;
1123
1124 start = g_list_prepend(start,
1125 automation);
1126 }
1127
1128 /* verify each specifier available */
1129 for(i = 0; i < specifier_count; i++){
1130 if(n_index[i] == 0){
1131 n_index[i] = 1;
1132
1133 automation = ags_automation_new(audio,
1134 0,
1135 AGS_TYPE_INPUT,
1136 specifier[i]);
1137 automation->steps = AGS_AUTOMATION_TEST_FIND_SPECIFIER_STEPS;
1138 automation->lower = AGS_AUTOMATION_TEST_FIND_SPECIFIER_LOWER;
1139 automation->upper = AGS_AUTOMATION_TEST_FIND_SPECIFIER_UPPER;
1140 automation->default_value = AGS_AUTOMATION_TEST_FIND_SPECIFIER_DEFAULT_VALUE;
1141
1142 start = g_list_prepend(start,
1143 automation);
1144 }
1145 }
1146
1147 /* assert unavailable */
1148 current = ags_automation_find_specifier(start,
1149 unavailable_specifier);
1150 CU_ASSERT(current == NULL);
1151
1152 /* assert specifier find n-times */
1153 for(i = 0; i < specifier_count; i++){
1154 current = start;
1155 n_match = 0;
1156
1157 while((current = ags_automation_find_specifier(current,
1158 specifier[i])) != NULL){
1159 n_match++;
1160
1161 current = current->next;
1162 }
1163
1164 CU_ASSERT(n_match == n_index[i] && current == NULL);
1165 }
1166 }
1167
1168 void
ags_automation_test_find_specifier_with_type_and_line()1169 ags_automation_test_find_specifier_with_type_and_line()
1170 {
1171 //TODO:JK: implement me
1172 }
1173
1174 void
ags_automation_test_get_value()1175 ags_automation_test_get_value()
1176 {
1177 //TODO:JK: implement me
1178 }
1179
1180 int
main(int argc,char ** argv)1181 main(int argc, char **argv)
1182 {
1183 CU_pSuite pSuite = NULL;
1184
1185 putenv("LC_ALL=C");
1186 putenv("LANG=C");
1187
1188 /* initialize the CUnit test registry */
1189 if(CUE_SUCCESS != CU_initialize_registry()){
1190 return CU_get_error();
1191 }
1192
1193 /* add a suite to the registry */
1194 pSuite = CU_add_suite("AgsAutomationTest", ags_automation_test_init_suite, ags_automation_test_clean_suite);
1195
1196 if(pSuite == NULL){
1197 CU_cleanup_registry();
1198
1199 return CU_get_error();
1200 }
1201
1202 /* add the tests to the suite */
1203 if((CU_add_test(pSuite, "test of AgsAutomation find port", ags_automation_test_find_port) == NULL) ||
1204 (CU_add_test(pSuite, "test of AgsAutomation find near timestamp", ags_automation_test_find_near_timestamp) == NULL) ||
1205 (CU_add_test(pSuite, "test of AgsAutomation add acceleration", ags_automation_test_add_acceleration) == NULL) ||
1206 (CU_add_test(pSuite, "test of AgsAutomation remove acceleration at position", ags_automation_test_remove_acceleration_at_position) == NULL) ||
1207 (CU_add_test(pSuite, "test of AgsAutomation is acceleration selected", ags_automation_test_is_acceleration_selected) == NULL) ||
1208 (CU_add_test(pSuite, "test of AgsAutomation find point", ags_automation_test_find_point) == NULL) ||
1209 (CU_add_test(pSuite, "test of AgsAutomation find region", ags_automation_test_find_region) == NULL) ||
1210 (CU_add_test(pSuite, "test of AgsAutomation free selection", ags_automation_test_free_selection) == NULL) ||
1211 (CU_add_test(pSuite, "test of AgsAutomation add all to selection", ags_automation_test_add_all_to_selection) == NULL) ||
1212 (CU_add_test(pSuite, "test of AgsAutomation add point to selection", ags_automation_test_add_point_to_selection) == NULL) ||
1213 (CU_add_test(pSuite, "test of AgsAutomation remove point from selection", ags_automation_test_remove_point_from_selection) == NULL) ||
1214 (CU_add_test(pSuite, "test of AgsAutomation get specifier unique", ags_automation_test_get_specifier_unique) == NULL) ||
1215 (CU_add_test(pSuite, "test of AgsAutomation find specifier", ags_automation_test_find_specifier) == NULL)){
1216 CU_cleanup_registry();
1217
1218 return CU_get_error();
1219 }
1220
1221 /* Run all tests using the CUnit Basic interface */
1222 CU_basic_set_mode(CU_BRM_VERBOSE);
1223 CU_basic_run_tests();
1224
1225 CU_cleanup_registry();
1226
1227 return(CU_get_error());
1228 }
1229
1230