1 /* GSequencer - Advanced GTK Sequencer
2 * Copyright (C) 2005-2018 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_set_device_test_init_suite();
33 int ags_set_device_test_clean_suite();
34
35 void ags_set_device_test_launch();
36
37 /* The suite initialization function.
38 * Opens the temporary file used by the tests.
39 * Returns zero on success, non-zero otherwise.
40 */
41 int
ags_set_device_test_init_suite()42 ags_set_device_test_init_suite()
43 {
44 return(0);
45 }
46
47 /* The suite cleanup function.
48 * Closes the temporary file used by the tests.
49 * Returns zero on success, non-zero otherwise.
50 */
51 int
ags_set_device_test_clean_suite()52 ags_set_device_test_clean_suite()
53 {
54 return(0);
55 }
56
57 void
ags_set_device_test_launch()58 ags_set_device_test_launch()
59 {
60 AgsDevout *devout;
61
62 AgsSetDevice *set_device;
63
64 devout = ags_devout_new(NULL);
65
66 set_device = ags_set_device_new(devout,
67 "default");
68
69 CU_ASSERT(AGS_IS_SET_DEVICE(set_device));
70 CU_ASSERT(set_device->scope == devout);
71 CU_ASSERT(!g_strcmp0(set_device->device,
72 "default"));
73
74 /* launch */
75 ags_task_launch(set_device);
76
77 CU_ASSERT(!g_strcmp0(ags_soundcard_get_device(AGS_SOUNDCARD(devout)),
78 "default"));
79 }
80
81 int
main(int argc,char ** argv)82 main(int argc, char **argv)
83 {
84 CU_pSuite pSuite = NULL;
85
86 putenv("LC_ALL=C");
87 putenv("LANG=C");
88
89 /* initialize the CUnit test registry */
90 if(CUE_SUCCESS != CU_initialize_registry()){
91 return CU_get_error();
92 }
93
94 /* add a suite to the registry */
95 pSuite = CU_add_suite("AgsSetDeviceTest", ags_set_device_test_init_suite, ags_set_device_test_clean_suite);
96
97 if(pSuite == NULL){
98 CU_cleanup_registry();
99
100 return CU_get_error();
101 }
102
103 /* add the tests to the suite */
104 if((CU_add_test(pSuite, "test of AgsSetDevice launch", ags_set_device_test_launch) == NULL)){
105 CU_cleanup_registry();
106
107 return CU_get_error();
108 }
109
110 /* Run all tests using the CUnit Basic interface */
111 CU_basic_set_mode(CU_BRM_VERBOSE);
112 CU_basic_run_tests();
113
114 CU_cleanup_registry();
115
116 return(CU_get_error());
117 }
118