tests: Move SocketEvent into ruffle_socket_format crate
This commit is contained in:
parent
88626b7212
commit
3e8ee00a67
|
@ -4048,11 +4048,18 @@ dependencies = [
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruffle_socket_mock"
|
name = "ruffle_socket_format"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ruffle_socket_mock"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"ruffle_socket_format",
|
||||||
"tracing",
|
"tracing",
|
||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
]
|
]
|
||||||
|
|
|
@ -25,6 +25,7 @@ members = [
|
||||||
|
|
||||||
"tests",
|
"tests",
|
||||||
"tests/input-format",
|
"tests/input-format",
|
||||||
|
"tests/socket-format",
|
||||||
"tests/socket-mock",
|
"tests/socket-mock",
|
||||||
]
|
]
|
||||||
default-members = ["desktop"]
|
default-members = ["desktop"]
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
[package]
|
||||||
|
name = "ruffle_socket_format"
|
||||||
|
authors.workspace = true
|
||||||
|
edition.workspace = true
|
||||||
|
homepage.workspace = true
|
||||||
|
license.workspace = true
|
||||||
|
repository.workspace = true
|
||||||
|
version.workspace = true
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
serde = { version = "1.0.152", features = ["derive"] }
|
||||||
|
serde_json = "1.0.91"
|
|
@ -0,0 +1,32 @@
|
||||||
|
use std::{io, fs::File, path::Path};
|
||||||
|
|
||||||
|
use serde::{Serialize, Deserialize};
|
||||||
|
use serde_json::from_reader;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
|
#[serde(tag = "type")]
|
||||||
|
pub enum SocketEvent {
|
||||||
|
/// Wait for input data that matches this.
|
||||||
|
Receive {
|
||||||
|
expected: Vec<u8>,
|
||||||
|
},
|
||||||
|
/// Send data to client.
|
||||||
|
Send {
|
||||||
|
payload: Vec<u8>,
|
||||||
|
},
|
||||||
|
/// Expect client to disconnect.
|
||||||
|
WaitForDisconnect,
|
||||||
|
/// Disconnect the client.
|
||||||
|
Disconnect,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl SocketEvent {
|
||||||
|
pub fn from_file<P>(path: P) -> Result<Vec<Self>, io::Error>
|
||||||
|
where
|
||||||
|
P: AsRef<Path>,
|
||||||
|
{
|
||||||
|
let file = File::open(path)?;
|
||||||
|
|
||||||
|
Ok(from_reader(file)?)
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,5 +10,4 @@ version.workspace = true
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tracing = { workspace = true}
|
tracing = { workspace = true}
|
||||||
tracing-subscriber = { workspace = true }
|
tracing-subscriber = { workspace = true }
|
||||||
serde = { version = "1.0.152", features = ["derive"] }
|
ruffle_socket_format = { path = "../socket-format" }
|
||||||
serde_json = "1.0.91"
|
|
|
@ -1,36 +1,7 @@
|
||||||
use std::{net::TcpListener, io::{self, Read, Write}, path::Path, fs::File};
|
use std::{net::TcpListener, io::{Read, Write}};
|
||||||
use serde::{Serialize, Deserialize};
|
use ruffle_socket_format::SocketEvent;
|
||||||
use serde_json::from_reader;
|
|
||||||
use tracing_subscriber::filter::{EnvFilter, LevelFilter};
|
use tracing_subscriber::filter::{EnvFilter, LevelFilter};
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
|
||||||
#[serde(tag = "type")]
|
|
||||||
pub enum SocketEvent {
|
|
||||||
/// Wait for input data that matches this.
|
|
||||||
Receive {
|
|
||||||
expected: Vec<u8>,
|
|
||||||
},
|
|
||||||
/// Send data to client.
|
|
||||||
Send {
|
|
||||||
payload: Vec<u8>,
|
|
||||||
},
|
|
||||||
/// Expect client to disconnect.
|
|
||||||
WaitForDisconnect,
|
|
||||||
/// Disconnect the client.
|
|
||||||
Disconnect,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl SocketEvent {
|
|
||||||
pub fn from_file<P>(path: P) -> Result<Vec<Self>, io::Error>
|
|
||||||
where
|
|
||||||
P: AsRef<Path>,
|
|
||||||
{
|
|
||||||
let file = File::open(path)?;
|
|
||||||
|
|
||||||
Ok(from_reader(file)?)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static POLICY: &'static [u8] = &*b"<?xml version=\"1.0\"?>
|
static POLICY: &'static [u8] = &*b"<?xml version=\"1.0\"?>
|
||||||
<!DOCTYPE cross-domain-policy SYSTEM \"http://www.adobe.com/xml/dtds/cross-domain-policy.dtd\">
|
<!DOCTYPE cross-domain-policy SYSTEM \"http://www.adobe.com/xml/dtds/cross-domain-policy.dtd\">
|
||||||
<cross-domain-policy>
|
<cross-domain-policy>
|
||||||
|
|
Loading…
Reference in New Issue