Skip to content

Commit

Permalink
Fix accesskit_windows tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DataTriny committed Oct 25, 2023
1 parent 51d4ac4 commit a347d5d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion platforms/windows/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ features = [

[dev-dependencies]
scopeguard = "1.1.0"
winit = { version = "0.29", default-features = false, features = ["rwh_05"] }
winit = { version = "0.29", default-features = false, features = ["rwh_06"] }
24 changes: 13 additions & 11 deletions platforms/windows/src/tests/subclassed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ use accesskit::{
TreeUpdate,
};
use windows::Win32::{Foundation::*, UI::Accessibility::*};
use winit::{event_loop::EventLoopBuilder, window::WindowBuilder};
use winit::{platform::macos::WindowExtMacOS, window::rwh_05::HasRawWindowHandle, window::Window};
use winit::{
event_loop::EventLoopBuilder,
raw_window_handle::{HasWindowHandle, RawWindowHandle},
window::WindowBuilder,
};

use crate::SubclassingAdapter;

Expand Down Expand Up @@ -62,19 +65,18 @@ fn has_native_uia() {
use winit::platform::windows::EventLoopBuilderExtWindows;
// This test is simple enough that we know it's fine to run entirely
// on one thread, so we don't need a full multithreaded test harness.
let event_loop = EventLoopBuilder::<()>::new().any_thread(true).build();
let event_loop = EventLoopBuilder::<()>::new()
.with_any_thread(true)
.build()
.unwrap();
let window = WindowBuilder::new()
.with_title(WINDOW_TITLE)
.build(&event_loop)
.unwrap();
let hwnd = HWND(match window.raw_window_handle() {
winit::window::raw_window_handle::RawWindowHandle::Win32(handle) => handle.hwnd as isize,
// TODO(Vrixyz): not sure if we can do something with that ?
// winit::window::raw_window_handle::RawWindowHandle::WinRt(handle) => handle.core_window,
unsupported_window_handle => panic!(
"macos should not have that raw window handle type: {:?}",
unsupported_window_handle
),
let hwnd = HWND(match window.window_handle().unwrap().as_raw() {
RawWindowHandle::Win32(handle) => handle.hwnd.get(),
RawWindowHandle::WinRt(_) => unimplemented!(),
_ => unreachable!(),
});
assert!(!unsafe { UiaHasServerSideProvider(hwnd) }.as_bool());
let adapter = SubclassingAdapter::new(hwnd, get_initial_state, Box::new(NullActionHandler {}));
Expand Down

0 comments on commit a347d5d

Please sign in to comment.