tests: Add a library defining the file format for Ruffle test input.
I intend to share this code across both Ruffle and FlashTAS (another project that allows running input tests on Flash Player), hence why it's a separate library from Ruffle's tests crate.
This commit is contained in:
parent
aed5c85edb
commit
ac86dee3a6
|
@ -2987,6 +2987,13 @@ dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ruffle-input-format"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruffle_core"
|
name = "ruffle_core"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
|
@ -16,6 +16,7 @@ members = [
|
||||||
"render/webgl",
|
"render/webgl",
|
||||||
|
|
||||||
"tests",
|
"tests",
|
||||||
|
"tests/input-format",
|
||||||
]
|
]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
[package]
|
||||||
|
name = "ruffle-input-format"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
serde = { version = "1.0.136", features = ["derive"] }
|
|
@ -0,0 +1,40 @@
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
/// Position of a mouse cursor on the screen.
|
||||||
|
///
|
||||||
|
/// Mouse cursor positions are sized relative to the Flash stage's dimensions,
|
||||||
|
/// regardless of the native window's size or pixel density. For example, a
|
||||||
|
/// (640x480) stage movie on a 2x display (on platforms that report physical
|
||||||
|
/// pixels) or at 2x the size will see mouse clicks at its bottom right corner
|
||||||
|
/// on (1280x960), relative to the window. That coordinate needs to be scaled
|
||||||
|
/// down to match the desired stage.
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
pub struct MousePosition(f64, f64);
|
||||||
|
|
||||||
|
/// Which mouse button is being pressed or released.
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
pub enum MouseButton {
|
||||||
|
Left,
|
||||||
|
Middle,
|
||||||
|
Right,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// All automated event types supported by FlashTAS.
|
||||||
|
///
|
||||||
|
/// A FlashTAS input file consists of a string of `AutomatedEvent`s which are
|
||||||
|
/// played back by FlashTAS.
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
pub enum AutomatedEvent {
|
||||||
|
/// End the current frame's input and wait for the next frame before
|
||||||
|
/// continuing to inject input.
|
||||||
|
Wait,
|
||||||
|
|
||||||
|
/// Move the mouse to a new cursor position.
|
||||||
|
MouseMove(MousePosition),
|
||||||
|
|
||||||
|
/// Click a mouse button.
|
||||||
|
MouseDown(MousePosition, MouseButton),
|
||||||
|
|
||||||
|
/// Release a mouse button.
|
||||||
|
MouseUp(MousePosition, MouseButton),
|
||||||
|
}
|
Loading…
Reference in New Issue