use astrelis_render::GraphicsContext;
use std::sync::Arc;
#[test]
#[ignore] fn test_context_creation_sync() {
let result = GraphicsContext::new_owned_sync();
match result {
Ok(ctx) => {
assert_eq!(Arc::strong_count(&ctx), 1);
assert!(!ctx.device().limits().max_texture_dimension_2d == 0);
}
Err(e) => {
println!("GPU not available: {:?}", e);
}
}
}
#[test]
#[ignore] fn test_context_arc_cloning() {
let result = GraphicsContext::new_owned_sync();
if let Ok(ctx) = result {
let ctx2 = ctx.clone();
assert_eq!(Arc::strong_count(&ctx), 2);
assert_eq!(Arc::strong_count(&ctx2), 2);
assert_eq!(
ctx.device().limits().max_texture_dimension_2d,
ctx2.device().limits().max_texture_dimension_2d
);
drop(ctx2);
assert_eq!(Arc::strong_count(&ctx), 1);
}
}
#[test]
#[ignore] fn test_context_cleanup() {
let result = GraphicsContext::new_owned_sync();
if let Ok(ctx) = result {
let weak = Arc::downgrade(&ctx);
assert!(weak.upgrade().is_some());
drop(ctx);
assert!(weak.upgrade().is_none());
}
}
#[test]
fn test_graphics_error_display() {
use astrelis_render::GraphicsError;
let err = GraphicsError::NoAdapter;
let display = format!("{:?}", err);
assert!(display.contains("NoAdapter"));
}