1 | #![allow (deprecated)]slint::slint!{#[include_path=r#"/input/slint/tests/driver/driverlib/../../cases/issues/../../../examples/printerdemo/ui/images/"# ] |
2 | #[include_path=r#"/input/slint/tests/driver/driverlib/../../cases/issues"# ] |
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 | property <image> img1: @image-url("cat.jpg" ); |
10 | property <image> img2: @image-url("../images/cat.jpg" ); |
11 | } |
12 | |
13 | /* |
14 | ```rust |
15 | let instance = TestCase::new().unwrap(); |
16 | |
17 | use slint::private_unstable_api::re_exports::{ImageInner, ImageCacheKey}; |
18 | |
19 | let img1 = instance.get_img1(); |
20 | let img2 = instance.get_img2(); |
21 | let img1_inner: &ImageInner = (&img1).into(); |
22 | let img2_inner: &ImageInner = (&img2).into(); |
23 | |
24 | match (img1_inner, img2_inner) { |
25 | (ImageInner::EmbeddedImage { cache_key: ImageCacheKey::Path(img1_path), .. }, ImageInner::EmbeddedImage { cache_key: ImageCacheKey::Path(img2_path), .. }) => { |
26 | assert_eq!(img1_path, img2_path) |
27 | }, |
28 | (ImageInner::EmbeddedImage { cache_key: ImageCacheKey::EmbeddedData(img1_addr), .. }, ImageInner::EmbeddedImage { cache_key: ImageCacheKey::EmbeddedData(img2_addr), .. }) => { |
29 | assert_eq!(img1_addr, img2_addr) |
30 | }, |
31 | _ => todo!("adjust this test to new image comparison"), |
32 | } |
33 | ``` |
34 | */ |
35 | } |
36 | |
37 | #[test ] fn t_0() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> { |
38 | use i_slint_backend_testing as slint_testing; |
39 | slint_testing::init(); |
40 | let instance = TestCase::new().unwrap(); |
41 | |
42 | use slint::private_unstable_api::re_exports::{ImageInner, ImageCacheKey}; |
43 | |
44 | let img1 = instance.get_img1(); |
45 | let img2 = instance.get_img2(); |
46 | let img1_inner: &ImageInner = (&img1).into(); |
47 | let img2_inner: &ImageInner = (&img2).into(); |
48 | |
49 | match (img1_inner, img2_inner) { |
50 | (ImageInner::EmbeddedImage { cache_key: ImageCacheKey::Path(img1_path: &SharedString), .. }, ImageInner::EmbeddedImage { cache_key: ImageCacheKey::Path(img2_path: &SharedString), .. }) => { |
51 | assert_eq!(img1_path, img2_path) |
52 | }, |
53 | (ImageInner::EmbeddedImage { cache_key: ImageCacheKey::EmbeddedData(img1_addr: &usize), .. }, ImageInner::EmbeddedImage { cache_key: ImageCacheKey::EmbeddedData(img2_addr: &usize), .. }) => { |
54 | assert_eq!(img1_addr, img2_addr) |
55 | }, |
56 | _ => todo!("adjust this test to new image comparison" ), |
57 | } |
58 | Ok(()) |
59 | } |