Skip to content

Commit

Permalink
Removed display-dependent tests
Browse files Browse the repository at this point in the history
  • Loading branch information
samclane committed Oct 2, 2024
1 parent 32b2945 commit 4ab4bc1
Showing 1 changed file with 0 additions and 116 deletions.
116 changes: 0 additions & 116 deletions src/screencap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,119 +215,3 @@ impl ScreencapManager {
.into())
}
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_screen_subregion_reset() {
let mut subregion = ScreenSubregion {
// monitor: Some(Arc::new(Monitor::primary().unwrap())),
monitor: Some(Arc::new(Monitor::all().unwrap().first().unwrap().clone())),
x: 100,
y: 100,
width: 200,
height: 200,
};
subregion.reset();
assert!(subregion.monitor.is_none());
assert_eq!(subregion.x, 0);
assert_eq!(subregion.y, 0);
assert_eq!(subregion.width, 0);
assert_eq!(subregion.height, 0);
}

#[test]
fn test_screencap_manager_new() {
let manager = ScreencapManager::new();
assert!(manager.is_ok());
}

#[test]
fn test_screencap_manager_monitor_names() {
let manager = ScreencapManager::new().unwrap();
let names = manager.monitor_names();
assert!(!names.is_empty());
}

#[test]
fn test_screencap_manager_window_titles() {
let manager = ScreencapManager::new().unwrap();
let titles = manager.window_titles();
assert!(!titles.is_empty());
}

#[test]
fn test_screencap_manager_get_monitor() {
let manager = ScreencapManager::new().unwrap();
let names = manager.monitor_names();
if let Some(name) = names.first() {
let monitor = manager.get_monitor(name);
assert!(monitor.is_some());
assert_eq!(monitor.unwrap().name(), name);
}
}

#[test]
fn test_screencap_manager_get_window() {
let manager = ScreencapManager::new().unwrap();
let titles = manager.window_titles();
if let Some(title) = titles.first() {
let window = manager.get_window(title);
assert!(window.is_some());
assert_eq!(window.unwrap().title(), title);
}
}

#[test]
fn test_screencap_manager_from_click() {
let manager = ScreencapManager::new().unwrap();
let monitor = Monitor::all().unwrap().first().unwrap().clone();
let x = monitor.x() + monitor.width() as i32 / 2;
let y = monitor.y() + monitor.height() as i32 / 2;
let color = manager.from_click(x, y);
assert!(color.is_ok());
}

#[test]
fn test_screencap_manager_bounding_box() {
let manager = ScreencapManager::new().unwrap();
let rect = manager.bounding_box();
assert!(rect.width() > 0.0);
assert!(rect.height() > 0.0);
}

#[test]
fn test_screencap_manager_avg_color_all() {
let manager = ScreencapManager::new().unwrap();
let color = manager.avg_color(FollowType::All);
assert!(color.is_ok());
}

#[test]
fn test_screencap_manager_avg_color_monitor() {
let manager = ScreencapManager::new().unwrap();
let monitors = manager.monitors.clone();
let color = manager.avg_color(FollowType::Monitor(monitors));
assert!(color.is_ok());
}

#[test]
fn test_screencap_manager_avg_color_window() {
let manager = ScreencapManager::new().unwrap();
let windows = manager.windows.clone();
let color = manager.avg_color(FollowType::Window(windows));
assert!(color.is_ok());
}

#[test]
fn test_follow_type_equality() {
let manager = ScreencapManager::new().unwrap();
let monitors1 = manager.monitors.clone();
let monitors2 = manager.monitors.clone();
let follow1 = FollowType::Monitor(monitors1);
let follow2 = FollowType::Monitor(monitors2);
assert_eq!(follow1, follow2);
}
}

0 comments on commit 4ab4bc1

Please sign in to comment.