1 | #![allow (deprecated)]slint::slint!{#[include_path=r#"/input/slint/tests/driver/driverlib/../../cases/types"# ] |
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 | export component TestCase { |
6 | in-out property<string> p1: "hello" ; |
7 | in-out property<string> p2: "fox:🦊" ; |
8 | in-out property<string> p3: "with \"quote \\\"\u{8}" ; |
9 | in-out property<bool> e1: p2 == "fox:🦊" ; |
10 | in-out property<bool> e2: p2 == "fox:🦍" ; |
11 | |
12 | // conversion from float |
13 | in property<float> value: 98.7654321; |
14 | out property <string> converted_value: round(value * 100)/100; |
15 | out property <bool> test: e1 && !e2 && converted_value == "98.77" ; |
16 | } |
17 | |
18 | |
19 | /* |
20 | |
21 | ```cpp |
22 | auto handle = TestCase::create(); |
23 | const TestCase &instance = *handle; |
24 | assert_eq(instance.get_p1(), "hello"); |
25 | assert_eq(instance.get_p2(), "fox:🦊"); |
26 | assert_eq(instance.get_p3(), "with\"quote\\\"\x08"); |
27 | assert(instance.get_e1()); |
28 | assert(!instance.get_e2()); |
29 | assert(instance.get_test()); |
30 | ``` |
31 | |
32 | ```rust |
33 | let instance = TestCase::new().unwrap(); |
34 | assert_eq!(instance.get_p1(), "hello"); |
35 | assert_eq!(instance.get_p2(), "fox:🦊"); |
36 | assert_eq!(instance.get_p3(), "with\"quote\\\"\u{8}"); |
37 | assert!(instance.get_e1()); |
38 | assert!(!instance.get_e2()); |
39 | assert!(instance.get_test()); |
40 | ``` |
41 | |
42 | ```js |
43 | var instance = new slint.TestCase({}); |
44 | assert.equal(instance.p1, "hello"); |
45 | assert.equal(instance.p2, "fox:🦊"); |
46 | assert.equal(instance.p3, "with\"quote\\\"\u0008"); |
47 | assert(instance.e1); |
48 | assert(!instance.e2); |
49 | assert(instance.test); |
50 | ``` |
51 | |
52 | */ |
53 | } |
54 | |
55 | #[test ] fn t_0() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> { |
56 | use i_slint_backend_testing as slint_testing; |
57 | slint_testing::init(); |
58 | let instance = TestCase::new().unwrap(); |
59 | assert_eq!(instance.get_p1(), "hello" ); |
60 | assert_eq!(instance.get_p2(), "fox:🦊" ); |
61 | assert_eq!(instance.get_p3(), "with \"quote \\\"\u{8}" ); |
62 | assert!(instance.get_e1()); |
63 | assert!(!instance.get_e2()); |
64 | assert!(instance.get_test()); |
65 | Ok(()) |
66 | } |