tests: Use new socket API
This commit is contained in:
parent
d7b6e588d0
commit
1b765e2a45
|
@ -37,7 +37,7 @@ toml = "0.7.4"
|
|||
libtest-mimic = "0.6.0"
|
||||
walkdir = "2.3.2"
|
||||
anyhow = "1.0"
|
||||
async-io = "1.13.0"
|
||||
async-channel = "1.9.0"
|
||||
|
||||
[[test]]
|
||||
name = "tests"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::util::runner::TestLogBackend;
|
||||
use async_io::Timer;
|
||||
use async_channel::Receiver;
|
||||
use ruffle_core::backend::log::LogBackend;
|
||||
use ruffle_core::backend::navigator::{
|
||||
fetch_path, resolve_url_with_relative_base_path, ErrorResponse, NavigationMethod,
|
||||
|
@ -10,7 +10,7 @@ use ruffle_core::loader::Error;
|
|||
use ruffle_core::socket::{ConnectionState, SocketAction, SocketHandle};
|
||||
use ruffle_socket_format::SocketEvent;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::mpsc::{Receiver, Sender, TryRecvError};
|
||||
use std::sync::mpsc::Sender;
|
||||
use std::time::Duration;
|
||||
use url::{ParseError, Url};
|
||||
|
||||
|
@ -132,11 +132,7 @@ impl NavigatorBackend for TestNavigatorBackend {
|
|||
},
|
||||
SocketEvent::WaitForDisconnect => {
|
||||
loop {
|
||||
match receiver.try_recv() {
|
||||
Err(TryRecvError::Empty) => {
|
||||
//NOTE: We need to yield to executor.
|
||||
Timer::after(Duration::from_micros(1)).await;
|
||||
}
|
||||
match receiver.recv().await {
|
||||
Err(_) => break,
|
||||
Ok(_) => panic!("Expected client to disconnect, data was sent instead"),
|
||||
}
|
||||
|
@ -144,7 +140,7 @@ impl NavigatorBackend for TestNavigatorBackend {
|
|||
},
|
||||
SocketEvent::Receive { expected } => {
|
||||
loop {
|
||||
match receiver.try_recv() {
|
||||
match receiver.recv().await {
|
||||
Ok(val) => {
|
||||
if expected != val {
|
||||
panic!("Received data did not match expected data\nExpected: {:?}\nActual: {:?}", expected, val);
|
||||
|
@ -152,10 +148,6 @@ impl NavigatorBackend for TestNavigatorBackend {
|
|||
|
||||
break;
|
||||
}
|
||||
Err(TryRecvError::Empty) => {
|
||||
//NOTE: We need to yield to executor.
|
||||
Timer::after(Duration::from_micros(1)).await;
|
||||
}
|
||||
Err(_) => panic!("Expected client to send data, but connection was closed instead"),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue