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 | |
7 | export 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 |
37 | auto handle = TestCase::create(); |
38 | const TestCase &instance = *handle; |
39 | assert(instance.get_test()); |
40 | ``` |
41 | |
42 | |
43 | ```rust |
44 | let instance = TestCase::new().unwrap(); |
45 | assert!(instance.get_test()); |
46 | |
47 | slint_testing::send_mouse_click(&instance, 21., 16.); |
48 | assert_eq!(instance.get_clicked(), 16); |
49 | instance.set_xx(80.); |
50 | slint_testing::send_mouse_click(&instance, 81., 66.); |
51 | assert_eq!(instance.get_clicked(), 66); |
52 | ``` |
53 | |
54 | ```js |
55 | var instance = new slint.TestCase({}); |
56 | assert(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 | } |