openpencil/crates/op-host-native/tests/tracing_spans.rs
Kayshen-X 1e0b3cab7a refactor(rust): rename native + desktop hosts to op-host-* crates
Phase 7.3 strangler reorg — rename the native widget host and the
desktop runner crates to the op- prefix. The desktop+native merge was
declined: keeping the library / binary split preserves the mobile-
checkable op-host-native lib (cargo check -p op-host-native on iOS /
Android, relied on by check-jian-boundaries.sh + the CI mobile job),
which a folded-in winit binary would break. A clean separate rename is
purely mechanical and the brief permits it.

- openpencil-shell-native -> op-host-native (lib op_host_native)
- openpencil-desktop -> op-host-desktop crate; the shipped executable
  keeps the stable openpencil-desktop [[bin]] name so release
  artifacts + external CLI integrations are unaffected
- every openpencil_shell_core:: path -> op_editor_ui::
- every openpencil_shell_native:: path -> op_host_native::
- doc-comment / manual-smoke note refs updated
2026-05-16 23:49:58 +08:00

47 lines
1.6 KiB
Rust

//! Spec v19 acceptance #8 / plan v7 Task 2 Step 16c:
//! `tracing` spans must fire at `begin_frame / present / resize /
//! teardown` (and the rest of the frame surface). `tracing-test`
//! captures them at the subscriber level.
mod common;
use common::setup_headless_context;
use tracing_test::traced_test;
#[traced_test]
#[test]
fn frame_lifecycle_spans_emitted() {
let mut ctx = setup_headless_context();
ctx.begin_frame();
ctx.with_frame(|_canvas, _glow| {
// Empty closure body — we still want the `with_frame` span if
// the surface were live; on the inert ctx the closure simply
// doesn't fire (surface is None), so the span entry alone is
// what `tracing-test` records.
});
ctx.present();
ctx.resize(1024, 768).unwrap();
ctx.teardown().unwrap();
// Span name is the function name by default for
// `#[tracing::instrument]` — assert each lifecycle entry shows up
// exactly once.
assert!(logs_contain("begin_frame"), "begin_frame span missing");
assert!(logs_contain("present"), "present span missing");
assert!(logs_contain("resize"), "resize span missing");
assert!(logs_contain("teardown"), "teardown span missing");
}
#[traced_test]
#[test]
fn lifecycle_hook_spans_emitted() {
let mut ctx = setup_headless_context();
ctx.on_pause().unwrap();
ctx.on_resume(None).unwrap();
ctx.on_low_memory();
assert!(logs_contain("on_pause"), "on_pause span missing");
assert!(logs_contain("on_resume"), "on_resume span missing");
assert!(logs_contain("on_low_memory"), "on_low_memory span missing");
}