mirror of
https://github.com/bleackstorm/SteamFrame-FPV-Control-Center.git
synced 2026-12-03 07:31:57 +01:00
feat(openxr): add comprehensive automated test pipeline and unit tests for projection modes
This commit is contained in:
1 parent
93a0868b67
commit
b9a1ce0699
4 files changed
+156
-2
No files matched your search
@@ -93,3 +93,56 @@ impl DomeWarpLut {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_projection_mode_parsing() {
|
||||
assert_eq!(ProjectionMode::from_str("dome"), ProjectionMode::Dome140);
|
||||
assert_eq!(ProjectionMode::from_str("DOME"), ProjectionMode::Dome140);
|
||||
assert_eq!(ProjectionMode::from_str("cylinder"), ProjectionMode::Cylinder140);
|
||||
assert_eq!(ProjectionMode::from_str("cyl"), ProjectionMode::Cylinder140);
|
||||
assert_eq!(ProjectionMode::from_str("flat"), ProjectionMode::FlatQuad);
|
||||
assert_eq!(ProjectionMode::from_str("quad"), ProjectionMode::FlatQuad);
|
||||
assert_eq!(ProjectionMode::from_str("unknown"), ProjectionMode::Dome140);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_dome_warp_lut_disabled() {
|
||||
let lut = DomeWarpLut::new(64, 64, 140.0, 0.0, 0.0);
|
||||
assert!(!lut.enabled);
|
||||
|
||||
let input = vec![42u8; 64 * 64 * 4];
|
||||
let mut output = vec![0u8; 64 * 64 * 4];
|
||||
lut.apply(&input, &mut output);
|
||||
assert_eq!(output, input);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_dome_warp_lut_barrel_correction() {
|
||||
let width = 128;
|
||||
let height = 72;
|
||||
let lut = DomeWarpLut::new(width, height, 140.0, -0.14, 0.03);
|
||||
assert!(lut.enabled);
|
||||
assert_eq!(lut.src_byte_offsets.len(), (width * height) as usize);
|
||||
|
||||
// Vérifier que tous les offsets sources restent strictement dans les limites de la mémoire
|
||||
let max_valid_byte = (width * height * 4) as usize - 4;
|
||||
for &offset in &lut.src_byte_offsets {
|
||||
assert!(offset <= max_valid_byte, "Offset {} dépasse la taille tampon", offset);
|
||||
}
|
||||
|
||||
let mut input = vec![128u8; (width * height * 4) as usize];
|
||||
// Marquer le centre
|
||||
let center_offset = ((height / 2 * width + width / 2) * 4) as usize;
|
||||
input[center_offset] = 255;
|
||||
|
||||
let mut output = vec![0u8; (width * height * 4) as usize];
|
||||
lut.apply(&input, &mut output);
|
||||
|
||||
// Le centre ne doit pas subir de déplacement extrême
|
||||
assert_eq!(output[center_offset], 255);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user