mirror of
https://github.com/slint-ui/slint.git
synced 2025-12-23 09:19:32 +00:00
Widgets tests: Also test C++
This commit is contained in:
parent
8024dcc245
commit
8996948fd1
3 changed files with 15 additions and 14 deletions
|
|
@ -102,10 +102,10 @@ const TestCase &instance = *handle;
|
|||
|
||||
auto label_search = slint::testing::ElementHandle::find_by_accessible_label(handle, "Aaa");
|
||||
assert(label_search.size() == 1);
|
||||
auto aaa = label_search.front();
|
||||
auto aaa = label_search[0];
|
||||
assert_eq(aaa.accessible_label().value(), "Aaa");
|
||||
assert_eq(aaa.accessible_description().value(), "Normal Button");
|
||||
assert_eq(aaa.accessible_value(), std::nullopt);
|
||||
assert_eq(aaa.accessible_description().value(), "Checkable Button");
|
||||
assert(!aaa.accessible_value());
|
||||
assert_eq(aaa.accessible_checked().value(), false);
|
||||
assert_eq(aaa.accessible_checkable().value(), true);
|
||||
aaa.invoke_accessible_default_action();
|
||||
|
|
@ -122,24 +122,25 @@ assert_eq(aaa.accessible_checked().value(), false);
|
|||
assert_eq(instance.get_a_focused(), true);
|
||||
slint_testing::send_keyboard_string_sequence(&instance, "\n");
|
||||
assert_eq(instance.get_clicked(), "aa");
|
||||
assert_eq(aaa.accessible_checked().value(), false);
|
||||
assert_eq(aaa.accessible_checked().value(), true);
|
||||
assert_eq(instance.get_a_focused(), true);
|
||||
|
||||
label_search = slint::testing::ElementHandle::find_by_accessible_label(handle, "Bbb");
|
||||
assert(label_search.size() == 1);
|
||||
auto bbb = label_search.front();
|
||||
auto bbb = label_search[0];
|
||||
assert_eq(bbb.accessible_label().value(), "Bbb");
|
||||
assert_eq(bbb.accessible_description().value(), "Normal Button");
|
||||
assert_eq(bbb.accessible_value(), std::nullopt);
|
||||
assert_eq!(bbb.accessible_checkable().value(), false);
|
||||
assert(!bbb.accessible_value());
|
||||
assert_eq(bbb.accessible_checkable().value(), false);
|
||||
assert_eq(bbb.accessible_checked().value(), false);
|
||||
auto origin = bbb.accessible_origin();
|
||||
auto origin = bbb.absolute_position();
|
||||
auto size = bbb.size();
|
||||
slint_testing::sebd_mouse_click(&instance, origin.x + size.width / 2, origin.y + size.height / 2);
|
||||
slint_testing::send_mouse_click(&instance, origin.x + size.width / 2, origin.y + size.height / 2);
|
||||
assert_eq(instance.get_clicked(), "aab");
|
||||
assert_eq(bbb.accessible_checked().value(), false);
|
||||
assert_eq(instance.get_a_focused(), true);
|
||||
|
||||
|
||||
```
|
||||
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -42,10 +42,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
|
||||
let mut tests_file = BufWriter::new(std::fs::File::create(&tests_file_path)?);
|
||||
|
||||
for testcase in test_driver_lib::collect_test_cases("cases")?.into_iter().filter(|testcase| {
|
||||
// Style testing not supported yet
|
||||
testcase.requested_style.is_none()
|
||||
}) {
|
||||
for testcase in test_driver_lib::collect_test_cases("cases")? {
|
||||
let test_function_name = testcase.identifier();
|
||||
let ignored = testcase.is_ignored("cpp");
|
||||
|
||||
|
|
@ -58,7 +55,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
cppdriver::test(&test_driver_lib::TestCase{{
|
||||
absolute_path: std::path::PathBuf::from(r#"{absolute_path}"#),
|
||||
relative_path: std::path::PathBuf::from(r#"{relative_path}"#),
|
||||
requested_style: None,
|
||||
requested_style: {requested_style},
|
||||
}}).unwrap();
|
||||
}}
|
||||
|
||||
|
|
@ -67,6 +64,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
function_name = test_function_name,
|
||||
absolute_path = testcase.absolute_path.to_string_lossy(),
|
||||
relative_path = testcase.relative_path.to_string_lossy(),
|
||||
requested_style =
|
||||
testcase.requested_style.map_or("None".into(), |style| format!("Some({style:?})")),
|
||||
)?;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ pub fn test(testcase: &test_driver_lib::TestCase) -> Result<(), Box<dyn Error>>
|
|||
let mut compiler_config = CompilerConfiguration::new(output_format.clone());
|
||||
compiler_config.include_paths = include_paths;
|
||||
compiler_config.library_paths = library_paths;
|
||||
compiler_config.style = testcase.requested_style.map(str::to_string);
|
||||
let (root_component, diag, _) =
|
||||
spin_on::spin_on(compile_syntax_node(syntax_node, diag, compiler_config));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue