Skip to main content

Module tui

Module tui 

Source
Expand description

TUI Testing Framework (SPEC-024 Section 12 & 13)

This module enforces test-first development for TUI widgets. Tests DEFINE the interface - implementation follows.

§Example: Test-First Interface Definition

use presentar_test::tui::{TuiTestBackend, expect_frame, FrameAssertion};

#[test]
fn test_cpu_exploded_receives_async_updates() {
    let mut backend = TuiTestBackend::new(120, 40);
    let mut app = App::test_instance();

    // Frame 1: Initial render
    app.apply_snapshot(snapshot1);
    backend.render(|buf| ui::draw(&app, buf));
    let freq1 = backend.extract_text_at(50, 5); // CPU frequency

    // Frame 2: After async update
    app.apply_snapshot(snapshot2);
    backend.render(|buf| ui::draw(&app, buf));
    let freq2 = backend.extract_text_at(50, 5);

    // ASSERTION: Data must update
    expect_frame(&backend)
        .field("cpu_freq")
        .changed_between(freq1, freq2);
}

Structs§

AsyncUpdateAssertion
Assertion helper for async data updates. This is the CRITICAL test that defines interface requirements.
BenchmarkHarness
Benchmark harness for running widget benchmarks.
BenchmarkResult
Benchmark result.
DiffEntry
Single difference entry.
FrameAssertion
Fluent frame assertion builder.
PerformanceTargets
Performance targets for validation.
RenderMetrics
Performance metrics collected during rendering.
SnapshotDiff
Difference between two snapshots.
TuiCell
Cell in the TUI buffer.
TuiSnapshot
Snapshot of TUI state for comparison.
TuiTestBackend
In-memory TUI test backend. Renders widgets to a buffer for assertions.

Enums§

SnapshotError
Snapshot error.

Functions§

expect_frame
Start building frame assertions.