feat: finishing of M0
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
mod app;
|
||||
mod platform;
|
||||
pub mod app;
|
||||
pub mod platform;
|
||||
|
||||
pub use app::BdsApp;
|
||||
|
||||
@@ -4,6 +4,10 @@ use muda::{Menu, MenuEvent, MenuItem, PredefinedMenuItem, Submenu};
|
||||
use crate::app::Message;
|
||||
|
||||
/// Build the native menu bar with standard application menus.
|
||||
///
|
||||
/// On macOS, also calls `init_for_nsapp()` to register the menu with AppKit.
|
||||
/// This requires an active NSApplication, so it will silently fail in
|
||||
/// test contexts without one (muda returns an error that we discard).
|
||||
pub fn build_menu_bar() -> Menu {
|
||||
let menu = Menu::new();
|
||||
|
||||
|
||||
39
crates/bds-ui/tests/app_smoke.rs
Normal file
39
crates/bds-ui/tests/app_smoke.rs
Normal file
@@ -0,0 +1,39 @@
|
||||
//! App launch smoke tests.
|
||||
//!
|
||||
//! M0 validation: verifies that the core UI types can be constructed
|
||||
//! and that the message routing works at the type level.
|
||||
//!
|
||||
//! NOTE: muda::Menu on macOS requires the actual main thread (not just
|
||||
//! single-threaded test mode). Menu construction and BdsApp::new() cannot
|
||||
//! be tested via `cargo test`. The full smoke test is launching the binary:
|
||||
//! cargo run -p bds-ui
|
||||
|
||||
use bds_ui::app::Message;
|
||||
|
||||
// ── Smoke: Message enum is well-formed ──
|
||||
|
||||
#[test]
|
||||
fn message_variants_constructable() {
|
||||
let _noop = Message::Noop;
|
||||
let _menu = Message::MenuEvent(muda::MenuId::new("test"));
|
||||
// Verify Debug trait works
|
||||
assert!(format!("{:?}", Message::Noop).contains("Noop"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn message_clone_works() {
|
||||
let msg = Message::MenuEvent(muda::MenuId::new("file-open"));
|
||||
let cloned = msg.clone();
|
||||
assert!(format!("{cloned:?}").contains("MenuEvent"));
|
||||
}
|
||||
|
||||
// ── Smoke: BdsApp type is accessible from integration tests ──
|
||||
|
||||
#[test]
|
||||
fn bds_app_type_is_public() {
|
||||
// This test verifies the public API surface exists.
|
||||
// BdsApp, Message, platform::menu are all reachable.
|
||||
fn _assert_types() {
|
||||
let _: fn() -> (bds_ui::BdsApp, iced::Task<Message>) = bds_ui::BdsApp::new;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user