Skip to content

Commit

Permalink
DeviceFilter::ExcludeCubebAggregateAndVPIO
Browse files Browse the repository at this point in the history
  • Loading branch information
ChunMinChang committed Oct 27, 2023
1 parent 30f36bb commit f34253c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
4 changes: 1 addition & 3 deletions run_device_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ cargo test test_plug_and_unplug_device -- --ignored --nocapture

cargo test test_register_device_changed_callback_to_check_default_device_changed_input -- --ignored --nocapture
cargo test test_register_device_changed_callback_to_check_default_device_changed_output -- --ignored --nocapture

# FIXME: The test will hang if the default input or output is an aggregate device (and VoiceProcessingIO is)
# cargo test test_register_device_changed_callback_to_check_default_device_changed_duplex -- --ignored --nocapture
cargo test test_register_device_changed_callback_to_check_default_device_changed_duplex -- --ignored --nocapture

cargo test test_register_device_changed_callback_to_check_input_alive_changed_input -- --ignored --nocapture
cargo test test_register_device_changed_callback_to_check_input_alive_changed_duplex -- --ignored --nocapture
Expand Down
4 changes: 2 additions & 2 deletions src/backend/tests/aggregate_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fn test_aggregate_set_sub_devices_for_unknown_devices() {
// application and print out the sub devices of them!
#[test]
fn test_aggregate_get_sub_devices() {
let devices = test_get_all_devices(DeviceFilter::ExcludeCubebAggregate);
let devices = test_get_all_devices(DeviceFilter::ExcludeCubebAggregateAndVPIO);
for device in devices {
// `AggregateDevice::get_sub_devices(device)` will return a single-element vector
// containing `device` itself if it's not an aggregate device. This test assumes devices
Expand Down Expand Up @@ -108,7 +108,7 @@ fn test_aggregate_create_blank_device() {
// TODO: Test this when there is no available devices.
let plugin = AggregateDevice::get_system_plugin_id().unwrap();
let device = AggregateDevice::create_blank_device_sync(plugin).unwrap();
let devices = test_get_all_devices(DeviceFilter::IncludeCubebAggregate);
let devices = test_get_all_devices(DeviceFilter::IncludeAll);
let device = devices.into_iter().find(|dev| dev == &device).unwrap();
let uid = get_device_global_uid(device).unwrap().into_string();
assert!(uid.contains(PRIVATE_AGGREGATE_DEVICE_NAME));
Expand Down
2 changes: 1 addition & 1 deletion src/backend/tests/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1447,7 +1447,7 @@ fn test_get_devices_of_type() {
let input_devices = audiounit_get_devices_of_type(DeviceType::INPUT);
let output_devices = audiounit_get_devices_of_type(DeviceType::OUTPUT);

let mut expected_all = test_get_all_devices(DeviceFilter::ExcludeCubebAggregate);
let mut expected_all = test_get_all_devices(DeviceFilter::ExcludeCubebAggregateAndVPIO);
expected_all.sort();
assert_eq!(all_devices, expected_all);
for device in all_devices.iter() {
Expand Down
9 changes: 5 additions & 4 deletions src/backend/tests/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,8 @@ fn u32_to_string(data: u32) -> String {
}

pub enum DeviceFilter {
ExcludeCubebAggregate,
IncludeCubebAggregate,
ExcludeCubebAggregateAndVPIO,
IncludeAll,
}
pub fn test_get_all_devices(filter: DeviceFilter) -> Vec<AudioObjectID> {
let mut devices = Vec::new();
Expand Down Expand Up @@ -303,11 +303,12 @@ pub fn test_get_all_devices(filter: DeviceFilter) -> Vec<AudioObjectID> {
}

match filter {
DeviceFilter::ExcludeCubebAggregate => {
DeviceFilter::ExcludeCubebAggregateAndVPIO => {
devices.retain(|&device| {
if let Ok(uid) = get_device_global_uid(device) {
let uid = uid.into_string();
!uid.contains(PRIVATE_AGGREGATE_DEVICE_NAME)
&& !uid.contains(VOICEPROCESSING_AGGREGATE_DEVICE_NAME)
} else {
true
}
Expand All @@ -320,7 +321,7 @@ pub fn test_get_all_devices(filter: DeviceFilter) -> Vec<AudioObjectID> {
}

pub fn test_get_devices_in_scope(scope: Scope) -> Vec<AudioObjectID> {
let mut devices = test_get_all_devices(DeviceFilter::ExcludeCubebAggregate);
let mut devices = test_get_all_devices(DeviceFilter::ExcludeCubebAggregateAndVPIO);
devices.retain(|device| test_device_in_scope(*device, scope.clone()));
devices
}
Expand Down

0 comments on commit f34253c

Please sign in to comment.