22 lines
749 B
Rust
22 lines
749 B
Rust
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
use molotov_core::graphics::surface::GraphicsSurface;
|
|
use molotov_core::graphics::types::WindowFormat;
|
|
|
|
#[test]
|
|
fn test_surface_lock_and_unlock_post() {
|
|
let mut surface = GraphicsSurface::new(800, 600, WindowFormat::Rgba8888);
|
|
assert_eq!(surface.width(), 800);
|
|
assert_eq!(surface.height(), 600);
|
|
|
|
let mut buffer = std::mem::MaybeUninit::uninit();
|
|
let lock_res = unsafe { surface.lock(buffer.as_mut_ptr(), std::ptr::null_mut()) };
|
|
assert_eq!(lock_res, 0);
|
|
|
|
let buf = unsafe { buffer.assume_init() };
|
|
assert_eq!(buf.width, 800);
|
|
assert_eq!(buf.height, 600);
|
|
assert!(!buf.bits.is_null());
|
|
|
|
let post_res = surface.unlock_and_post();
|
|
assert_eq!(post_res, 0);
|
|
}
|