1// Copyright © SixtyFPS GmbH <info@slint.dev>
2// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
3
4export global Data {
5 in-out property <int> counter;
6}
7
8struct Test { blink: bool}
9
10export component Row {
11 in property <Test> prop;
12
13 Timer {
14 interval: 100ms;
15 running: prop.blink;
16 triggered => {
17 Data.counter += 1;
18 }
19 }
20}
21
22export component TestCase inherits Window {
23 in property <[Test]> rows: [{ blink: true }];
24
25 VerticalLayout {
26 for row in rows: Row {
27 prop: row;
28 }
29 }
30}
31/*
32
33```rust
34let instance = TestCase::new().unwrap();
35slint_testing::send_mouse_click(&instance, 10., 16.);
36assert_eq!(instance.global::<Data<'_>>().get_counter(), 0);
37slint_testing::mock_elapsed_time(101);
38assert_eq!(instance.global::<Data<'_>>().get_counter(), 1);
39```
40
41```cpp
42auto handle = TestCase::create();
43const TestCase &instance = *handle;
44slint_testing::send_mouse_click(&instance, 10., 16.);
45assert_eq(instance.global<Data>().get_counter(), 0);
46slint_testing::mock_elapsed_time(101);
47assert_eq(instance.global<Data>().get_counter(), 1);
48```
49
50```js
51var instance = new slint.TestCase({});
52slintlib.private_api.send_mouse_click(instance, 10., 16.);
53assert.equal(instance.Data.counter, 0);
54slintlib.private_api.mock_elapsed_time(101);
55assert.equal(instance.Data.counter, 1);
56```
57
58
59*/