From 6d7ce3ceb9b52bad71e656502b4463cd074adf45 Mon Sep 17 00:00:00 2001 From: Amr Bashir Date: Mon, 15 Apr 2024 10:55:57 +0200 Subject: [PATCH] fix(bench): update bench tests to latest wry window handle changes (#1219) --- bench/tests/src/cpu_intensive.rs | 22 +++++++++++++++++++++- bench/tests/src/custom_protocol.rs | 22 +++++++++++++++++++++- bench/tests/src/hello_world.rs | 26 ++++++++++++++++++++++---- 3 files changed, 64 insertions(+), 6 deletions(-) diff --git a/bench/tests/src/cpu_intensive.rs b/bench/tests/src/cpu_intensive.rs index 183523aec..6ddc79d9b 100644 --- a/bench/tests/src/cpu_intensive.rs +++ b/bench/tests/src/cpu_intensive.rs @@ -24,7 +24,27 @@ fn main() -> wry::Result<()> { exit(0); } }; - let _webview = WebViewBuilder::new(&window) + #[cfg(any( + target_os = "windows", + target_os = "macos", + target_os = "ios", + target_os = "android" + ))] + let builder = WebViewBuilder::new(&window); + + #[cfg(not(any( + target_os = "windows", + target_os = "macos", + target_os = "ios", + target_os = "android" + )))] + let builder = { + use tao::platform::unix::WindowExtUnix; + use wry::WebViewBuilderExtUnix; + let vbox = window.default_vbox().unwrap(); + WebViewBuilder::new_gtk(vbox) + }; + let _webview = builder .with_custom_protocol("wrybench".into(), move |request| { let path = request.uri().to_string(); let requested_asset_path = path.strip_prefix("wrybench://localhost").unwrap(); diff --git a/bench/tests/src/custom_protocol.rs b/bench/tests/src/custom_protocol.rs index 0d7f8fbc2..b7c96db28 100644 --- a/bench/tests/src/custom_protocol.rs +++ b/bench/tests/src/custom_protocol.rs @@ -48,7 +48,27 @@ fn main() -> wry::Result<()> { exit(0); } }; - let _webview = WebViewBuilder::new(&window) + #[cfg(any( + target_os = "windows", + target_os = "macos", + target_os = "ios", + target_os = "android" + ))] + let builder = WebViewBuilder::new(&window); + + #[cfg(not(any( + target_os = "windows", + target_os = "macos", + target_os = "ios", + target_os = "android" + )))] + let builder = { + use tao::platform::unix::WindowExtUnix; + use wry::WebViewBuilderExtUnix; + let vbox = window.default_vbox().unwrap(); + WebViewBuilder::new_gtk(vbox) + }; + let _webview = builder .with_ipc_handler(handler) .with_custom_protocol("wrybench".into(), move |_request| { Response::builder() diff --git a/bench/tests/src/hello_world.rs b/bench/tests/src/hello_world.rs index 1aeca1a3e..030faabf9 100644 --- a/bench/tests/src/hello_world.rs +++ b/bench/tests/src/hello_world.rs @@ -35,10 +35,28 @@ fn main() -> wry::Result<()> { exit(0); } }; - let _webview = WebViewBuilder::new(&window) - .with_url(url) - .with_ipc_handler(handler) - .build()?; + + #[cfg(any( + target_os = "windows", + target_os = "macos", + target_os = "ios", + target_os = "android" + ))] + let builder = WebViewBuilder::new(&window); + + #[cfg(not(any( + target_os = "windows", + target_os = "macos", + target_os = "ios", + target_os = "android" + )))] + let builder = { + use tao::platform::unix::WindowExtUnix; + use wry::WebViewBuilderExtUnix; + let vbox = window.default_vbox().unwrap(); + WebViewBuilder::new_gtk(vbox) + }; + let _webview = builder.with_url(url).with_ipc_handler(handler).build()?; event_loop.run(move |event, _, control_flow| { *control_flow = ControlFlow::Wait;