1#![allow(deprecated)]slint::slint!{#[include_path=r#"/input/slint/tests/driver/driverlib/../../cases"#]
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
5component Item {
6 callback pointer-event <=> touch.pointer-event;
7 touch := TouchArea {}
8}
9
10component Issue3148 {
11 out property <length> result;
12 Item {
13 x: 42px;
14 pointer-event => {
15 debug(self.absolute-position.x - root.absolute-position.x);
16 }
17 init => {
18 result = self.absolute-position.x - root.absolute-position.x
19 }
20 }
21}
22
23export component TestCase {
24 width: 500phx;
25 height: 500phx;
26
27 property <bool> simple-inner-ok: simple-inner.absolute-position.x == 40phx && simple-inner.absolute-position.y == 60phx;
28 Rectangle {
29 x: 10phx;
30 y: 20phx;
31
32 simple-inner := Rectangle {
33 x: 30phx;
34 y: 40phx;
35 }
36 }
37 empty1 := Rectangle {
38 Rectangle {
39 empty2 := Rectangle {
40
41 }
42 }
43 }
44 xxx := Issue3148 { width: 50%; }
45 out property <bool> test: simple-inner-ok && xxx.result == 42px && empty1.absolute-position == empty2.absolute-position;
46 out property <Point> coords <=> simple-inner.absolute-position;
47}
48
49/*
50```rust
51let instance = TestCase::new().unwrap();
52assert!(instance.get_test());
53let pos: slint::LogicalPosition = instance.get_coords();
54assert_eq!(pos.x, 40.);
55assert_eq!(pos.y, 60.);
56```
57
58```cpp
59auto handle = TestCase::create();
60const TestCase &instance = *handle;
61assert(instance.get_test());
62slint::LogicalPosition pos = instance.get_coords();
63assert_eq(pos.x, 40);
64assert_eq(pos.y, 60);
65```
66
67```js
68let instance = new slint.TestCase({});
69assert(instance.test, 1);
70assert.deepEqual(instance.coords, { x: 40, y: 60});
71```
72
73*/
74}
75
76#[test] fn t_0() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> {
77 use i_slint_backend_testing as slint_testing;
78 slint_testing::init();
79 let instance = TestCase::new().unwrap();
80 assert!(instance.get_test());
81 let pos: slint::LogicalPosition = instance.get_coords();
82 assert_eq!(pos.x, 40.);
83 assert_eq!(pos.y, 60.);
84 Ok(())
85}