1// Copyright © SixtyFPS GmbH <info@slint.dev>
2// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.1 OR LicenseRef-Slint-commercial
3
4use ::slint::slint;
5
6#[test]
7fn simple_window() {
8 i_slint_backend_testing::init();
9 slint!(export component X inherits Window{});
10 X::new().unwrap();
11}
12#[test]
13fn empty_stuff() {
14 slint!();
15 slint!(export struct Hei { abcd: bool });
16 slint!(export global G { });
17}
18
19#[test]
20fn test_serialize_deserialize_struct() {
21 i_slint_backend_testing::init();
22 slint! {
23
24 @rust-attr(derive(serde::Serialize, serde::Deserialize))
25 export enum TestEnum {
26 hello, world, xxx
27 }
28
29 @rust-attr(derive(serde::Serialize, serde::Deserialize))
30 export struct TestStruct {
31 enum: TestEnum,
32 foo: int,
33 }
34 export component Test { }
35 }
36 let data = TestStruct { foo: 1, r#enum: TestEnum::World };
37 let serialized: String = serde_json::to_string(&data).unwrap();
38 let deserialized: TestStruct = serde_json::from_str(&serialized).unwrap();
39 assert_eq!(data, deserialized);
40}
41