1 /* GSequencer - Advanced GTK Sequencer
2 * Copyright (C) 2017 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 <ags/libags.h>
24 #include <ags/libags-audio.h>
25
26 #include <CUnit/CUnit.h>
27 #include <CUnit/Automated.h>
28 #include <CUnit/Basic.h>
29
30 int ags_lv2ui_plugin_test_init_suite();
31 int ags_lv2ui_plugin_test_clean_suite();
32
33 void ags_lv2ui_plugin_test_find_gui_uri();
34
35 #define AGS_LV2UI_PLUGIN_TEST_FIND_GUI_URI_SWH "http://plugin.org.uk/ladspa-swh"
36 #define AGS_LV2UI_PLUGIN_TEST_FIND_GUI_URI_INVADA "http://invadarecords.com/plugins/lv2"
37 #define AGS_LV2UI_PLUGIN_TEST_FIND_GUI_URI_ZYN "http://home.gna.org/zyn/zynadd"
38
39 /* The suite initialization time.
40 * Opens the temporary file used by the tests.
41 * Returns zero on success, non-zero otherwise.
42 */
43 int
ags_lv2ui_plugin_test_init_suite()44 ags_lv2ui_plugin_test_init_suite()
45 {
46 return(0);
47 }
48
49 /* The suite cleanup time.
50 * Closes the temporary file used by the tests.
51 * Returns zero on success, non-zero otherwise.
52 */
53 int
ags_lv2ui_plugin_test_clean_suite()54 ags_lv2ui_plugin_test_clean_suite()
55 {
56 return(0);
57 }
58
59 void
ags_lv2ui_plugin_test_find_gui_uri()60 ags_lv2ui_plugin_test_find_gui_uri()
61 {
62 AgsLv2uiPlugin *lv2ui_plugin[3];
63
64 GList *list, *current;
65
66 list = NULL;
67
68 lv2ui_plugin[0] = (AgsLv2uiPlugin *) g_object_new(AGS_TYPE_LV2UI_PLUGIN,
69 "gui-uri", AGS_LV2UI_PLUGIN_TEST_FIND_GUI_URI_SWH,
70 NULL);
71 list = g_list_prepend(list,
72 lv2ui_plugin[0]);
73
74 lv2ui_plugin[1] = (AgsLv2uiPlugin *) g_object_new(AGS_TYPE_LV2UI_PLUGIN,
75 "gui-uri", AGS_LV2UI_PLUGIN_TEST_FIND_GUI_URI_INVADA,
76 NULL);
77 list = g_list_prepend(list,
78 lv2ui_plugin[1]);
79
80 lv2ui_plugin[2] = (AgsLv2uiPlugin *) g_object_new(AGS_TYPE_LV2UI_PLUGIN,
81 "gui-uri", AGS_LV2UI_PLUGIN_TEST_FIND_GUI_URI_ZYN,
82 NULL);
83 list = g_list_prepend(list,
84 lv2ui_plugin[2]);
85
86 /* assert */
87 CU_ASSERT((current = ags_lv2ui_plugin_find_gui_uri(list, AGS_LV2UI_PLUGIN_TEST_FIND_GUI_URI_SWH)) != NULL &&
88 current->data == lv2ui_plugin[0]);
89
90 CU_ASSERT((current = ags_lv2ui_plugin_find_gui_uri(list, AGS_LV2UI_PLUGIN_TEST_FIND_GUI_URI_INVADA)) != NULL &&
91 current->data == lv2ui_plugin[1]);
92
93 CU_ASSERT((current = ags_lv2ui_plugin_find_gui_uri(list, AGS_LV2UI_PLUGIN_TEST_FIND_GUI_URI_ZYN)) != NULL &&
94 current->data == lv2ui_plugin[2]);
95 }
96
97 int
main(int argc,char ** argv)98 main(int argc, char **argv)
99 {
100 CU_pSuite pSuite = NULL;
101
102 /* initialize the CUnit test registry */
103 if(CUE_SUCCESS != CU_initialize_registry()){
104 return CU_get_error();
105 }
106
107 /* add a suite to the registry */
108 pSuite = CU_add_suite("AgsLv2uiPluginTest", ags_lv2ui_plugin_test_init_suite, ags_lv2ui_plugin_test_clean_suite);
109
110 if(pSuite == NULL){
111 CU_cleanup_registry();
112
113 return CU_get_error();
114 }
115
116 /* add the tests to the suite */
117 if((CU_add_test(pSuite, "test of AgsLv2uiPlugin find GUI URI", ags_lv2ui_plugin_test_find_gui_uri) == NULL)){
118 CU_cleanup_registry();
119
120 return CU_get_error();
121 }
122
123 /* Run all tests using the CUnit Basic interface */
124 CU_basic_set_mode(CU_BRM_VERBOSE);
125 CU_basic_run_tests();
126
127 CU_cleanup_registry();
128
129 return(CU_get_error());
130 }
131