1 | #![allow (deprecated)]slint::slint!{#[include_path=r#"/input/slint/tests/driver/driverlib/../../cases/elements"# ] |
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 | InheritFlickable := Flickable {} |
6 | |
7 | TestCase := Window { |
8 | width: 500phx; |
9 | height: 500phx; |
10 | |
11 | Flickable { |
12 | r1 := Rectangle { |
13 | property<bool> ok: height == root.height && width == root.width; |
14 | } |
15 | } |
16 | |
17 | InheritFlickable { |
18 | width: 123phx; |
19 | viewport_height: 456phx; |
20 | r2 := Rectangle { |
21 | property<bool> ok: height == 456phx && width == 123phx; |
22 | } |
23 | } |
24 | |
25 | f3 := InheritFlickable { |
26 | VerticalLayout { |
27 | spacing: 0phx; |
28 | padding: 0phx; |
29 | r3 := Rectangle { |
30 | property<bool> ok: height == root.height/2 && width == 888phx && f3.viewport_width == 888phx && f3.min-width == 0phx; |
31 | } |
32 | Rectangle { |
33 | min-width: 888phx; |
34 | } |
35 | } |
36 | } |
37 | |
38 | f4 := Flickable { |
39 | HorizontalLayout { |
40 | spacing: 0phx; |
41 | padding: 0phx; |
42 | r4 := Rectangle { |
43 | property<bool> ok: f4.max-height == 6000phx && r4.height == root.height; |
44 | } |
45 | Rectangle { |
46 | max-height: 6000phx; |
47 | } |
48 | } |
49 | } |
50 | |
51 | Flickable { for i in 5: Rectangle {} } |
52 | |
53 | property<bool> all_ok: r1.ok && r2.ok && r3.ok && r4.ok; |
54 | property<bool> test: all_ok; |
55 | } |
56 | |
57 | /* |
58 | ```cpp |
59 | auto handle = TestCase::create(); |
60 | const TestCase &instance = *handle; |
61 | slint_testing::send_mouse_click(&instance, 5., 5.); |
62 | |
63 | assert(instance.get_all_ok()); |
64 | ``` |
65 | |
66 | |
67 | ```rust |
68 | let instance = TestCase::new().unwrap(); |
69 | slint_testing::send_mouse_click(&instance, 5., 5.); |
70 | assert!(instance.get_all_ok()); |
71 | ``` |
72 | |
73 | ```js |
74 | var instance = new slint.TestCase(); |
75 | slintlib.private_api.send_mouse_click(instance, 5., 5.); |
76 | assert(instance.all_ok); |
77 | ``` |
78 | */ |
79 | } |
80 | |
81 | #[test ] fn t_0() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> { |
82 | use i_slint_backend_testing as slint_testing; |
83 | slint_testing::init(); |
84 | let instance = TestCase::new().unwrap(); |
85 | slint_testing::send_mouse_click(&instance, x:5., y:5.); |
86 | assert!(instance.get_all_ok()); |
87 | Ok(()) |
88 | } |