From f34253c0114b54c8adfca10471e45e837b84e7f8 Mon Sep 17 00:00:00 2001 From: Chun-Min Chang Date: Fri, 27 Oct 2023 09:18:36 -0700 Subject: [PATCH] DeviceFilter::ExcludeCubebAggregateAndVPIO --- run_device_tests.sh | 4 +--- src/backend/tests/aggregate_device.rs | 4 ++-- src/backend/tests/api.rs | 2 +- src/backend/tests/utils.rs | 9 +++++---- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/run_device_tests.sh b/run_device_tests.sh index ae6c3eb3..ffb6fb0b 100755 --- a/run_device_tests.sh +++ b/run_device_tests.sh @@ -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 diff --git a/src/backend/tests/aggregate_device.rs b/src/backend/tests/aggregate_device.rs index 49726f26..1d3c341a 100644 --- a/src/backend/tests/aggregate_device.rs +++ b/src/backend/tests/aggregate_device.rs @@ -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 @@ -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)); diff --git a/src/backend/tests/api.rs b/src/backend/tests/api.rs index 319b27f5..67b92f5b 100644 --- a/src/backend/tests/api.rs +++ b/src/backend/tests/api.rs @@ -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() { diff --git a/src/backend/tests/utils.rs b/src/backend/tests/utils.rs index dee6c8c3..69979e77 100644 --- a/src/backend/tests/utils.rs +++ b/src/backend/tests/utils.rs @@ -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 { let mut devices = Vec::new(); @@ -303,11 +303,12 @@ pub fn test_get_all_devices(filter: DeviceFilter) -> Vec { } 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 } @@ -320,7 +321,7 @@ pub fn test_get_all_devices(filter: DeviceFilter) -> Vec { } pub fn test_get_devices_in_scope(scope: Scope) -> Vec { - 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 }