nigig-org/crates/apps/nigig-traffic/tests/ui_basic.rs
andodeki ac8f8aa002
Some checks failed
p2p-intel / engine (push) Waiting to run
p2p-intel / notifications (push) Waiting to run
p2p-intel / coverage (push) Waiting to run
p2p-intel / makepad-app (push) Waiting to run
p2p-intel / exchange-tab (push) Waiting to run
Payment domain, storage, platform and UI / isolated-payment-tests (push) Waiting to run
Payment domain, storage, platform and UI / payment-ui-tests (push) Waiting to run
repo hygiene / hygiene (push) Has been cancelled
PDF engine / engine (push) Has been cancelled
PDF engine / makepad-integration (push) Has been cancelled
PDF engine / fuzz (push) Has been cancelled
nigig-build (CAD) / supply-chain (push) Has been cancelled
nigig-build (CAD) / cad-module (push) Has been cancelled
nigig-build (CAD) / full-crate-check (push) Has been cancelled
nigig-build (CAD) / cad-engine-coverage (push) Has been cancelled
nigig-build (CAD) / doc-workspace-coverage (push) Has been cancelled
nigig-build (CAD) / cad-widget-coverage (push) Has been cancelled
traffic / gates (push) Has been cancelled
traffic / nigig-traffic (push) Has been cancelled
traffic / supply-chain (push) Has been cancelled
doc-engine / engine (push) Has been cancelled
doc-engine / coverage (push) Has been cancelled
doc-engine / consumer (push) Has been cancelled
email / gates (push) Has been cancelled
email / email-domain (push) Has been cancelled
email / nigig-email (push) Has been cancelled
email / supply-chain (push) Has been cancelled
nigig-map / test (push) Has been cancelled
sms / gates (push) Has been cancelled
sms / robius-sms (push) Has been cancelled
sms / android (push) Has been cancelled
sms / nigig-sms (push) Has been cancelled
sms / supply-chain (push) Has been cancelled
spreadsheet / engine-coverage (push) Has been cancelled
spreadsheet / ui-controller-coverage (push) Has been cancelled
chore: sync full working tree to gitdab
Whole-tree sync: cad-core/cad-ui split sources, nigig-build
construction_frame migration, pdf port progress, mpesa/pay/uikit/doc
updates, workspace members/profiles/lock, CI workflows and reviews.
See individual file history for details.
2026-09-12 07:15:24 +03:00

55 lines
2 KiB
Rust
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

use nigig_traffic::game_frame::RenderMode;
use nigig_traffic::traffic::TrafficWorld;
#[test]
fn traffic_world_loads_and_ticks() {
let mut world = TrafficWorld::new();
world.load_scenario(0);
let scenario = world.scenario().expect("scenario loaded").clone();
assert!(!scenario.title.is_empty());
// Tick a few frames with no input should stay in Intro then Driving
let input = makepad_game_blocks::DriveInput::default();
for _ in 0..70 {
world.tick(&input);
}
assert!(world.run.tick >= 70);
// Intro books exactly 60 ticks, then the run goes live.
assert_eq!(world.run.phase, nigig_traffic::traffic::Phase::Driving);
}
#[test]
fn traffic_world_navigates_scenarios() {
let mut world = TrafficWorld::new();
world.load_scenario(0);
let first = world.scenario().expect("scenario loaded").id;
world.next();
let second = world.scenario().expect("scenario loaded").id;
assert_ne!(first, second);
world.prev();
assert_eq!(world.scenario().expect("scenario loaded").id, first);
}
#[test]
fn render_mode_labels_are_stable() {
assert_eq!(RenderMode::TopDown.label(), "Top-Down");
assert_eq!(RenderMode::Chase25D.label(), "Chase-Cam (2.5D)");
assert_eq!(RenderMode::Full3D.label(), "Full 3D");
}
#[test]
fn traffic_world_builds_first_scenarios_without_panic() {
// Headless smoke: every scenario must build road geometry and survive a
// tick (no panics in `build_world_for`, id ordering, or `evaluate`
// with no scenario edge cases). The actual GPU frame
// (`window_0_frame_000000.png`) is only written by a real
// `MAKEPAD=headless` binary run, not by this test.
let all = TrafficWorld::all_scenarios();
assert!(all.len() >= 36);
for s in all.iter().take(5) {
let mut world = TrafficWorld::new();
let idx = all.iter().position(|x| x.id == s.id).unwrap();
world.load_scenario(idx);
// One tick to ensure no panic in road building (oriented slab + large ground)
world.tick(&makepad_game_blocks::DriveInput::default());
}
}