1#![allow(deprecated)]slint::slint!{#[include_path=r#"/input/slint/tests/driver/driverlib/../../cases/layout"#]
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// Test that the x and y property of a Rectangle with opacity are consistant
6
7export component TestCase {
8
9 width: 100px;
10 height: 100px;
11
12
13 r1 := Rectangle {
14 x: 20px;
15 y: 15px;
16 width: 12px;
17 height: 5px;
18 opacity: 0.5;
19 background: red;
20 TouchArea {
21 clicked => {
22 root.clicked = (self.absolute-position.y + self.mouse-y) / 1px;
23 r1.y += 50px;
24 }
25 }
26 }
27
28 in-out property xx <=> r1.x;
29 out property<int> clicked;
30
31 out property <bool> test:
32 r1.x == 20px && r1.y == 15px;
33}
34
35/*
36```cpp
37auto handle = TestCase::create();
38const TestCase &instance = *handle;
39assert(instance.get_test());
40```
41
42
43```rust
44let instance = TestCase::new().unwrap();
45assert!(instance.get_test());
46
47slint_testing::send_mouse_click(&instance, 21., 16.);
48assert_eq!(instance.get_clicked(), 16);
49instance.set_xx(80.);
50slint_testing::send_mouse_click(&instance, 81., 66.);
51assert_eq!(instance.get_clicked(), 66);
52```
53
54```js
55var instance = new slint.TestCase({});
56assert(instance.test);
57```
58*/
59}
60
61#[test] fn t_0() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> {
62 use i_slint_backend_testing as slint_testing;
63 slint_testing::init();
64 let instance = TestCase::new().unwrap();
65 assert!(instance.get_test());
66
67 slint_testing::send_mouse_click(&instance, x:21., y:16.);
68 assert_eq!(instance.get_clicked(), 16);
69 instance.set_xx(80.);
70 slint_testing::send_mouse_click(&instance, x:81., y:66.);
71 assert_eq!(instance.get_clicked(), 66);
72 Ok(())
73}