1#![allow(deprecated)]slint::slint!{#[include_path=r#"/input/slint/tests/driver/driverlib/../../cases/subcomponents"#]
2// Copyright © SixtyFPS GmbH <info@slint.dev>
3// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.1 OR LicenseRef-Slint-commercial
4
5// Verify that two repeaters (if and for) are placed correctly in the item tree
6// and matched in the dyn_visit closure.
7// The two repeaters ended up being swapped and sub-component's repeater was
8// visited when the Text's child's repeater should have been, resulting in
9// wrong rendering order. This is tested by clicking into the left half and
10// verifying that it did not hit the sub-component's repeater.
11
12component A inherits Rectangle {
13}
14component B inherits A {
15}
16
17
18export component TestCase {
19 width: 300phx;
20 height: 300phx;
21 out property <bool> clicked;
22 B {
23 TouchArea { clicked => {root.clicked = true;} }
24 }
25}
26
27/*
28```rust
29let instance = TestCase::new().unwrap();
30
31assert!(!instance.get_clicked());
32slint_testing::send_mouse_click(&instance, 20., 5.);
33assert!(instance.get_clicked());
34```
35
36```cpp
37auto handle = TestCase::create();
38const TestCase &instance = *handle;
39assert(!instance.get_clicked());
40slint_testing::send_mouse_click(&instance, 20., 5.);
41assert(instance.get_clicked());
42```
43
44
45```js
46var instance = new slint.TestCase({});
47assert(!instance.clicked);
48slintlib.private_api.send_mouse_click(instance, 20., 5.);
49assert(instance.clicked);
50```
51
52
53*/
54}
55
56#[test] fn t_0() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> {
57 use i_slint_backend_testing as slint_testing;
58 slint_testing::init();
59 let instance = TestCase::new().unwrap();
60
61 assert!(!instance.get_clicked());
62 slint_testing::send_mouse_click(&instance, x:20., y:5.);
63 assert!(instance.get_clicked());
64 Ok(())
65}