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 | import { ListView } from "std-widgets.slint" ; |
6 | |
7 | MyListItem := Rectangle { |
8 | callback clicked <=> ta.clicked; |
9 | property <string> string; |
10 | |
11 | height: 100px; |
12 | |
13 | Text { |
14 | text: string; |
15 | } |
16 | |
17 | ta := TouchArea { } |
18 | } |
19 | |
20 | TestCase := Window { |
21 | width: 300px; |
22 | height: 500px; |
23 | |
24 | property <string> value; |
25 | |
26 | HorizontalLayout { |
27 | lv := ListView { |
28 | for string in [ "Blue" , "Red" , "Green" , "Yellow" , "Black" , "White" , "Magenta" , "Cyan" ] : my := MyListItem { |
29 | string: string; |
30 | clicked => { value = string; } |
31 | } |
32 | } |
33 | } |
34 | property <int> viewport-height: lv.viewport-height / 1px; |
35 | } |
36 | |
37 | /* |
38 | ```cpp |
39 | auto handle = TestCase::create(); |
40 | const TestCase &instance = *handle; |
41 | slint_testing::send_mouse_click(&instance, 5., 205.); |
42 | assert_eq(instance.get_value(), "Green"); |
43 | assert_eq(instance.get_viewport_height(), 800); |
44 | ``` |
45 | |
46 | ```rust |
47 | let instance = TestCase::new().unwrap(); |
48 | slint_testing::send_mouse_click(&instance, 5., 205.); |
49 | assert_eq!(instance.get_value(), "Green"); |
50 | assert_eq!(instance.get_viewport_height(), 800); |
51 | ``` |
52 | |
53 | ```js |
54 | var instance = new slint.TestCase(); |
55 | slintlib.private_api.send_mouse_click(instance, 5., 205.); |
56 | assert.equal(instance.value, "Green"); |
57 | assert.equal(instance.viewport_height, 800); |
58 | ``` |
59 | |
60 | */ |
61 | } |
62 | |
63 | #[test ] fn t_0() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> { |
64 | use i_slint_backend_testing as slint_testing; |
65 | slint_testing::init(); |
66 | let instance = TestCase::new().unwrap(); |
67 | slint_testing::send_mouse_click(&instance, x:5., y:205.); |
68 | assert_eq!(instance.get_value(), "Green" ); |
69 | assert_eq!(instance.get_viewport_height(), 800); |
70 | Ok(()) |
71 | } |