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
5OtherComp := 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
15TestCase := 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
63let instance = TestCase::new().unwrap();
64assert_eq!(instance.get_text1(), slint::SharedString::from("Hello"));
65assert_eq!(instance.get_text2(), slint::SharedString::from("Blah"));
66assert_eq!(instance.get_ti1_text(), slint::SharedString::from("Hello"));
67assert_eq!(instance.get_ti2_text(), slint::SharedString::from("Blah"));
68assert_eq!(instance.get_text_item_text(), slint::SharedString::from("Blah"));
69assert_eq!(instance.get_othercomp_t(), instance.get_othercomp_get_text());
70assert_eq!(instance.get_othercomp_t(), slint::SharedString::from("real value"));
71assert_eq!(instance.get_othercomp_get_text(), slint::SharedString::from("real value"));
72
73instance.set_text1(slint::SharedString::from("Text1New"));
74instance.set_text2(slint::SharedString::from("Text2New"));
75assert_eq!(instance.get_text1(), slint::SharedString::from("Text1New"));
76assert_eq!(instance.get_text2(), slint::SharedString::from("Text2New"));
77assert_eq!(instance.get_ti1_text(), slint::SharedString::from("Text1New"));
78assert_eq!(instance.get_ti2_text(), slint::SharedString::from("Text2New"));
79assert_eq!(instance.get_text_item_text(), slint::SharedString::from("Text2New"));
80
81instance.invoke_set_ti1(slint::SharedString::from("Hallo"));
82instance.invoke_set_ti2(slint::SharedString::from("Bonjour"));
83assert_eq!(instance.get_text1(), slint::SharedString::from("Hallo"));
84assert_eq!(instance.get_text2(), slint::SharedString::from("Text2New"));
85assert_eq!(instance.get_ti1_text(), slint::SharedString::from("Hallo"));
86assert_eq!(instance.get_ti2_text(), slint::SharedString::from("Bonjour"));
87assert_eq!(instance.get_text_item_text(), slint::SharedString::from("Bonjour"));
88
89assert_eq!(instance.get_othercomp_some_value(), 0);
90assert_eq!(instance.get_othercomp_some_value_alias(), 0);
91assert_eq!(instance.get_othercomp_some_value_alias2(), 0);
92instance.set_othercomp_some_value(88);
93assert_eq!(instance.get_othercomp_some_value(), 88);
94assert_eq!(instance.get_othercomp_some_value_alias(), 88);
95assert_eq!(instance.get_othercomp_some_value_alias2(), 88);
96instance.set_othercomp_some_value_alias(81);
97assert_eq!(instance.get_othercomp_some_value(), 81);
98assert_eq!(instance.get_othercomp_some_value_alias(), 81);
99assert_eq!(instance.get_othercomp_some_value_alias2(), 81);
100instance.set_othercomp_some_value_alias2(1);
101assert_eq!(instance.get_othercomp_some_value(), 1);
102assert_eq!(instance.get_othercomp_some_value_alias(), 1);
103assert_eq!(instance.get_othercomp_some_value_alias2(), 1);
104
105```
106
107
108
109```cpp
110auto handle = TestCase::create();
111const TestCase &instance = *handle;
112assert_eq(instance.get_text1(), slint::SharedString("Hello"));
113assert_eq(instance.get_text2(), slint::SharedString("Blah"));
114assert_eq(instance.get_ti1_text(), slint::SharedString("Hello"));
115assert_eq(instance.get_ti2_text(), slint::SharedString("Blah"));
116assert_eq(instance.get_text_item_text(), slint::SharedString("Blah"));
117assert_eq(instance.get_othercomp_t(), instance.get_othercomp_get_text());
118assert_eq(instance.get_othercomp_t(), slint::SharedString("real value"));
119assert_eq(instance.get_othercomp_get_text(), slint::SharedString("real value"));
120
121
122instance.set_text1(slint::SharedString("Text1New"));
123instance.set_text2(slint::SharedString("Text2New"));
124assert_eq(instance.get_text1(), slint::SharedString("Text1New"));
125assert_eq(instance.get_text2(), slint::SharedString("Text2New"));
126assert_eq(instance.get_ti1_text(), slint::SharedString("Text1New"));
127assert_eq(instance.get_ti2_text(), slint::SharedString("Text2New"));
128assert_eq(instance.get_text_item_text(), slint::SharedString("Text2New"));
129
130instance.invoke_set_ti1(slint::SharedString("Hallo"));
131instance.invoke_set_ti2(slint::SharedString("Bonjour"));
132assert_eq(instance.get_text1(), slint::SharedString("Hallo"));
133assert_eq(instance.get_text2(), slint::SharedString("Text2New"));
134assert_eq(instance.get_ti1_text(), slint::SharedString("Hallo"));
135assert_eq(instance.get_ti2_text(), slint::SharedString("Bonjour"));
136assert_eq(instance.get_text_item_text(), slint::SharedString("Bonjour"));
137
138assert_eq(instance.get_othercomp_some_value(), 0);
139assert_eq(instance.get_othercomp_some_value_alias(), 0);
140assert_eq(instance.get_othercomp_some_value_alias2(), 0);
141instance.set_othercomp_some_value(88);
142assert_eq(instance.get_othercomp_some_value(), 88);
143assert_eq(instance.get_othercomp_some_value_alias(), 88);
144assert_eq(instance.get_othercomp_some_value_alias2(), 88);
145instance.set_othercomp_some_value_alias(81);
146assert_eq(instance.get_othercomp_some_value(), 81);
147assert_eq(instance.get_othercomp_some_value_alias(), 81);
148assert_eq(instance.get_othercomp_some_value_alias2(), 81);
149instance.set_othercomp_some_value_alias2(1);
150assert_eq(instance.get_othercomp_some_value(), 1);
151assert_eq(instance.get_othercomp_some_value_alias(), 1);
152assert_eq(instance.get_othercomp_some_value_alias2(), 1);
153```
154
155
156```js
157let instance = new slint.TestCase({});
158assert.equal(instance.text1, "Hello");
159assert.equal(instance.text2, "Blah");
160assert.equal(instance.ti1_text, "Hello");
161assert.equal(instance.ti2_text, "Blah");
162assert.equal(instance.text_item_text, "Blah");
163assert.equal(instance.othercomp_t, instance.othercomp_get_text);
164assert.equal(instance.othercomp_t, "real value");
165assert.equal(instance.othercomp_get_text, "real value");
166
167instance.text1 = "Text1New";
168instance.text2 = "Text2New";
169assert.equal(instance.text1, "Text1New");
170assert.equal(instance.text2, "Text2New");
171assert.equal(instance.ti1_text, "Text1New");
172assert.equal(instance.ti2_text, "Text2New");
173assert.equal(instance.text_item_text, "Text2New");
174
175instance.set_ti1("Hallo");
176instance.set_ti2("Bonjour");
177assert.equal(instance.text1, "Hallo");
178assert.equal(instance.text2, "Text2New");
179assert.equal(instance.ti1_text, "Hallo");
180assert.equal(instance.ti2_text, "Bonjour");
181assert.equal(instance.text_item_text, "Bonjour");
182
183assert.equal(instance.othercomp_some_value, 0);
184assert.equal(instance.othercomp_some_value_alias, 0);
185assert.equal(instance.othercomp_some_value_alias2, 0);
186instance.othercomp_some_value = 88;
187assert.equal(instance.othercomp_some_value, 88);
188assert.equal(instance.othercomp_some_value_alias, 88);
189assert.equal(instance.othercomp_some_value_alias2, 88);
190instance.othercomp_some_value_alias = 81;
191assert.equal(instance.othercomp_some_value, 81);
192assert.equal(instance.othercomp_some_value_alias, 81);
193assert.equal(instance.othercomp_some_value_alias2, 81);
194instance.othercomp_some_value_alias2 = 1;
195assert.equal(instance.othercomp_some_value, 1);
196assert.equal(instance.othercomp_some_value_alias, 1);
197assert.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}