slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
17.11k stars 578 forks source link

UI/UX testing #464

Open ogoffart opened 3 years ago

ogoffart commented 3 years ago

We should make a way to record the input events to enable to make UX testing. With that we could make it easier to write automated UI testing. And also offer ways to analyses how tester user are using the interface and gather data.

ogoffart commented 10 months ago

Related topic to make easier to do UI testing could be done with the accessibility API.

Tests could look like:

#[test]
fn click_button_increase_value() { 
  // Set the slint platform to a thread-safe equivalent of the testing backend.
  init_test_backend();
  // Create gui with callback connections (Same as the real app) 
  let handle = setup_ui(); 
  let button_under_test /* : slint::testing::AccessibleWidgetHanbdle */
         = slint::testing::match_accessible_widget_from_text(handle, "Increase value").unwrap();
  button_under_test.action(Action::Click).unwrap();
  assert_eq!(handle.get_counter(), 2);
}