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
5import { ListView } from "std-widgets.slint";
6
7TestCase := Window {
8 width: 400px;
9 height: 540px;
10
11 property <string> value;
12
13 listview := ListView {
14 for data in [
15 { text: "Blue", color: #0000ff, bg: #eeeeee},
16 { text: "Red", color: #ff0000, bg: #eeeeee},
17 { text: "Green", color: #00ff00, bg: #eeeeee},
18 { text: "Yellow", color: #ffff00, bg: #222222 },
19 { text: "Black", color: #000000, bg: #eeeeee },
20 { text: "White", color: #ffffff, bg: #222222 },
21 { text: "Magenta", color: #ff00ff, bg: #eeeeee },
22 { text: "Cyan", color: #00ffff, bg: #222222 },
23 ] : delegate := Rectangle {
24 background: @linear-gradient(90deg, data.bg,data.bg.brighter(0.5));
25 HorizontalLayout {
26 text_Name := Text {
27 height: 100px;
28 text: data.text;
29 color: data.color;
30 font_size: 20px ;
31 }
32 }
33 TouchArea { clicked => { value = data.text; } }
34 }
35 }
36}
37
38/*
39```cpp
40auto handle = TestCase::create();
41const TestCase &instance = *handle;
42slint_testing::send_mouse_click(&instance, 5., 205.);
43assert_eq(instance.get_value(), "Green");
44```
45
46```rust
47let instance = TestCase::new().unwrap();
48slint_testing::send_mouse_click(&instance, 5., 205.);
49assert_eq!(instance.get_value(), "Green");
50```
51
52```js
53var instance = new slint.TestCase();
54slintlib.private_api.send_mouse_click(instance, 5., 205.);
55assert.equal(instance.value, "Green");
56```
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 slint_testing::send_mouse_click(&instance, x:5., y:205.);
66 assert_eq!(instance.get_value(), "Green");
67 Ok(())
68}