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
5export component TestCase {
6 width: 300px;
7 height: 300px;
8
9 popup := PopupWindow {
10 x: 100px;
11 y: 10px;
12 width: 100px;
13 height: parent.height - 20px;
14 Rectangle { background: blue; }
15 TouchArea {
16 y: 0px; x: 0px;
17 height: 50px;
18 width: 50px;
19 mouse-cursor: not-allowed;
20 }
21 }
22
23 TouchArea {
24 mouse-cursor: help;
25 x: 0px;
26 width: 150px;
27 clicked => {
28 popup.show()
29 }
30
31 }
32
33}
34/*
35
36```rust
37use slint::{platform::WindowEvent, LogicalPosition};
38use slint::private_unstable_api::re_exports::MouseCursor;
39
40let instance = TestCase::new().unwrap();
41assert_eq!(slint_testing::access_testing_window(instance.window(), |window| window.mouse_cursor.get()), MouseCursor::Default);
42
43instance.window().dispatch_event(WindowEvent::PointerMoved { position: LogicalPosition::new(35.0, 35.0) });
44assert_eq!(slint_testing::access_testing_window(instance.window(), |window| window.mouse_cursor.get()), MouseCursor::Help);
45slint_testing::send_mouse_click(&instance, 35., 35.);
46assert_eq!(slint_testing::access_testing_window(instance.window(), |window| window.mouse_cursor.get()), MouseCursor::Default);
47
48instance.window().dispatch_event(WindowEvent::PointerMoved { position: LogicalPosition::new(135.0, 35.0) });
49assert_eq!(slint_testing::access_testing_window(instance.window(), |window| window.mouse_cursor.get()), MouseCursor::NotAllowed);
50
51instance.window().dispatch_event(WindowEvent::PointerMoved { position: LogicalPosition::new(35.0, 35.0) });
52assert_eq!(slint_testing::access_testing_window(instance.window(), |window| window.mouse_cursor.get()), MouseCursor::Default);
53
54// Close the popup
55
56slint_testing::send_mouse_click(&instance, 135., 35.);
57// FIXME: it takes two events to get that correctly
58// assert_eq!(slint_testing::access_testing_window(instance.window(), |window| window.mouse_cursor.get()), MouseCursor::Help);
59instance.window().dispatch_event(WindowEvent::PointerMoved { position: LogicalPosition::new(135.0, 35.0) });
60assert_eq!(slint_testing::access_testing_window(instance.window(), |window| window.mouse_cursor.get()), MouseCursor::Help);
61```
62
63*/
64}
65
66#[test] fn t_0() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> {
67 use i_slint_backend_testing as slint_testing;
68 slint_testing::init();
69 use slint::{platform::WindowEvent, LogicalPosition};
70 use slint::private_unstable_api::re_exports::MouseCursor;
71
72 let instance = TestCase::new().unwrap();
73 assert_eq!(slint_testing::access_testing_window(instance.window(), |window| window.mouse_cursor.get()), MouseCursor::Default);
74
75 instance.window().dispatch_event(WindowEvent::PointerMoved { position: LogicalPosition::new(35.0, 35.0) });
76 assert_eq!(slint_testing::access_testing_window(instance.window(), |window| window.mouse_cursor.get()), MouseCursor::Help);
77 slint_testing::send_mouse_click(&instance, 35., 35.);
78 assert_eq!(slint_testing::access_testing_window(instance.window(), |window| window.mouse_cursor.get()), MouseCursor::Default);
79
80 instance.window().dispatch_event(WindowEvent::PointerMoved { position: LogicalPosition::new(135.0, 35.0) });
81 assert_eq!(slint_testing::access_testing_window(instance.window(), |window| window.mouse_cursor.get()), MouseCursor::NotAllowed);
82
83 instance.window().dispatch_event(WindowEvent::PointerMoved { position: LogicalPosition::new(35.0, 35.0) });
84 assert_eq!(slint_testing::access_testing_window(instance.window(), |window| window.mouse_cursor.get()), MouseCursor::Default);
85
86 // Close the popup
87
88 slint_testing::send_mouse_click(&instance, 135., 35.);
89 // FIXME: it takes two events to get that correctly
90 // assert_eq!(slint_testing::access_testing_window(instance.window(), |window| window.mouse_cursor.get()), MouseCursor::Help);
91 instance.window().dispatch_event(WindowEvent::PointerMoved { position: LogicalPosition::new(135.0, 35.0) });
92 assert_eq!(slint_testing::access_testing_window(instance.window(), |window| window.mouse_cursor.get()), MouseCursor::Help);
93 Ok(())
94}