1 // Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <gtest/gtest.h>
6 #include <stdio.h>
7 #include <string.h>
8
9 extern "C" {
10 #include "cras_alert.h"
11 #include "cras_board_config.h"
12 #include "cras_shm.h"
13 #include "cras_system_state.h"
14 #include "cras_types.h"
15 }
16
17 namespace {
18 static struct cras_alsa_card* kFakeAlsaCard;
19 size_t cras_alsa_card_create_called;
20 size_t cras_alsa_card_destroy_called;
21 static size_t add_stub_called;
22 static size_t rm_stub_called;
23 static size_t add_task_stub_called;
24 static size_t callback_stub_called;
25 static void* select_data_value;
26 static void* task_data_value;
27 static size_t add_callback_called;
28 static cras_alert_cb add_callback_cb;
29 static void* add_callback_arg;
30 static size_t rm_callback_called;
31 static cras_alert_cb rm_callback_cb;
32 static void* rm_callback_arg;
33 static size_t alert_pending_called;
34 static char* device_config_dir;
35 static const char* cras_alsa_card_config_dir;
36 static size_t cras_observer_notify_output_volume_called;
37 static size_t cras_observer_notify_output_mute_called;
38 static size_t cras_observer_notify_capture_mute_called;
39 static size_t cras_observer_notify_suspend_changed_called;
40 static size_t cras_observer_notify_num_active_streams_called;
41 static size_t cras_observer_notify_input_streams_with_permission_called;
42 static size_t cras_iodev_list_reset_for_noise_cancellation_called;
43 static struct cras_board_config fake_board_config;
44 static size_t cras_alert_process_all_pending_alerts_called;
45
ResetStubData()46 static void ResetStubData() {
47 cras_alsa_card_create_called = 0;
48 cras_alsa_card_destroy_called = 0;
49 kFakeAlsaCard = reinterpret_cast<struct cras_alsa_card*>(0x33);
50 add_stub_called = 0;
51 rm_stub_called = 0;
52 add_task_stub_called = 0;
53 callback_stub_called = 0;
54 add_callback_called = 0;
55 rm_callback_called = 0;
56 alert_pending_called = 0;
57 device_config_dir = NULL;
58 cras_alsa_card_config_dir = NULL;
59 cras_observer_notify_output_volume_called = 0;
60 cras_observer_notify_output_mute_called = 0;
61 cras_observer_notify_capture_mute_called = 0;
62 cras_observer_notify_suspend_changed_called = 0;
63 cras_observer_notify_num_active_streams_called = 0;
64 cras_observer_notify_input_streams_with_permission_called = 0;
65 cras_alert_process_all_pending_alerts_called = 0;
66 cras_iodev_list_reset_for_noise_cancellation_called = 0;
67 memset(&fake_board_config, 0, sizeof(fake_board_config));
68 }
69
add_stub(int fd,void (* cb)(void * data,int revents),void * callback_data,int events,void * select_data)70 static int add_stub(int fd,
71 void (*cb)(void* data, int revents),
72 void* callback_data,
73 int events,
74 void* select_data) {
75 add_stub_called++;
76 select_data_value = select_data;
77 return 0;
78 }
79
rm_stub(int fd,void * select_data)80 static void rm_stub(int fd, void* select_data) {
81 rm_stub_called++;
82 select_data_value = select_data;
83 }
84
add_task_stub(void (* cb)(void * data),void * callback_data,void * task_data)85 static int add_task_stub(void (*cb)(void* data),
86 void* callback_data,
87 void* task_data) {
88 add_task_stub_called++;
89 task_data_value = task_data;
90 return 0;
91 }
92
callback_stub(void * data,int revents)93 static void callback_stub(void* data, int revents) {
94 callback_stub_called++;
95 }
96
task_stub(void * data)97 static void task_stub(void* data) {
98 callback_stub_called++;
99 }
100
do_sys_init()101 static void do_sys_init() {
102 char* shm_name;
103 ASSERT_GT(asprintf(&shm_name, "/cras-%d", getpid()), 0);
104 int rw_shm_fd;
105 int ro_shm_fd;
106 struct cras_server_state* exp_state =
107 (struct cras_server_state*)cras_shm_setup(shm_name, sizeof(*exp_state),
108 &rw_shm_fd, &ro_shm_fd);
109 if (!exp_state)
110 exit(-1);
111 cras_system_state_init(device_config_dir, shm_name, rw_shm_fd, ro_shm_fd,
112 exp_state, sizeof(*exp_state));
113 free(shm_name);
114 }
115
TEST(SystemStateSuite,DefaultVolume)116 TEST(SystemStateSuite, DefaultVolume) {
117 do_sys_init();
118 EXPECT_EQ(100, cras_system_get_volume());
119 EXPECT_EQ(0, cras_system_get_mute());
120 EXPECT_EQ(0, cras_system_get_capture_mute());
121 cras_system_state_deinit();
122 }
123
TEST(SystemStateSuite,SetVolume)124 TEST(SystemStateSuite, SetVolume) {
125 do_sys_init();
126 cras_system_set_volume(0);
127 EXPECT_EQ(0, cras_system_get_volume());
128 cras_system_set_volume(50);
129 EXPECT_EQ(50, cras_system_get_volume());
130 cras_system_set_volume(CRAS_MAX_SYSTEM_VOLUME);
131 EXPECT_EQ(CRAS_MAX_SYSTEM_VOLUME, cras_system_get_volume());
132 cras_system_set_volume(CRAS_MAX_SYSTEM_VOLUME + 1);
133 EXPECT_EQ(CRAS_MAX_SYSTEM_VOLUME, cras_system_get_volume());
134 cras_system_state_deinit();
135 EXPECT_EQ(4, cras_observer_notify_output_volume_called);
136 }
137
TEST(SystemStateSuite,SetMinMaxVolume)138 TEST(SystemStateSuite, SetMinMaxVolume) {
139 do_sys_init();
140 cras_system_set_volume_limits(-10000, -600);
141 EXPECT_EQ(-10000, cras_system_get_min_volume());
142 EXPECT_EQ(-600, cras_system_get_max_volume());
143 cras_system_state_deinit();
144 }
145
TEST(SystemStateSuite,SetUserMute)146 TEST(SystemStateSuite, SetUserMute) {
147 ResetStubData();
148 do_sys_init();
149
150 EXPECT_EQ(0, cras_system_get_mute());
151
152 cras_system_set_user_mute(0);
153 EXPECT_EQ(0, cras_system_get_mute());
154 EXPECT_EQ(0, cras_observer_notify_output_mute_called);
155
156 cras_system_set_user_mute(1);
157 EXPECT_EQ(1, cras_system_get_mute());
158 EXPECT_EQ(1, cras_observer_notify_output_mute_called);
159
160 cras_system_set_user_mute(22);
161 EXPECT_EQ(1, cras_system_get_mute());
162 EXPECT_EQ(1, cras_observer_notify_output_mute_called);
163
164 cras_system_state_deinit();
165 }
166
TEST(SystemStateSuite,SetMute)167 TEST(SystemStateSuite, SetMute) {
168 ResetStubData();
169 do_sys_init();
170
171 EXPECT_EQ(0, cras_system_get_mute());
172
173 cras_system_set_mute(0);
174 EXPECT_EQ(0, cras_system_get_mute());
175 EXPECT_EQ(0, cras_observer_notify_output_mute_called);
176
177 cras_system_set_mute(1);
178 EXPECT_EQ(1, cras_system_get_mute());
179 EXPECT_EQ(1, cras_observer_notify_output_mute_called);
180
181 cras_system_set_mute(22);
182 EXPECT_EQ(1, cras_system_get_mute());
183 EXPECT_EQ(1, cras_observer_notify_output_mute_called);
184
185 cras_system_state_deinit();
186 }
187
TEST(SystemStateSuite,SetSystemMuteThenSwitchUserMute)188 TEST(SystemStateSuite, SetSystemMuteThenSwitchUserMute) {
189 ResetStubData();
190 do_sys_init();
191
192 EXPECT_EQ(0, cras_system_get_mute());
193
194 // Set system mute.
195 cras_system_set_mute(1);
196
197 // Switching user mute will not notify observer.
198 EXPECT_EQ(1, cras_observer_notify_output_mute_called);
199 cras_system_set_user_mute(1);
200 EXPECT_EQ(1, cras_observer_notify_output_mute_called);
201 cras_system_set_user_mute(0);
202 EXPECT_EQ(1, cras_observer_notify_output_mute_called);
203
204 // Unset system mute.
205 cras_system_set_mute(0);
206 EXPECT_EQ(2, cras_observer_notify_output_mute_called);
207
208 cras_system_state_deinit();
209 }
210
TEST(SystemStateSuite,SetUserMuteThenSwitchSystemMute)211 TEST(SystemStateSuite, SetUserMuteThenSwitchSystemMute) {
212 ResetStubData();
213 do_sys_init();
214
215 EXPECT_EQ(0, cras_system_get_mute());
216
217 // Set user mute.
218 cras_system_set_user_mute(1);
219
220 // Switching system mute will not notify observer.
221 EXPECT_EQ(1, cras_observer_notify_output_mute_called);
222 cras_system_set_mute(1);
223 EXPECT_EQ(1, cras_observer_notify_output_mute_called);
224 cras_system_set_mute(0);
225 EXPECT_EQ(1, cras_observer_notify_output_mute_called);
226
227 // Unset user mute.
228 cras_system_set_user_mute(0);
229 EXPECT_EQ(2, cras_observer_notify_output_mute_called);
230
231 cras_system_state_deinit();
232 }
233
TEST(SystemStateSuite,CaptureMuteChangedCallbackMultiple)234 TEST(SystemStateSuite, CaptureMuteChangedCallbackMultiple) {
235 do_sys_init();
236 ResetStubData();
237
238 cras_system_set_capture_mute(1);
239 EXPECT_EQ(1, cras_system_get_capture_mute());
240 EXPECT_EQ(1, cras_observer_notify_capture_mute_called);
241 cras_system_set_capture_mute(0);
242 EXPECT_EQ(0, cras_system_get_capture_mute());
243 EXPECT_EQ(2, cras_observer_notify_capture_mute_called);
244
245 cras_system_state_deinit();
246 }
247
TEST(SystemStateSuite,MuteLocked)248 TEST(SystemStateSuite, MuteLocked) {
249 do_sys_init();
250 ResetStubData();
251
252 cras_system_set_mute(1);
253 EXPECT_EQ(1, cras_system_get_mute());
254 EXPECT_EQ(0, cras_system_get_mute_locked());
255 EXPECT_EQ(1, cras_observer_notify_output_mute_called);
256
257 cras_system_set_mute_locked(1);
258 cras_system_set_mute(0);
259 EXPECT_EQ(1, cras_system_get_mute());
260 EXPECT_EQ(1, cras_system_get_mute_locked());
261 EXPECT_EQ(1, cras_observer_notify_output_mute_called);
262
263 cras_system_set_capture_mute(1);
264 EXPECT_EQ(1, cras_system_get_capture_mute());
265 EXPECT_EQ(0, cras_system_get_capture_mute_locked());
266 EXPECT_EQ(1, cras_observer_notify_capture_mute_called);
267
268 cras_system_set_capture_mute_locked(1);
269 cras_system_set_capture_mute(0);
270 EXPECT_EQ(1, cras_system_get_capture_mute());
271 EXPECT_EQ(1, cras_system_get_capture_mute_locked());
272 cras_system_state_deinit();
273 EXPECT_EQ(2, cras_observer_notify_capture_mute_called);
274 }
275
TEST(SystemStateSuite,Suspend)276 TEST(SystemStateSuite, Suspend) {
277 do_sys_init();
278 ResetStubData();
279
280 cras_system_set_suspended(1);
281 EXPECT_EQ(1, cras_observer_notify_suspend_changed_called);
282 EXPECT_EQ(1, cras_alert_process_all_pending_alerts_called);
283 EXPECT_EQ(1, cras_system_get_suspended());
284
285 cras_system_set_suspended(0);
286 EXPECT_EQ(2, cras_observer_notify_suspend_changed_called);
287 EXPECT_EQ(0, cras_system_get_suspended());
288
289 cras_system_state_deinit();
290 }
291
TEST(SystemStateSuite,AddCardFailCreate)292 TEST(SystemStateSuite, AddCardFailCreate) {
293 ResetStubData();
294 kFakeAlsaCard = NULL;
295 cras_alsa_card_info info;
296
297 info.card_type = ALSA_CARD_TYPE_INTERNAL;
298 info.card_index = 0;
299 do_sys_init();
300 EXPECT_EQ(-ENOMEM, cras_system_add_alsa_card(&info));
301 EXPECT_EQ(1, cras_alsa_card_create_called);
302 EXPECT_EQ(cras_alsa_card_config_dir, device_config_dir);
303 cras_system_state_deinit();
304 }
305
TEST(SystemStateSuite,AddCard)306 TEST(SystemStateSuite, AddCard) {
307 ResetStubData();
308 cras_alsa_card_info info;
309
310 info.card_type = ALSA_CARD_TYPE_INTERNAL;
311 info.card_index = 0;
312 do_sys_init();
313 EXPECT_EQ(0, cras_system_add_alsa_card(&info));
314 EXPECT_EQ(1, cras_alsa_card_create_called);
315 EXPECT_EQ(cras_alsa_card_config_dir, device_config_dir);
316 // Adding the same card again should fail.
317 ResetStubData();
318 EXPECT_NE(0, cras_system_add_alsa_card(&info));
319 EXPECT_EQ(0, cras_alsa_card_create_called);
320 // Removing card should destroy it.
321 cras_system_remove_alsa_card(0);
322 EXPECT_EQ(1, cras_alsa_card_destroy_called);
323 cras_system_state_deinit();
324 }
325
TEST(SystemSettingsRegisterSelectDescriptor,AddSelectFd)326 TEST(SystemSettingsRegisterSelectDescriptor, AddSelectFd) {
327 void* stub_data = reinterpret_cast<void*>(44);
328 void* select_data = reinterpret_cast<void*>(33);
329 int rc;
330
331 ResetStubData();
332 do_sys_init();
333 rc = cras_system_add_select_fd(7, callback_stub, stub_data, POLLIN);
334 EXPECT_NE(0, rc);
335 EXPECT_EQ(0, add_stub_called);
336 EXPECT_EQ(0, rm_stub_called);
337 rc = cras_system_set_select_handler(add_stub, rm_stub, select_data);
338 EXPECT_EQ(0, rc);
339 EXPECT_EQ(0, add_stub_called);
340 EXPECT_EQ(0, rm_stub_called);
341 rc = cras_system_set_select_handler(add_stub, rm_stub, select_data);
342 EXPECT_EQ(-EEXIST, rc);
343 EXPECT_EQ(0, add_stub_called);
344 EXPECT_EQ(0, rm_stub_called);
345 rc = cras_system_add_select_fd(7, callback_stub, stub_data, POLLIN);
346 EXPECT_EQ(0, rc);
347 EXPECT_EQ(1, add_stub_called);
348 EXPECT_EQ(select_data, select_data_value);
349 cras_system_rm_select_fd(7);
350 EXPECT_EQ(1, rm_stub_called);
351 EXPECT_EQ(0, callback_stub_called);
352 EXPECT_EQ(select_data, select_data_value);
353 cras_system_state_deinit();
354 }
355
TEST(SystemSettingsAddTask,AddTask)356 TEST(SystemSettingsAddTask, AddTask) {
357 void* stub_data = reinterpret_cast<void*>(44);
358 void* task_data = reinterpret_cast<void*>(33);
359 int rc;
360
361 do_sys_init();
362 rc = cras_system_add_task(task_stub, stub_data);
363 EXPECT_NE(0, rc);
364 EXPECT_EQ(0, add_task_stub_called);
365 rc = cras_system_set_add_task_handler(add_task_stub, task_data);
366 EXPECT_EQ(0, rc);
367 EXPECT_EQ(0, add_task_stub_called);
368 rc = cras_system_add_task(task_stub, stub_data);
369 EXPECT_EQ(0, rc);
370 EXPECT_EQ(1, add_task_stub_called);
371 EXPECT_EQ(task_data, task_data_value);
372
373 cras_system_state_deinit();
374 }
375
TEST(SystemSettingsStreamCount,StreamCount)376 TEST(SystemSettingsStreamCount, StreamCount) {
377 ResetStubData();
378 do_sys_init();
379
380 EXPECT_EQ(0, cras_system_state_get_active_streams());
381 cras_system_state_stream_added(CRAS_STREAM_OUTPUT, CRAS_CLIENT_TYPE_CHROME);
382 EXPECT_EQ(1, cras_system_state_get_active_streams());
383 struct cras_timespec ts1;
384 cras_system_state_get_last_stream_active_time(&ts1);
385 cras_system_state_stream_removed(CRAS_STREAM_OUTPUT, CRAS_CLIENT_TYPE_CHROME);
386 EXPECT_EQ(0, cras_system_state_get_active_streams());
387 struct cras_timespec ts2;
388 cras_system_state_get_last_stream_active_time(&ts2);
389 EXPECT_NE(0, memcmp(&ts1, &ts2, sizeof(ts1)));
390 cras_system_state_deinit();
391 }
392
TEST(SystemSettingsStreamCount,StreamCountByDirection)393 TEST(SystemSettingsStreamCount, StreamCountByDirection) {
394 ResetStubData();
395 do_sys_init();
396
397 EXPECT_EQ(0, cras_system_state_get_active_streams());
398 cras_system_state_stream_added(CRAS_STREAM_OUTPUT, CRAS_CLIENT_TYPE_CHROME);
399 cras_system_state_stream_added(CRAS_STREAM_INPUT, CRAS_CLIENT_TYPE_CHROME);
400 cras_system_state_stream_added(CRAS_STREAM_POST_MIX_PRE_DSP,
401 CRAS_CLIENT_TYPE_CHROME);
402 EXPECT_EQ(1, cras_observer_notify_input_streams_with_permission_called);
403 EXPECT_EQ(
404 1, cras_system_state_get_active_streams_by_direction(CRAS_STREAM_OUTPUT));
405 EXPECT_EQ(
406 1, cras_system_state_get_active_streams_by_direction(CRAS_STREAM_INPUT));
407 EXPECT_EQ(1, cras_system_state_get_active_streams_by_direction(
408 CRAS_STREAM_POST_MIX_PRE_DSP));
409 EXPECT_EQ(3, cras_system_state_get_active_streams());
410 EXPECT_EQ(3, cras_observer_notify_num_active_streams_called);
411 cras_system_state_stream_removed(CRAS_STREAM_OUTPUT, CRAS_CLIENT_TYPE_CHROME);
412 cras_system_state_stream_removed(CRAS_STREAM_INPUT, CRAS_CLIENT_TYPE_CHROME);
413 cras_system_state_stream_removed(CRAS_STREAM_POST_MIX_PRE_DSP,
414 CRAS_CLIENT_TYPE_CHROME);
415 EXPECT_EQ(2, cras_observer_notify_input_streams_with_permission_called);
416 EXPECT_EQ(
417 0, cras_system_state_get_active_streams_by_direction(CRAS_STREAM_OUTPUT));
418 EXPECT_EQ(
419 0, cras_system_state_get_active_streams_by_direction(CRAS_STREAM_INPUT));
420 EXPECT_EQ(0, cras_system_state_get_active_streams_by_direction(
421 CRAS_STREAM_POST_MIX_PRE_DSP));
422 EXPECT_EQ(0, cras_system_state_get_active_streams());
423 EXPECT_EQ(6, cras_observer_notify_num_active_streams_called);
424
425 cras_system_state_deinit();
426 }
427
TEST(SystemStateSuite,IgnoreUCMSuffix)428 TEST(SystemStateSuite, IgnoreUCMSuffix) {
429 fake_board_config.ucm_ignore_suffix = strdup("TEST1,TEST2,TEST3");
430 do_sys_init();
431
432 EXPECT_EQ(1, cras_system_check_ignore_ucm_suffix("TEST1"));
433 EXPECT_EQ(1, cras_system_check_ignore_ucm_suffix("TEST2"));
434 EXPECT_EQ(1, cras_system_check_ignore_ucm_suffix("TEST3"));
435 EXPECT_EQ(0, cras_system_check_ignore_ucm_suffix("TEST4"));
436 cras_system_state_deinit();
437 }
438
TEST(SystemStateSuite,SetNoiseCancellationEnabled)439 TEST(SystemStateSuite, SetNoiseCancellationEnabled) {
440 ResetStubData();
441 do_sys_init();
442
443 EXPECT_EQ(0, cras_system_get_noise_cancellation_enabled());
444
445 cras_system_set_noise_cancellation_enabled(0);
446 EXPECT_EQ(0, cras_system_get_noise_cancellation_enabled());
447 EXPECT_EQ(0, cras_iodev_list_reset_for_noise_cancellation_called);
448
449 cras_system_set_noise_cancellation_enabled(1);
450 EXPECT_EQ(1, cras_system_get_noise_cancellation_enabled());
451 EXPECT_EQ(1, cras_iodev_list_reset_for_noise_cancellation_called);
452
453 cras_system_set_noise_cancellation_enabled(1);
454 EXPECT_EQ(1, cras_system_get_noise_cancellation_enabled());
455 // cras_iodev_list_reset_for_noise_cancellation shouldn't be called if state
456 // is already enabled/disabled.
457 EXPECT_EQ(1, cras_iodev_list_reset_for_noise_cancellation_called);
458
459 cras_system_set_noise_cancellation_enabled(0);
460 EXPECT_EQ(0, cras_system_get_noise_cancellation_enabled());
461 EXPECT_EQ(2, cras_iodev_list_reset_for_noise_cancellation_called);
462
463 cras_system_state_deinit();
464 }
465
466 extern "C" {
467
cras_alsa_card_create(struct cras_alsa_card_info * info,const char * device_config_dir,struct cras_device_blocklist * blocklist)468 struct cras_alsa_card* cras_alsa_card_create(
469 struct cras_alsa_card_info* info,
470 const char* device_config_dir,
471 struct cras_device_blocklist* blocklist) {
472 cras_alsa_card_create_called++;
473 cras_alsa_card_config_dir = device_config_dir;
474 return kFakeAlsaCard;
475 }
476
cras_alsa_card_destroy(struct cras_alsa_card * alsa_card)477 void cras_alsa_card_destroy(struct cras_alsa_card* alsa_card) {
478 cras_alsa_card_destroy_called++;
479 }
480
cras_alsa_card_get_index(const struct cras_alsa_card * alsa_card)481 size_t cras_alsa_card_get_index(const struct cras_alsa_card* alsa_card) {
482 return 0;
483 }
484
cras_device_blocklist_create(const char * config_path)485 struct cras_device_blocklist* cras_device_blocklist_create(
486 const char* config_path) {
487 return NULL;
488 }
489
cras_device_blocklist_destroy(struct cras_device_blocklist * blocklist)490 void cras_device_blocklist_destroy(struct cras_device_blocklist* blocklist) {}
491
cras_alert_create(cras_alert_prepare prepare,unsigned int flags)492 struct cras_alert* cras_alert_create(cras_alert_prepare prepare,
493 unsigned int flags) {
494 return NULL;
495 }
496
cras_alert_destroy(struct cras_alert * alert)497 void cras_alert_destroy(struct cras_alert* alert) {}
498
cras_alert_add_callback(struct cras_alert * alert,cras_alert_cb cb,void * arg)499 int cras_alert_add_callback(struct cras_alert* alert,
500 cras_alert_cb cb,
501 void* arg) {
502 add_callback_called++;
503 add_callback_cb = cb;
504 add_callback_arg = arg;
505 return 0;
506 }
507
cras_alert_rm_callback(struct cras_alert * alert,cras_alert_cb cb,void * arg)508 int cras_alert_rm_callback(struct cras_alert* alert,
509 cras_alert_cb cb,
510 void* arg) {
511 rm_callback_called++;
512 rm_callback_cb = cb;
513 rm_callback_arg = arg;
514 return 0;
515 }
516
cras_alert_pending(struct cras_alert * alert)517 void cras_alert_pending(struct cras_alert* alert) {
518 alert_pending_called++;
519 }
520
cras_tm_init()521 cras_tm* cras_tm_init() {
522 return static_cast<cras_tm*>(malloc(sizeof(unsigned int)));
523 }
524
cras_tm_deinit(cras_tm * tm)525 void cras_tm_deinit(cras_tm* tm) {
526 free(tm);
527 }
528
cras_observer_notify_output_volume(int32_t volume)529 void cras_observer_notify_output_volume(int32_t volume) {
530 cras_observer_notify_output_volume_called++;
531 }
532
cras_observer_notify_output_mute(int muted,int user_muted,int mute_locked)533 void cras_observer_notify_output_mute(int muted,
534 int user_muted,
535 int mute_locked) {
536 cras_observer_notify_output_mute_called++;
537 }
538
cras_observer_notify_capture_mute(int muted,int mute_locked)539 void cras_observer_notify_capture_mute(int muted, int mute_locked) {
540 cras_observer_notify_capture_mute_called++;
541 }
542
cras_observer_notify_suspend_changed(int suspended)543 void cras_observer_notify_suspend_changed(int suspended) {
544 cras_observer_notify_suspend_changed_called++;
545 }
546
cras_observer_notify_num_active_streams(enum CRAS_STREAM_DIRECTION dir,uint32_t num_active_streams)547 void cras_observer_notify_num_active_streams(enum CRAS_STREAM_DIRECTION dir,
548 uint32_t num_active_streams) {
549 cras_observer_notify_num_active_streams_called++;
550 }
551
cras_observer_notify_input_streams_with_permission(uint32_t num_input_streams[CRAS_NUM_CLIENT_TYPE])552 void cras_observer_notify_input_streams_with_permission(
553 uint32_t num_input_streams[CRAS_NUM_CLIENT_TYPE]) {
554 cras_observer_notify_input_streams_with_permission_called++;
555 }
556
cras_board_config_get(const char * config_path,struct cras_board_config * board_config)557 void cras_board_config_get(const char* config_path,
558 struct cras_board_config* board_config) {
559 *board_config = fake_board_config;
560 }
561
cras_alert_process_all_pending_alerts()562 void cras_alert_process_all_pending_alerts() {
563 cras_alert_process_all_pending_alerts_called++;
564 }
565
cras_iodev_list_reset_for_noise_cancellation()566 void cras_iodev_list_reset_for_noise_cancellation() {
567 cras_iodev_list_reset_for_noise_cancellation_called++;
568 }
569
570 } // extern "C"
571 } // namespace
572
main(int argc,char ** argv)573 int main(int argc, char** argv) {
574 ::testing::InitGoogleTest(&argc, argv);
575 return RUN_ALL_TESTS();
576 }
577