#[cfg(test)] #[cfg(feature = "hifb")] mod tests { use himpp::{ hifb::{FrameBuffer, PixelFormat}, mpi::hdmi::{HdmiCore, HdmiId, HdmiPortBuilder}, mpi::sys::SysManager, mpi::types::{VideoInterface, VideoStandard}, mpi::vb::{VbConfigBuilder, VbManager, VbRemapMode}, mpi::vo::{VoDev, VoPubAttrBuilder}, }; use std::sync::Arc; #[test] fn test_framebuffer() { let vb_conf = VbConfigBuilder::new() .max_pool_count(32) .pool(1920 * 1088 * 4, 3, VbRemapMode::None, "") .pool(1920 * 1088 * 3, 3, VbRemapMode::None, "") .pool(1920 * 1088 * 2, 3, VbRemapMode::None, "") .build(); let vb_mgr = VbManager::new(&vb_conf, &[]); let _sys_mgr = SysManager::with_align(64, Some(vb_mgr)); let vo_attr = VoPubAttrBuilder::new() .with_bg_color(0x0000ffff) .with_video_interface(VideoInterface::Hdmi) .with_video_standard(VideoStandard::Hd1080p60) .build(); assert_eq!(vo_attr.bg_color(), 0x0000ffff); assert_eq!(vo_attr.video_interface(), VideoInterface::Hdmi); assert_eq!(vo_attr.video_standard(), VideoStandard::Hd1080p60); let _vo0 = Arc::new(VoDev::new(0, &vo_attr)); let hdmi_core = Arc::new(HdmiCore::new()); let hdmi_port = HdmiPortBuilder::with_dvi_1080p60(HdmiId::Hdmi0, Arc::clone(&hdmi_core)).build(); hdmi_port.start().unwrap(); assert_eq!(Arc::strong_count(&hdmi_core), 2); let mut fb = FrameBuffer::new("/dev/fb0").unwrap(); assert_eq!(fb.set_pixel_format(PixelFormat::Argb8888).is_ok(), true); assert_eq!(fb.set_resolution(1920, 1080).is_ok(), true); assert_eq!(fb.resolution(), (1920, 1080)); assert_eq!(fb.set_num_buffers(2).is_ok(), true); assert_eq!(fb.num_buffers(), 2); assert_eq!(fb.show().is_ok(), true); std::thread::sleep(std::time::Duration::from_secs(5)); assert_eq!(fb.hide().is_ok(), true); drop(fb); drop(hdmi_port); assert_eq!(Arc::strong_count(&hdmi_core), 1); } }