tests: Appease clippy by implementing Default for some backends

This commit is contained in:
Nathan Adams 2023-11-09 12:53:57 +01:00
parent 673d52f013
commit 2a2a717a06
2 changed files with 13 additions and 9 deletions

View File

@ -186,7 +186,7 @@ impl PlayerOptions {
}
if self.with_audio {
player_builder = player_builder.with_audio(TestAudioBackend::new());
player_builder = player_builder.with_audio(TestAudioBackend::default());
}
#[cfg(feature = "imgtests")]

View File

@ -34,11 +34,8 @@ pub struct TestAudioBackend {
buffer: Vec<f32>,
}
impl TestAudioBackend {
const NUM_CHANNELS: u8 = 2;
const SAMPLE_RATE: u32 = 44100;
pub fn new() -> Self {
impl Default for TestAudioBackend {
fn default() -> Self {
Self {
mixer: AudioMixer::new(Self::NUM_CHANNELS, Self::SAMPLE_RATE),
buffer: vec![],
@ -46,6 +43,11 @@ impl TestAudioBackend {
}
}
impl TestAudioBackend {
const NUM_CHANNELS: u8 = 2;
const SAMPLE_RATE: u32 = 44100;
}
impl AudioBackend for TestAudioBackend {
impl_audio_mixer_backend!(mixer);
fn play(&mut self) {}
@ -67,13 +69,15 @@ pub struct TestLogBackend {
trace_output: Rc<RefCell<String>>,
}
impl TestLogBackend {
pub fn new() -> Self {
impl Default for TestLogBackend {
fn default() -> Self {
Self {
trace_output: Rc::new(RefCell::new(String::new())),
}
}
}
impl TestLogBackend {
pub fn trace_output(self) -> String {
self.trace_output.take()
}
@ -105,7 +109,7 @@ pub fn run_swf(
let frame_time_duration = Duration::from_millis(frame_time as u64);
let log = TestLogBackend::new();
let log = TestLogBackend::default();
let (fs_command_provider, fs_commands) = TestFsCommandProvider::new();
let navigator = TestNavigatorBackend::new(
base_path,