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
6SubComponent := 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
17TestCase := Rectangle {
18 width: 100px;
19 height: 100px;
20 property <[int]> mod;
21 SubComponent {
22 m: mod;
23 }
24}
25
26/*
27```rust
28use slint::Model;
29let instance = TestCase::new().unwrap();
30
31let the_model = std::rc::Rc::new(slint::VecModel::<i32>::from(vec![1, 2, 3]));
32instance.set_mod(the_model.clone().into());
33slint_testing::send_mouse_click(&instance, 50., 50.);
34assert_eq!(the_model.row_data(1).unwrap() , 2+8);
35```
36
37```cpp
38auto handle = TestCase::create();
39const TestCase &instance = *handle;
40std::vector<int> array { 1 , 2 , 3 };
41auto the_model = std::make_shared<slint::VectorModel<int>>(std::move(array));
42instance.set_mod(the_model);
43
44slint_testing::send_mouse_click(&instance, 50., 50.);
45assert_eq(*the_model->row_data(1) , 2+8);
46```
47
48
49```js
50var instance = new slint.TestCase({});
51instance.mod = [1, 2, 3];
52slintlib.private_api.send_mouse_click(instance, 50., 50.);
53assert.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}