Skip to content

Commit

Permalink
fix(bench): fix benchmark cannot be built after 783b142 (#1072)
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysd authored Nov 12, 2023
1 parent d57f94e commit 9529b44
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 30 deletions.
1 change: 1 addition & 0 deletions bench/tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ edition = "2018"
[dependencies]
wry = { path = "../../" }
serde = { version = "1.0", features = [ "derive" ] }
tao = { git = "https://github.com/tauri-apps/tao", default-features = false, features = ["rwh_05"] }

[[bin]]
name = "bench_hello_world"
Expand Down
17 changes: 8 additions & 9 deletions bench/tests/src/cpu_intensive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,25 @@
use std::process::exit;

fn main() -> wry::Result<()> {
use tao::{
event::{Event, WindowEvent},
event_loop::{ControlFlow, EventLoop},
window::WindowBuilder,
};
use wry::{
application::{
event::{Event, WindowEvent},
event_loop::{ControlFlow, EventLoop},
window::{Window, WindowBuilder},
},
http::{header::CONTENT_TYPE, Response},
webview::WebViewBuilder,
WebViewBuilder,
};

let event_loop = EventLoop::new();
let window = WindowBuilder::new().build(&event_loop).unwrap();

let handler = |_window: &Window, req: String| {
let handler = |req: String| {
if &req == "process-complete" {
exit(0);
}
};
let _webview = WebViewBuilder::new(window)
.unwrap()
let _webview = WebViewBuilder::new(&window)
.with_custom_protocol("wrybench".into(), move |request| {
let path = request.uri().to_string();
let requested_asset_path = path.strip_prefix("wrybench://localhost").unwrap();
Expand Down
19 changes: 9 additions & 10 deletions bench/tests/src/custom_protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,25 @@ struct MessageParameters {
}

fn main() -> wry::Result<()> {
use tao::{
event::{Event, WindowEvent},
event_loop::{ControlFlow, EventLoop},
window::WindowBuilder,
};
use wry::{
application::{
event::{Event, WindowEvent},
event_loop::{ControlFlow, EventLoop},
window::{Window, WindowBuilder},
},
http::{header::CONTENT_TYPE, Response},
webview::WebViewBuilder,
WebViewBuilder,
};

let event_loop = EventLoop::new();
let window = WindowBuilder::new().build(&event_loop).unwrap();

let handler = |_window: &Window, req: String| {
let handler = |req: String| {
if &req == "dom-loaded" {
exit(0);
}
};
let _webview = WebViewBuilder::new(window)
.unwrap()
let _webview = WebViewBuilder::new(&window)
.with_ipc_handler(handler)
.with_custom_protocol("wrybench".into(), move |_request| {
Response::builder()
Expand All @@ -69,5 +68,5 @@ fn main() -> wry::Result<()> {
} => *control_flow = ControlFlow::Exit,
_ => {}
}
});
})
}
19 changes: 8 additions & 11 deletions bench/tests/src/hello_world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@ struct MessageParameters {
}

fn main() -> wry::Result<()> {
use wry::{
application::{
event::{Event, WindowEvent},
event_loop::{ControlFlow, EventLoop},
window::{Window, WindowBuilder},
},
webview::WebViewBuilder,
use tao::{
event::{Event, WindowEvent},
event_loop::{ControlFlow, EventLoop},
window::WindowBuilder,
};
use wry::WebViewBuilder;

let event_loop = EventLoop::new();
let window = WindowBuilder::new().build(&event_loop).unwrap();
Expand All @@ -31,13 +29,12 @@ fn main() -> wry::Result<()> {
</script>
"#;

let handler = |_window: &Window, req: String| {
let handler = |req: String| {
if &req == "dom-loaded" {
exit(0);
}
};
let _webview = WebViewBuilder::new(window)
.unwrap()
let _webview = WebViewBuilder::new(&window)
.with_url(url)?
.with_ipc_handler(handler)
.build()?;
Expand All @@ -52,5 +49,5 @@ fn main() -> wry::Result<()> {
} => *control_flow = ControlFlow::Exit,
_ => {}
}
});
})
}

0 comments on commit 9529b44

Please sign in to comment.