Add interface tests for register_device_changed_callback

This commit is contained in:
Chun-Min Chang 2019-04-19 09:24:04 -07:00
Родитель 1d49f890fc
Коммит afc55c0350
2 изменённых файлов: 29 добавлений и 2 удалений

Просмотреть файл

@ -2,6 +2,7 @@
//
// This program is made available under an ISC-style license. See the
// accompanying file LICENSE for details.
use super::utils::test_get_empty_stream;
use super::*;
// Interface
@ -55,3 +56,31 @@ fn test_context_register_device_collection_changed_twice_output() {
fn test_context_register_device_collection_changed_twice_inout() {
test_context_register_device_collection_changed_twice(DeviceType::INPUT | DeviceType::OUTPUT);
}
#[test]
fn test_stream_register_device_changed_callback() {
extern "C" fn callback(_: *mut c_void) {}
test_get_empty_stream(|stream| {
assert!(stream
.register_device_changed_callback(Some(callback))
.is_ok());
assert!(stream.register_device_changed_callback(None).is_ok());
});
}
#[test]
#[should_panic]
fn test_stream_register_device_changed_callback_twice() {
extern "C" fn callback1(_: *mut c_void) {}
extern "C" fn callback2(_: *mut c_void) {}
test_get_empty_stream(|stream| {
assert!(stream
.register_device_changed_callback(Some(callback1))
.is_ok());
assert!(stream
.register_device_changed_callback(Some(callback2))
.is_err());
});
}

Просмотреть файл

@ -568,5 +568,3 @@ fn test_ops_stream_device_destroy() {
// );
// });
// }
// TODO: Add a manual test for stream_register_device_changed_callback operation.