1 | #![allow (deprecated)]slint::slint!{#[style="fluent" #] |
2 | #[include_path=r#"/input/slint/tests/driver/driverlib/../../cases/widgets"# ] |
3 | // Copyright © SixtyFPS GmbH <info@slint.dev> |
4 | // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.1 OR LicenseRef-Slint-commercial |
5 | |
6 | import { StandardTableView } from "std-widgets.slint" ; |
7 | |
8 | TestCase := Rectangle { |
9 | callback set-current-row(int); |
10 | |
11 | out property <int> row-count: list.rows.length; |
12 | out property <int> callback-current-row: -1; |
13 | |
14 | in-out property<[[StandardListViewItem]]> rows: [ |
15 | [{ text: "Item 1" }, { text: "Description" } ], |
16 | [{ text: "Item 1" }, { text: "Description" }], |
17 | [{ text: "Item 1" }, { text: "Description" }], |
18 | ]; |
19 | in-out property <int> current-row <=> list.current-row; |
20 | |
21 | list := StandardTableView { |
22 | rows: root.rows; |
23 | |
24 | columns: [ |
25 | { title: "Items" }, |
26 | { title: "Descriptions" }, |
27 | ]; |
28 | |
29 | current-row-changed(index) => { |
30 | root.callback-current-row = index; |
31 | } |
32 | } |
33 | |
34 | set-current-row(index) => { |
35 | list.set-current-row(index); |
36 | } |
37 | } |
38 | |
39 | /* |
40 | |
41 | ```rust |
42 | let instance = TestCase::new().unwrap(); |
43 | assert_eq!(instance.get_row_count(), 3); |
44 | assert_eq!(instance.get_current_row(), -1); |
45 | |
46 | assert_eq!(instance.get_callback_current_row(), -1); |
47 | instance.invoke_set_current_row(1); |
48 | assert_eq!(instance.get_callback_current_row(), 1); |
49 | assert_eq!(instance.get_current_row(), 1); |
50 | ``` |
51 | */} |
52 | |
53 | #[test ] fn t_0() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> { |
54 | use i_slint_backend_testing as slint_testing; |
55 | slint_testing::init(); |
56 | let instance = TestCase::new().unwrap(); |
57 | assert_eq!(instance.get_row_count(), 3); |
58 | assert_eq!(instance.get_current_row(), -1); |
59 | |
60 | assert_eq!(instance.get_callback_current_row(), -1); |
61 | instance.invoke_set_current_row(1); |
62 | assert_eq!(instance.get_callback_current_row(), 1); |
63 | assert_eq!(instance.get_current_row(), 1); |
64 | Ok(()) |
65 | } |