#![cfg(feature = "macos_14_0")]
use screencapturekit::content_sharing_picker::{
SCContentSharingPickerConfiguration, SCContentSharingPickerMode,
};
#[test]
fn test_picker_configuration_creation() {
let config = SCContentSharingPickerConfiguration::new();
assert!(
!config.as_ptr().is_null(),
"Configuration pointer should not be null"
);
println!("✅ Picker configuration created");
}
#[test]
fn test_picker_configuration_modes() {
let mut config = SCContentSharingPickerConfiguration::new();
let modes = vec![
vec![SCContentSharingPickerMode::SingleWindow],
vec![SCContentSharingPickerMode::MultipleWindows],
vec![SCContentSharingPickerMode::SingleDisplay],
vec![SCContentSharingPickerMode::SingleApplication],
vec![SCContentSharingPickerMode::MultipleApplications],
vec![
SCContentSharingPickerMode::SingleWindow,
SCContentSharingPickerMode::SingleDisplay,
],
vec![
SCContentSharingPickerMode::SingleWindow,
SCContentSharingPickerMode::MultipleWindows,
SCContentSharingPickerMode::SingleDisplay,
SCContentSharingPickerMode::SingleApplication,
SCContentSharingPickerMode::MultipleApplications,
],
];
for mode_set in modes {
config.set_allowed_picker_modes(&mode_set);
println!("✅ Set picker modes: {mode_set:?}");
}
}
#[test]
fn test_picker_mode_values() {
assert_eq!(SCContentSharingPickerMode::SingleWindow as i32, 0);
assert_eq!(SCContentSharingPickerMode::MultipleWindows as i32, 1);
assert_eq!(SCContentSharingPickerMode::SingleDisplay as i32, 2);
assert_eq!(SCContentSharingPickerMode::SingleApplication as i32, 3);
assert_eq!(SCContentSharingPickerMode::MultipleApplications as i32, 4);
println!("✅ Picker mode values correct");
}
#[test]
fn test_picker_configuration_reuse() {
let mut config = SCContentSharingPickerConfiguration::new();
config.set_allowed_picker_modes(&[SCContentSharingPickerMode::SingleWindow]);
config.set_allowed_picker_modes(&[SCContentSharingPickerMode::SingleDisplay]);
config.set_allowed_picker_modes(&[
SCContentSharingPickerMode::SingleWindow,
SCContentSharingPickerMode::SingleDisplay,
]);
println!("✅ Configuration can be reused");
}
#[test]
fn test_multiple_picker_configurations() {
let configs: Vec<_> = (0..5)
.map(|_| SCContentSharingPickerConfiguration::new())
.collect();
for (i, config) in configs.iter().enumerate() {
assert!(
!config.as_ptr().is_null(),
"Config {i} should have valid pointer"
);
}
println!("✅ Multiple configurations created");
}
#[test]
fn test_picker_configuration_drop() {
{
let _config = SCContentSharingPickerConfiguration::new();
println!("Configuration created in scope");
}
println!("✅ Configuration dropped successfully");
}
#[test]
fn test_empty_modes_array() {
let mut config = SCContentSharingPickerConfiguration::new();
config.set_allowed_picker_modes(&[]);
println!("✅ Empty modes array handled");
}
#[test]
fn test_picker_mode_equality() {
let mode1 = SCContentSharingPickerMode::SingleWindow;
let mode2 = SCContentSharingPickerMode::SingleWindow;
let mode3 = SCContentSharingPickerMode::MultipleWindows;
assert_eq!(mode1, mode2, "Same modes should be equal");
assert_ne!(mode1, mode3, "Different modes should not be equal");
println!("✅ Picker mode equality works");
}
#[test]
fn test_picker_mode_hash() {
use std::collections::HashSet;
let mut modes = HashSet::new();
modes.insert(SCContentSharingPickerMode::SingleWindow);
modes.insert(SCContentSharingPickerMode::MultipleWindows);
modes.insert(SCContentSharingPickerMode::SingleWindow);
assert_eq!(modes.len(), 2, "Should have 2 unique modes");
println!("✅ Picker modes can be hashed");
}
#[test]
fn test_picker_mode_clone() {
let mode1 = SCContentSharingPickerMode::SingleWindow;
let mode2 = mode1;
assert_eq!(mode1, mode2, "Cloned modes should be equal");
println!("✅ Picker modes can be cloned");
}
#[test]
fn test_picker_mode_debug() {
let modes = vec![
SCContentSharingPickerMode::SingleWindow,
SCContentSharingPickerMode::MultipleWindows,
SCContentSharingPickerMode::SingleDisplay,
SCContentSharingPickerMode::SingleApplication,
SCContentSharingPickerMode::MultipleApplications,
];
for mode in modes {
let debug_str = format!("{mode:?}");
assert!(!debug_str.is_empty(), "Debug string should not be empty");
println!("Mode: {debug_str}");
}
println!("✅ Picker modes have debug formatting");
}