28 lines
1.1 KiB
Rust
28 lines
1.1 KiB
Rust
// file: crates/engines/engine-v1-sdl/unit_tests/swipe.rs
|
|
// version: 1
|
|
|
|
fn pointer(x: f32, y: f32) -> engine_v1_common::PointerState {
|
|
return engine_v1_common::PointerState::normalized(true, x, y);
|
|
}
|
|
|
|
#[test]
|
|
fn short_gesture_does_not_emit_direction() {
|
|
let input = super::apply_swipe_direction(engine_v1_common::InputState::none(), Some(pointer(0.5, 0.5)), pointer(0.52, 0.51));
|
|
assert!(!input.is_active(engine_v1_common::GameAction::Left));
|
|
assert!(!input.is_active(engine_v1_common::GameAction::Right));
|
|
assert!(!input.is_active(engine_v1_common::GameAction::Up));
|
|
assert!(!input.is_active(engine_v1_common::GameAction::Down));
|
|
}
|
|
|
|
#[test]
|
|
fn horizontal_swipe_uses_dominant_axis() {
|
|
let input = super::apply_swipe_direction(engine_v1_common::InputState::none(), Some(pointer(0.7, 0.5)), pointer(0.2, 0.55));
|
|
assert!(input.is_active(engine_v1_common::GameAction::Left));
|
|
}
|
|
|
|
#[test]
|
|
fn vertical_swipe_uses_dominant_axis() {
|
|
let input = super::apply_swipe_direction(engine_v1_common::InputState::none(), Some(pointer(0.5, 0.8)), pointer(0.55, 0.2));
|
|
assert!(input.is_active(engine_v1_common::GameAction::Up));
|
|
}
|