// SPDX-License-Identifier: GPL-3.0-or-later
//! Mock providers for testing.

use anyhow::Result;
use std::cell::RefCell;
use std::collections::HashMap;

use temperlux::display::provider::{BacklightDisplayInfo, BacklightProvider};

/// Mock backlight provider with configurable display list.
pub struct MockBacklightProvider {
    pub displays: Vec<BacklightDisplayInfo>,
    pub set_calls: RefCell<HashMap<String, u32>>,
}

impl MockBacklightProvider {
    pub fn new(displays: Vec<BacklightDisplayInfo>) -> Self {
        Self {
            displays,
            set_calls: RefCell::new(HashMap::new()),
        }
    }
}

impl BacklightProvider for MockBacklightProvider {
    fn detect(&self) -> Result<Vec<BacklightDisplayInfo>> {
        Ok(self.displays.clone())
    }

    fn set_brightness(&self, name: &str, raw_value: u32) -> Result<()> {
        self.set_calls.borrow_mut().insert(name.to_string(), raw_value);
        Ok(())
    }
}
