1 | #![allow (deprecated)]slint::slint!{#[include_path=r#"/input/slint/tests/driver/driverlib/../../cases/elements/../../../examples/printerdemo/ui/images/"# ] |
2 | #[include_path=r#"/input/slint/tests/driver/driverlib/../../cases/elements"# ] |
3 | // Copyright © SixtyFPS GmbH <info@slint.dev> |
4 | // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.1 OR LicenseRef-Slint-commercial |
5 | |
6 | //include_path: ../../../examples/printerdemo/ui/images/ |
7 | |
8 | TestCase := Rectangle { |
9 | img := Image { |
10 | source: @image-url("cat.jpg" ); |
11 | } |
12 | |
13 | img2 := Image { |
14 | source: @image-url("cat.jpg" ); |
15 | source-clip-x: 20; |
16 | } |
17 | |
18 | img3 := Image { |
19 | source: @image-url("image.slint" ); |
20 | } |
21 | |
22 | out property <image> with-border: @image-url("dog.jpg" , nine-slice(12 13 14 15)); |
23 | |
24 | property <length> img_width: img.width; |
25 | property <length> img_height: img.height; |
26 | property <bool> test: img2.source-clip-height * 1px == img2.height && img2.source-clip-width * 1px == img2.width && |
27 | img2.width/1px == img2.source.width - 20 && img3.source.width == 0 && img3.source.height == 0; |
28 | } |
29 | |
30 | /* |
31 | ```cpp |
32 | auto handle = TestCase::create(); |
33 | const TestCase &instance = *handle; |
34 | |
35 | assert_eq(instance.get_img_width(), 320.); |
36 | assert_eq(instance.get_img_height(), 480.); |
37 | assert(instance.get_test()); |
38 | ``` |
39 | |
40 | |
41 | ```rust |
42 | let instance = TestCase::new().unwrap(); |
43 | |
44 | assert_eq!(instance.get_img_width(), 320.); |
45 | assert_eq!(instance.get_img_height(), 480.); |
46 | assert!(instance.get_test()); |
47 | ``` |
48 | |
49 | ```js |
50 | var instance = new slint.TestCase(); |
51 | |
52 | |
53 | assert.equal(instance.img_width, 320); |
54 | assert.equal(instance.img_height, 480); |
55 | assert(instance.test); |
56 | ``` |
57 | */ |
58 | } |
59 | |
60 | #[test ] fn t_0() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> { |
61 | use i_slint_backend_testing as slint_testing; |
62 | slint_testing::init(); |
63 | let instance = TestCase::new().unwrap(); |
64 | |
65 | assert_eq!(instance.get_img_width(), 320.); |
66 | assert_eq!(instance.get_img_height(), 480.); |
67 | assert!(instance.get_test()); |
68 | Ok(()) |
69 | } |