mirror of
https://github.com/emilk/egui.git
synced 2026-06-26 22:53:14 -04:00
Create custom egui_kittest::Node (#7138)
This adds a custom Node struct with proper support for egui types (`Key`, `Modifiers`, `egui::Event`, `Rect`) instead of needing to use the kittest / accesskit types. I also changed the `click` function to do a proper mouse move / mouse down instead of the accesskit click. Also added `accesskit_click` to trigger the accesskit event. This resulted in some changed snapshots, since the elements are now hovered. Also renamed `press_key` to `key_press` for consistency with `key_down/key_up`. Also removed the Deref to the AccessKit Node, to make it clearer when to expect egui and when to expect accesskit types. * Closes #5705 * [x] I have followed the instructions in the PR template
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
use egui::load::SizedTexture;
|
||||
use egui::{
|
||||
include_image, Align, AtomExt as _, AtomLayout, Button, Color32, ColorImage, Direction,
|
||||
DragValue, Event, Grid, IntoAtoms as _, Layout, PointerButton, Pos2, Response, Slider, Stroke,
|
||||
DragValue, Event, Grid, IntoAtoms as _, Layout, PointerButton, Response, Slider, Stroke,
|
||||
StrokeKind, TextWrapMode, TextureHandle, TextureOptions, Ui, UiBuilder, Vec2, Widget as _,
|
||||
};
|
||||
use egui_kittest::kittest::{by, Node, Queryable as _};
|
||||
use egui_kittest::{Harness, SnapshotResult, SnapshotResults};
|
||||
use egui_kittest::kittest::{by, Queryable as _};
|
||||
use egui_kittest::{Harness, Node, SnapshotResult, SnapshotResults};
|
||||
|
||||
#[test]
|
||||
fn widget_tests() {
|
||||
@@ -278,14 +278,10 @@ impl<'a> VisualTests<'a> {
|
||||
});
|
||||
self.add("pressed", |harness| {
|
||||
harness.get_next().hover();
|
||||
let rect = harness.get_next().bounding_box().unwrap();
|
||||
let pos = Pos2::new(
|
||||
((rect.x0 + rect.x1) / 2.0) as f32,
|
||||
((rect.y0 + rect.y1) / 2.0) as f32,
|
||||
);
|
||||
let rect = harness.get_next().rect();
|
||||
harness.input_mut().events.push(Event::PointerButton {
|
||||
button: PointerButton::Primary,
|
||||
pos,
|
||||
pos: rect.center(),
|
||||
pressed: true,
|
||||
modifiers: Default::default(),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user