Skip to content

Commit

Permalink
Tighten the device-switch-while-paused test: check that the devices a…
Browse files Browse the repository at this point in the history
…re the ones we expect before and after switching
  • Loading branch information
padenot committed Aug 9, 2024
1 parent b0e594b commit 7deb2a2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/backend/tests/device_change.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,18 @@ fn test_switch_device_in_scope_while_paused(scope: Scope) {
stm.core_stream_data.input_unit
};

if scope == Scope::Output {
assert_eq!(
stm.core_stream_data.output_device.id,
device_switcher.current()
);
} else {
assert_eq!(
stm.core_stream_data.input_device.id,
device_switcher.current()
);
}

// Pause the stream, and change the default device
assert_eq!(unsafe { OPS.stream_stop.unwrap()(stream) }, ffi::CUBEB_OK);

Expand Down Expand Up @@ -148,6 +160,18 @@ fn test_switch_device_in_scope_while_paused(scope: Scope) {
// Start the stream, and check that the device in use isn't the same as before pausing
assert_eq!(unsafe { OPS.stream_start.unwrap()(stream) }, ffi::CUBEB_OK);

if scope == Scope::Output {
assert_eq!(
stm.core_stream_data.output_device.id,
device_switcher.current()
);
} else {
assert_eq!(
stm.core_stream_data.input_device.id,
device_switcher.current()
);
}

let after = if scope == Scope::Output {
stm.core_stream_data.output_unit
} else {
Expand Down
3 changes: 3 additions & 0 deletions src/backend/tests/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,9 @@ impl TestDeviceSwitcher {
}
}
}
pub fn current(&self) -> AudioObjectID {
self.devices[self.current_device_index]
}

fn set_device(&self, device: AudioObjectID) -> std::result::Result<AudioObjectID, OSStatus> {
test_set_default_device(device, self.scope.clone())
Expand Down

0 comments on commit 7deb2a2

Please sign in to comment.