1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//! Test utilities for Astrelis engine.
//!
//! This crate provides testing infrastructure for the Astrelis game engine,
//! including mock GPU contexts and render trait abstractions.
//!
//! # Overview
//!
//! The main components are:
//!
//! - [`RenderContext`] - Trait abstracting GPU operations
//! - `MockRenderContext` - Mock implementation for testing (requires `mock` feature)
//! - GPU wrapper types (`GpuBuffer`, `GpuTexture`, etc.) - Can be real or mock
//!
//! # Example
//!
//! ```rust
//! # #[cfg(feature = "mock")]
//! # {
//! use astrelis_test_utils::{MockRenderContext, RenderContext};
//! use wgpu::*;
//!
//! // Create a mock context for testing
//! let mock = MockRenderContext::new();
//!
//! // Use it like a real GPU context
//! let buffer = mock.create_buffer(&BufferDescriptor {
//! label: Some("test_buffer"),
//! size: 1024,
//! usage: BufferUsages::VERTEX,
//! mapped_at_creation: false,
//! });
//!
//! // Verify operations in tests
//! assert_eq!(mock.count_buffer_creates(), 1);
//! assert!(buffer.is_mock());
//! # }
//! ```
//!
//! # Design Philosophy
//!
//! This crate follows several key design principles:
//!
//! ## 1. No Lifetimes
//!
//! All GPU wrapper types are owned and use reference counting internally.
//! This eliminates lifetime parameters from propagating through the codebase.
//!
//! ## 2. Interior Mutability
//!
//! Mock implementations use `Mutex` for interior mutability, allowing `&self`
//! methods to record calls.
//!
//! ## 3. Object Safety
//!
//! The `RenderContext` trait is object-safe (`dyn RenderContext`), allowing
//! for polymorphic usage with both real and mock contexts.
// Re-export main types at crate root
pub use *;
pub use *;
pub use *;