1 | #![allow (deprecated)]slint::slint!{#[include_path=r#"/input/slint/tests/driver/driverlib/../../cases/bindings"# ] |
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 | OtherComp := Rectangle { |
6 | property t <=> text.text; |
7 | property get_text <=> text.text; |
8 | text := Text { |
9 | text: "to be overridden" ; |
10 | } |
11 | property <int> some_value: 42; |
12 | property some_value_alias <=> some_value; |
13 | } |
14 | |
15 | TestCase := Rectangle { |
16 | |
17 | property <string> text1: "Hello" ; |
18 | property <string> text2: "Blah" ; |
19 | property ti1_text <=> ti1.text_alias; |
20 | property ti2_text <=> ti2.text_alias; |
21 | property text_item_text <=> text_item.text; |
22 | property <string> othercomp_t: "real value" ; |
23 | property othercomp_get_text <=> other_comp.get_text; |
24 | property <int> othercomp_some_value; |
25 | property othercomp_some_value_alias <=> other_comp.some_value_alias; |
26 | property <int> othercomp_some_value_alias2; |
27 | |
28 | ti1 := TextInput { |
29 | property text_alias <=> text; |
30 | text <=> text1; |
31 | } |
32 | |
33 | ti2 := TextInput { |
34 | property text_alias <=> text_alias_indirection; |
35 | property text_alias_indirection <=> text; |
36 | text <=> text_item.text; |
37 | } |
38 | |
39 | text_item := Text { |
40 | text: text2; |
41 | } |
42 | |
43 | Text { |
44 | text <=> text1; |
45 | } |
46 | |
47 | other_comp := OtherComp { |
48 | t <=> root.othercomp_t; |
49 | some_value <=> othercomp_some_value; |
50 | some_value_alias <=> othercomp_some_value_alias2; |
51 | } |
52 | |
53 | callback set_ti1(string); |
54 | set_ti1(a) => { ti1.text = a; } |
55 | callback set_ti2(string); |
56 | set_ti2(a) => { ti2.text = a; } |
57 | } |
58 | |
59 | |
60 | /* |
61 | |
62 | ```rust |
63 | let instance = TestCase::new().unwrap(); |
64 | assert_eq!(instance.get_text1(), slint::SharedString::from("Hello")); |
65 | assert_eq!(instance.get_text2(), slint::SharedString::from("Blah")); |
66 | assert_eq!(instance.get_ti1_text(), slint::SharedString::from("Hello")); |
67 | assert_eq!(instance.get_ti2_text(), slint::SharedString::from("Blah")); |
68 | assert_eq!(instance.get_text_item_text(), slint::SharedString::from("Blah")); |
69 | assert_eq!(instance.get_othercomp_t(), instance.get_othercomp_get_text()); |
70 | assert_eq!(instance.get_othercomp_t(), slint::SharedString::from("real value")); |
71 | assert_eq!(instance.get_othercomp_get_text(), slint::SharedString::from("real value")); |
72 | |
73 | instance.set_text1(slint::SharedString::from("Text1New")); |
74 | instance.set_text2(slint::SharedString::from("Text2New")); |
75 | assert_eq!(instance.get_text1(), slint::SharedString::from("Text1New")); |
76 | assert_eq!(instance.get_text2(), slint::SharedString::from("Text2New")); |
77 | assert_eq!(instance.get_ti1_text(), slint::SharedString::from("Text1New")); |
78 | assert_eq!(instance.get_ti2_text(), slint::SharedString::from("Text2New")); |
79 | assert_eq!(instance.get_text_item_text(), slint::SharedString::from("Text2New")); |
80 | |
81 | instance.invoke_set_ti1(slint::SharedString::from("Hallo")); |
82 | instance.invoke_set_ti2(slint::SharedString::from("Bonjour")); |
83 | assert_eq!(instance.get_text1(), slint::SharedString::from("Hallo")); |
84 | assert_eq!(instance.get_text2(), slint::SharedString::from("Text2New")); |
85 | assert_eq!(instance.get_ti1_text(), slint::SharedString::from("Hallo")); |
86 | assert_eq!(instance.get_ti2_text(), slint::SharedString::from("Bonjour")); |
87 | assert_eq!(instance.get_text_item_text(), slint::SharedString::from("Bonjour")); |
88 | |
89 | assert_eq!(instance.get_othercomp_some_value(), 0); |
90 | assert_eq!(instance.get_othercomp_some_value_alias(), 0); |
91 | assert_eq!(instance.get_othercomp_some_value_alias2(), 0); |
92 | instance.set_othercomp_some_value(88); |
93 | assert_eq!(instance.get_othercomp_some_value(), 88); |
94 | assert_eq!(instance.get_othercomp_some_value_alias(), 88); |
95 | assert_eq!(instance.get_othercomp_some_value_alias2(), 88); |
96 | instance.set_othercomp_some_value_alias(81); |
97 | assert_eq!(instance.get_othercomp_some_value(), 81); |
98 | assert_eq!(instance.get_othercomp_some_value_alias(), 81); |
99 | assert_eq!(instance.get_othercomp_some_value_alias2(), 81); |
100 | instance.set_othercomp_some_value_alias2(1); |
101 | assert_eq!(instance.get_othercomp_some_value(), 1); |
102 | assert_eq!(instance.get_othercomp_some_value_alias(), 1); |
103 | assert_eq!(instance.get_othercomp_some_value_alias2(), 1); |
104 | |
105 | ``` |
106 | |
107 | |
108 | |
109 | ```cpp |
110 | auto handle = TestCase::create(); |
111 | const TestCase &instance = *handle; |
112 | assert_eq(instance.get_text1(), slint::SharedString("Hello")); |
113 | assert_eq(instance.get_text2(), slint::SharedString("Blah")); |
114 | assert_eq(instance.get_ti1_text(), slint::SharedString("Hello")); |
115 | assert_eq(instance.get_ti2_text(), slint::SharedString("Blah")); |
116 | assert_eq(instance.get_text_item_text(), slint::SharedString("Blah")); |
117 | assert_eq(instance.get_othercomp_t(), instance.get_othercomp_get_text()); |
118 | assert_eq(instance.get_othercomp_t(), slint::SharedString("real value")); |
119 | assert_eq(instance.get_othercomp_get_text(), slint::SharedString("real value")); |
120 | |
121 | |
122 | instance.set_text1(slint::SharedString("Text1New")); |
123 | instance.set_text2(slint::SharedString("Text2New")); |
124 | assert_eq(instance.get_text1(), slint::SharedString("Text1New")); |
125 | assert_eq(instance.get_text2(), slint::SharedString("Text2New")); |
126 | assert_eq(instance.get_ti1_text(), slint::SharedString("Text1New")); |
127 | assert_eq(instance.get_ti2_text(), slint::SharedString("Text2New")); |
128 | assert_eq(instance.get_text_item_text(), slint::SharedString("Text2New")); |
129 | |
130 | instance.invoke_set_ti1(slint::SharedString("Hallo")); |
131 | instance.invoke_set_ti2(slint::SharedString("Bonjour")); |
132 | assert_eq(instance.get_text1(), slint::SharedString("Hallo")); |
133 | assert_eq(instance.get_text2(), slint::SharedString("Text2New")); |
134 | assert_eq(instance.get_ti1_text(), slint::SharedString("Hallo")); |
135 | assert_eq(instance.get_ti2_text(), slint::SharedString("Bonjour")); |
136 | assert_eq(instance.get_text_item_text(), slint::SharedString("Bonjour")); |
137 | |
138 | assert_eq(instance.get_othercomp_some_value(), 0); |
139 | assert_eq(instance.get_othercomp_some_value_alias(), 0); |
140 | assert_eq(instance.get_othercomp_some_value_alias2(), 0); |
141 | instance.set_othercomp_some_value(88); |
142 | assert_eq(instance.get_othercomp_some_value(), 88); |
143 | assert_eq(instance.get_othercomp_some_value_alias(), 88); |
144 | assert_eq(instance.get_othercomp_some_value_alias2(), 88); |
145 | instance.set_othercomp_some_value_alias(81); |
146 | assert_eq(instance.get_othercomp_some_value(), 81); |
147 | assert_eq(instance.get_othercomp_some_value_alias(), 81); |
148 | assert_eq(instance.get_othercomp_some_value_alias2(), 81); |
149 | instance.set_othercomp_some_value_alias2(1); |
150 | assert_eq(instance.get_othercomp_some_value(), 1); |
151 | assert_eq(instance.get_othercomp_some_value_alias(), 1); |
152 | assert_eq(instance.get_othercomp_some_value_alias2(), 1); |
153 | ``` |
154 | |
155 | |
156 | ```js |
157 | let instance = new slint.TestCase({}); |
158 | assert.equal(instance.text1, "Hello"); |
159 | assert.equal(instance.text2, "Blah"); |
160 | assert.equal(instance.ti1_text, "Hello"); |
161 | assert.equal(instance.ti2_text, "Blah"); |
162 | assert.equal(instance.text_item_text, "Blah"); |
163 | assert.equal(instance.othercomp_t, instance.othercomp_get_text); |
164 | assert.equal(instance.othercomp_t, "real value"); |
165 | assert.equal(instance.othercomp_get_text, "real value"); |
166 | |
167 | instance.text1 = "Text1New"; |
168 | instance.text2 = "Text2New"; |
169 | assert.equal(instance.text1, "Text1New"); |
170 | assert.equal(instance.text2, "Text2New"); |
171 | assert.equal(instance.ti1_text, "Text1New"); |
172 | assert.equal(instance.ti2_text, "Text2New"); |
173 | assert.equal(instance.text_item_text, "Text2New"); |
174 | |
175 | instance.set_ti1("Hallo"); |
176 | instance.set_ti2("Bonjour"); |
177 | assert.equal(instance.text1, "Hallo"); |
178 | assert.equal(instance.text2, "Text2New"); |
179 | assert.equal(instance.ti1_text, "Hallo"); |
180 | assert.equal(instance.ti2_text, "Bonjour"); |
181 | assert.equal(instance.text_item_text, "Bonjour"); |
182 | |
183 | assert.equal(instance.othercomp_some_value, 0); |
184 | assert.equal(instance.othercomp_some_value_alias, 0); |
185 | assert.equal(instance.othercomp_some_value_alias2, 0); |
186 | instance.othercomp_some_value = 88; |
187 | assert.equal(instance.othercomp_some_value, 88); |
188 | assert.equal(instance.othercomp_some_value_alias, 88); |
189 | assert.equal(instance.othercomp_some_value_alias2, 88); |
190 | instance.othercomp_some_value_alias = 81; |
191 | assert.equal(instance.othercomp_some_value, 81); |
192 | assert.equal(instance.othercomp_some_value_alias, 81); |
193 | assert.equal(instance.othercomp_some_value_alias2, 81); |
194 | instance.othercomp_some_value_alias2 = 1; |
195 | assert.equal(instance.othercomp_some_value, 1); |
196 | assert.equal(instance.othercomp_some_value_alias, 1); |
197 | assert.equal(instance.othercomp_some_value_alias2, 1); |
198 | ``` |
199 | |
200 | */ |
201 | } |
202 | |
203 | #[test ] fn t_0() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> { |
204 | use i_slint_backend_testing as slint_testing; |
205 | slint_testing::init(); |
206 | let instance = TestCase::new().unwrap(); |
207 | assert_eq!(instance.get_text1(), slint::SharedString::from("Hello" )); |
208 | assert_eq!(instance.get_text2(), slint::SharedString::from("Blah" )); |
209 | assert_eq!(instance.get_ti1_text(), slint::SharedString::from("Hello" )); |
210 | assert_eq!(instance.get_ti2_text(), slint::SharedString::from("Blah" )); |
211 | assert_eq!(instance.get_text_item_text(), slint::SharedString::from("Blah" )); |
212 | assert_eq!(instance.get_othercomp_t(), instance.get_othercomp_get_text()); |
213 | assert_eq!(instance.get_othercomp_t(), slint::SharedString::from("real value" )); |
214 | assert_eq!(instance.get_othercomp_get_text(), slint::SharedString::from("real value" )); |
215 | |
216 | instance.set_text1(slint::SharedString::from("Text1New" )); |
217 | instance.set_text2(slint::SharedString::from("Text2New" )); |
218 | assert_eq!(instance.get_text1(), slint::SharedString::from("Text1New" )); |
219 | assert_eq!(instance.get_text2(), slint::SharedString::from("Text2New" )); |
220 | assert_eq!(instance.get_ti1_text(), slint::SharedString::from("Text1New" )); |
221 | assert_eq!(instance.get_ti2_text(), slint::SharedString::from("Text2New" )); |
222 | assert_eq!(instance.get_text_item_text(), slint::SharedString::from("Text2New" )); |
223 | |
224 | instance.invoke_set_ti1(slint::SharedString::from("Hallo" )); |
225 | instance.invoke_set_ti2(slint::SharedString::from("Bonjour" )); |
226 | assert_eq!(instance.get_text1(), slint::SharedString::from("Hallo" )); |
227 | assert_eq!(instance.get_text2(), slint::SharedString::from("Text2New" )); |
228 | assert_eq!(instance.get_ti1_text(), slint::SharedString::from("Hallo" )); |
229 | assert_eq!(instance.get_ti2_text(), slint::SharedString::from("Bonjour" )); |
230 | assert_eq!(instance.get_text_item_text(), slint::SharedString::from("Bonjour" )); |
231 | |
232 | assert_eq!(instance.get_othercomp_some_value(), 0); |
233 | assert_eq!(instance.get_othercomp_some_value_alias(), 0); |
234 | assert_eq!(instance.get_othercomp_some_value_alias2(), 0); |
235 | instance.set_othercomp_some_value(88); |
236 | assert_eq!(instance.get_othercomp_some_value(), 88); |
237 | assert_eq!(instance.get_othercomp_some_value_alias(), 88); |
238 | assert_eq!(instance.get_othercomp_some_value_alias2(), 88); |
239 | instance.set_othercomp_some_value_alias(81); |
240 | assert_eq!(instance.get_othercomp_some_value(), 81); |
241 | assert_eq!(instance.get_othercomp_some_value_alias(), 81); |
242 | assert_eq!(instance.get_othercomp_some_value_alias2(), 81); |
243 | instance.set_othercomp_some_value_alias2(1); |
244 | assert_eq!(instance.get_othercomp_some_value(), 1); |
245 | assert_eq!(instance.get_othercomp_some_value_alias(), 1); |
246 | assert_eq!(instance.get_othercomp_some_value_alias2(), 1); |
247 | |
248 | Ok(()) |
249 | } |