64 lines
2.6 KiB
Rust
64 lines
2.6 KiB
Rust
// file: crates/apps/game-snake-poc-wasm/unit_tests/runtime.rs
|
|
// version: 3
|
|
|
|
#[test]
|
|
fn direction_is_queued_without_advancing_simulation() {
|
|
let mut game = crate::SnakeWasmGame::new();
|
|
let before_x = game.rectangle_x(1);
|
|
let before_y = game.rectangle_y(1);
|
|
game.up();
|
|
assert_eq!(game.rectangle_x(1), before_x);
|
|
assert_eq!(game.rectangle_y(1), before_y);
|
|
game.tick();
|
|
assert_eq!(game.rectangle_x(1), before_x);
|
|
assert!(game.rectangle_y(1) < before_y);
|
|
}
|
|
|
|
#[test]
|
|
fn scene_and_status_are_exposed_for_canvas_host() {
|
|
let game = crate::SnakeWasmGame::new();
|
|
assert_eq!(game.score(), 0);
|
|
assert_eq!(game.length(), 3);
|
|
assert_eq!(game.rectangle_count(), 4);
|
|
assert!(game.rectangle_width(0) > 0.0);
|
|
assert!(game.rectangle_height(0) > 0.0);
|
|
assert_eq!(game.rectangle_x(99), -1.0);
|
|
assert_eq!(game.rectangle_y(99), -1.0);
|
|
}
|
|
|
|
#[test]
|
|
fn browser_runtime_provenance_preserves_static_and_observed_dimensions() {
|
|
let mut game = crate::SnakeWasmGame::new();
|
|
assert_eq!(game.provenance_platform_family(), "web");
|
|
assert_eq!(game.provenance_execution_model(), "wasm");
|
|
assert_eq!(game.provenance_runtime_host(), "browser");
|
|
assert_eq!(game.provenance_device_class(), "unknown");
|
|
assert_eq!(game.provenance_input_profile(), "unknown");
|
|
assert!(game.configure_runtime_provenance("web", "browser", "phone", "touch"));
|
|
assert_eq!(game.provenance_device_class(), "phone");
|
|
assert_eq!(game.provenance_input_profile(), "touch");
|
|
assert_eq!(game.provenance_platform_family(), "web");
|
|
assert_eq!(game.provenance_execution_model(), "wasm");
|
|
assert_eq!(game.provenance_runtime_host(), "browser");
|
|
}
|
|
|
|
#[test]
|
|
fn invalid_runtime_provenance_labels_are_rejected_without_mutation() {
|
|
let mut game = crate::SnakeWasmGame::new();
|
|
assert!(game.configure_runtime_provenance("web", "browser", "desktop", "keyboard-mouse"));
|
|
assert!(!game.configure_runtime_provenance("console", "spaceship", "console", "telepathy"));
|
|
assert_eq!(game.provenance_device_class(), "desktop");
|
|
assert_eq!(game.provenance_input_profile(), "keyboard-mouse");
|
|
}
|
|
|
|
#[test]
|
|
fn tauri_android_runtime_provenance_is_supported_by_the_shared_adapter() {
|
|
let mut game = crate::SnakeWasmGame::new();
|
|
assert!(game.configure_runtime_provenance("android", "tauri-webview", "phone", "touch"));
|
|
assert_eq!(game.provenance_platform_family(), "android");
|
|
assert_eq!(game.provenance_runtime_host(), "tauri-webview");
|
|
assert_eq!(game.provenance_execution_model(), "wasm");
|
|
assert_eq!(game.provenance_device_class(), "phone");
|
|
assert_eq!(game.provenance_input_profile(), "touch");
|
|
}
|