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 enum Foo { bli, bla, blu } |
6 | |
7 | // (override the builtin 'InputType') |
8 | export enum InputType { Xxx, Yyy, Zzz } |
9 | |
10 | export enum With-dash { hallo, hello-world, halloWorld} |
11 | |
12 | export component TestCase { |
13 | in-out property<Foo> foo: Foo.bla; |
14 | in-out property<Foo> default; |
15 | |
16 | in-out property<InputType> input-type: InputType.Xxx; |
17 | |
18 | out property <bool> test: foo == Foo.bla && default == Foo.bli && input-type == InputType.Xxx; |
19 | |
20 | in property <With-dash> dash: halloWorld; |
21 | } |
22 | |
23 | /* |
24 | ```rust |
25 | let instance = TestCase::new().unwrap(); |
26 | |
27 | assert_eq!(instance.get_foo(), Foo::Bla); |
28 | assert!(instance.get_test()); |
29 | instance.set_foo(Foo::Blu); |
30 | assert!(!instance.get_test()); |
31 | |
32 | assert_eq!(instance.get_dash(), With_dash::HalloWorld); |
33 | instance.set_dash(With_dash::Hallo); |
34 | instance.set_dash(With_dash::HelloWorld); |
35 | |
36 | ``` |
37 | |
38 | ```cpp |
39 | auto handle = TestCase::create(); |
40 | const TestCase &instance = *handle; |
41 | |
42 | assert(instance.get_foo() == Foo::Bla); |
43 | assert(instance.get_test()); |
44 | instance.set_foo(Foo::Blu); |
45 | assert(!instance.get_test()); |
46 | |
47 | assert(instance.get_dash() == With_dash::HalloWorld); |
48 | instance.set_dash(With_dash::Hallo); |
49 | instance.set_dash(With_dash::HelloWorld); |
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 | |
60 | assert_eq!(instance.get_foo(), Foo::Bla); |
61 | assert!(instance.get_test()); |
62 | instance.set_foo(Foo::Blu); |
63 | assert!(!instance.get_test()); |
64 | |
65 | assert_eq!(instance.get_dash(), With_dash::HalloWorld); |
66 | instance.set_dash(With_dash::Hallo); |
67 | instance.set_dash(With_dash::HelloWorld); |
68 | |
69 | Ok(()) |
70 | } |