Skip to content

Commit 6c22759

Browse files
committed
Tighten the device-switch-while-paused test: check that the devices are the ones we expect before and after switching
1 parent 7a95143 commit 6c22759

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

src/backend/tests/device_change.rs

+24
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,18 @@ fn test_switch_device_in_scope_while_paused(scope: Scope) {
120120
stm.core_stream_data.input_unit
121121
};
122122

123+
if scope == Scope::Output {
124+
assert_eq!(
125+
stm.core_stream_data.output_device.id,
126+
device_switcher.current()
127+
);
128+
} else {
129+
assert_eq!(
130+
stm.core_stream_data.input_device.id,
131+
device_switcher.current()
132+
);
133+
}
134+
123135
// Pause the stream, and change the default device
124136
assert_eq!(unsafe { OPS.stream_stop.unwrap()(stream) }, ffi::CUBEB_OK);
125137

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

163+
if scope == Scope::Output {
164+
assert_eq!(
165+
stm.core_stream_data.output_device.id,
166+
device_switcher.current()
167+
);
168+
} else {
169+
assert_eq!(
170+
stm.core_stream_data.input_device.id,
171+
device_switcher.current()
172+
);
173+
}
174+
151175
let after = if scope == Scope::Output {
152176
stm.core_stream_data.output_unit
153177
} else {

src/backend/tests/utils.rs

+3
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,9 @@ impl TestDeviceSwitcher {
780780
}
781781
}
782782
}
783+
pub fn current(&self) -> AudioObjectID {
784+
self.devices[self.current_device_index]
785+
}
783786

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

0 commit comments

Comments
 (0)