1 | #![allow (deprecated)]slint::slint!{#[include_path=r#"/input/slint/tests/driver/driverlib/../../cases/models"# ] |
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 | |
6 | SubComponent := Rectangle { |
7 | property <[int]> m; |
8 | HorizontalLayout { |
9 | for foo in m: Rectangle { |
10 | if foo < 100 : TouchArea { |
11 | clicked => { foo += 8; } |
12 | } |
13 | } |
14 | } |
15 | } |
16 | |
17 | TestCase := Rectangle { |
18 | width: 100px; |
19 | height: 100px; |
20 | property <[int]> mod; |
21 | SubComponent { |
22 | m: mod; |
23 | } |
24 | } |
25 | |
26 | /* |
27 | ```rust |
28 | use slint::Model; |
29 | let instance = TestCase::new().unwrap(); |
30 | |
31 | let the_model = std::rc::Rc::new(slint::VecModel::<i32>::from(vec![1, 2, 3])); |
32 | instance.set_mod(the_model.clone().into()); |
33 | slint_testing::send_mouse_click(&instance, 50., 50.); |
34 | assert_eq!(the_model.row_data(1).unwrap() , 2+8); |
35 | ``` |
36 | |
37 | ```cpp |
38 | auto handle = TestCase::create(); |
39 | const TestCase &instance = *handle; |
40 | std::vector<int> array { 1 , 2 , 3 }; |
41 | auto the_model = std::make_shared<slint::VectorModel<int>>(std::move(array)); |
42 | instance.set_mod(the_model); |
43 | |
44 | slint_testing::send_mouse_click(&instance, 50., 50.); |
45 | assert_eq(*the_model->row_data(1) , 2+8); |
46 | ``` |
47 | |
48 | |
49 | ```js |
50 | var instance = new slint.TestCase({}); |
51 | instance.mod = [1, 2, 3]; |
52 | slintlib.private_api.send_mouse_click(instance, 50., 50.); |
53 | assert.equal(instance.mod.rowData(1), 2+8); |
54 | ``` |
55 | |
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 | use slint::Model; |
64 | let instance = TestCase::new().unwrap(); |
65 | |
66 | let the_model: Rc> = std::rc::Rc::new(slint::VecModel::<i32>::from(vec![1, 2, 3])); |
67 | instance.set_mod(the_model.clone().into()); |
68 | slint_testing::send_mouse_click(&instance, x:50., y:50.); |
69 | assert_eq!(the_model.row_data(1).unwrap() , 2+8); |
70 | Ok(()) |
71 | } |