| 1 | // Copyright © SixtyFPS GmbH <info@slint.dev> |
| 2 | // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0 |
| 3 | |
| 4 | // Test the propagation of maximum and minimum size through nested grid layouts |
| 5 | |
| 6 | Btn := Rectangle { |
| 7 | property <string> text; |
| 8 | |
| 9 | t := Text { |
| 10 | text: root.text; |
| 11 | width: 100%; height: 100%; |
| 12 | } |
| 13 | |
| 14 | accessible-label: text; |
| 15 | accessible-role: button; |
| 16 | } |
| 17 | |
| 18 | Cb := Rectangle { |
| 19 | property <string> text; |
| 20 | accessible-label: text; |
| 21 | t := Text { } |
| 22 | accessible-description <=> t.text; |
| 23 | accessible-role: checkbox; |
| 24 | accessible-checked: true; |
| 25 | } |
| 26 | |
| 27 | component ComboBox inherits Rectangle { |
| 28 | accessible-role: combobox; |
| 29 | accessible-label: "mycombo" ; |
| 30 | Rectangle { |
| 31 | accessible-role: text; |
| 32 | accessible-label: "innerlabel" ; |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | TestCase := Rectangle { |
| 37 | width: 300phx; |
| 38 | height: 300phx; |
| 39 | |
| 40 | vl := VerticalLayout { |
| 41 | b1 := Btn { |
| 42 | text: "plus" ; |
| 43 | } |
| 44 | |
| 45 | txt := Text { |
| 46 | text: "automatic text value" ; |
| 47 | } |
| 48 | |
| 49 | |
| 50 | b2 := Btn { |
| 51 | text : "minus" ; |
| 52 | } |
| 53 | |
| 54 | cb := Cb { text: "hello" ; } |
| 55 | |
| 56 | ComboBox {} |
| 57 | } |
| 58 | |
| 59 | for t in ["abc" ] : Text { text: t; accessible-description: t; } |
| 60 | |
| 61 | property<AccessibleRole> materialized_b1_role: b1.accessible_role; |
| 62 | property<string> materialized_b2_label: b2.accessible-label; |
| 63 | property<string> materialized_vl_label: vl.accessible-label; |
| 64 | property<AccessibleRole> materialized_vl_role: vl.accessible-role; |
| 65 | property<AccessibleRole> materialized_txt_role: txt.accessible-role; |
| 66 | property<string> materialized_txt_label: txt.accessible-label; |
| 67 | |
| 68 | property <bool> test: |
| 69 | materialized_b1_role == AccessibleRole.button && materialized_b2_label == "minus" |
| 70 | && materialized_vl_label == "" && materialized_vl_role == AccessibleRole.none |
| 71 | && materialized_txt_label == "automatic text value" && materialized_txt_role == AccessibleRole.text |
| 72 | && cb.accessible-checked && !b1.accessible-checked; |
| 73 | } |
| 74 | |
| 75 | |
| 76 | /* |
| 77 | |
| 78 | ```cpp |
| 79 | auto handle = TestCase::create(); |
| 80 | const TestCase &instance = *handle; |
| 81 | assert(instance.get_test()); |
| 82 | ``` |
| 83 | |
| 84 | |
| 85 | ```rust |
| 86 | let instance = TestCase::new().unwrap(); |
| 87 | assert!(instance.get_test()); |
| 88 | |
| 89 | assert_eq!(slint_testing::ElementHandle::find_by_accessible_label(&instance, "mycombo").collect::<Vec<_>>().len(), 1); |
| 90 | assert_eq!(slint_testing::ElementHandle::find_by_accessible_label(&instance, "innerlabel").collect::<Vec<_>>().len(), 1); |
| 91 | ``` |
| 92 | |
| 93 | ```js |
| 94 | var instance = new slint.TestCase(); |
| 95 | assert(instance.test); |
| 96 | ``` |
| 97 | |
| 98 | */ |
| 99 | |