mirror of
https://github.com/slint-ui/slint.git
synced 2025-09-27 12:29:41 +00:00
Rename test_ellapse_time to mock_elapsed_time
This commit is contained in:
parent
f2166d91a6
commit
37f874a26b
6 changed files with 22 additions and 21 deletions
|
@ -3,7 +3,8 @@
|
||||||
#include "sixtyfps.h"
|
#include "sixtyfps.h"
|
||||||
|
|
||||||
namespace sixtyfps::testing {
|
namespace sixtyfps::testing {
|
||||||
inline void ellapse_time(int64_t time_in_ms) {
|
inline void mock_elapsed_time(int64_t time_in_ms)
|
||||||
internal::sixtyfps_test_ellapse_time(time_in_ms);
|
{
|
||||||
}
|
internal::sixtyfps_mock_elapsed_time(time_in_ms);
|
||||||
|
}
|
||||||
} // namespace sixtyfps
|
} // namespace sixtyfps
|
||||||
|
|
|
@ -306,13 +306,13 @@ declare_types! {
|
||||||
|
|
||||||
register_module!(mut m, {
|
register_module!(mut m, {
|
||||||
m.export_function("load", load)?;
|
m.export_function("load", load)?;
|
||||||
m.export_function("test_ellapse_time", test_ellapse_time)?;
|
m.export_function("mock_elapsed_time", mock_elapsed_time)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
});
|
});
|
||||||
|
|
||||||
/// let some time ellapse for testing purposes
|
/// let some time ellapse for testing purposes
|
||||||
fn test_ellapse_time(mut cx: FunctionContext) -> JsResult<JsValue> {
|
fn mock_elapsed_time(mut cx: FunctionContext) -> JsResult<JsValue> {
|
||||||
let ms = cx.argument::<JsNumber>(0)?.value();
|
let ms = cx.argument::<JsNumber>(0)?.value();
|
||||||
sixtyfps_corelib::tests::sixtyfps_test_ellapse_time(ms as _);
|
sixtyfps_corelib::tests::sixtyfps_mock_elapsed_time(ms as _);
|
||||||
Ok(JsUndefined::new().as_value(&mut cx))
|
Ok(JsUndefined::new().as_value(&mut cx))
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,7 +108,7 @@ pub fn create_window() -> re_exports::ComponentWindow {
|
||||||
|
|
||||||
/// This module contains functions usefull for unit tests
|
/// This module contains functions usefull for unit tests
|
||||||
pub mod testing {
|
pub mod testing {
|
||||||
pub use sixtyfps_corelib::tests::sixtyfps_test_ellapse_time as ellapse_time;
|
pub use sixtyfps_corelib::tests::sixtyfps_mock_elapsed_time as mock_elapsed_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Include the code generated with the sixtyfps-build crate from the build script
|
/// Include the code generated with the sixtyfps-build crate from the build script
|
||||||
|
|
|
@ -72,7 +72,7 @@ pub mod tests;
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[cold]
|
#[cold]
|
||||||
pub fn use_modules() -> usize {
|
pub fn use_modules() -> usize {
|
||||||
tests::sixtyfps_test_ellapse_time as usize
|
tests::sixtyfps_mock_elapsed_time as usize
|
||||||
+ abi::signals::sixtyfps_signal_init as usize
|
+ abi::signals::sixtyfps_signal_init as usize
|
||||||
+ abi::sharedarray::sixtyfps_shared_array_drop as usize
|
+ abi::sharedarray::sixtyfps_shared_array_drop as usize
|
||||||
+ layout::solve_grid_layout as usize
|
+ layout::solve_grid_layout as usize
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
/// real time, but in tests, it is more convinient to use the fake time.
|
/// real time, but in tests, it is more convinient to use the fake time.
|
||||||
/// This function will add some milliseconds to the fake time
|
/// This function will add some milliseconds to the fake time
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn sixtyfps_test_ellapse_time(time_in_ms: u64) {
|
pub extern "C" fn sixtyfps_mock_elapsed_time(time_in_ms: u64) {
|
||||||
crate::animations::CURRENT_ANIMATION_DRIVER.with(|driver| {
|
crate::animations::CURRENT_ANIMATION_DRIVER.with(|driver| {
|
||||||
let mut tick = driver.current_tick();
|
let mut tick = driver.current_tick();
|
||||||
tick += instant::Duration::from_millis(time_in_ms);
|
tick += instant::Duration::from_millis(time_in_ms);
|
||||||
|
|
|
@ -31,17 +31,17 @@ assert_eq!(instance.get_hello(), 40);
|
||||||
assert_eq!(instance.get_binding_dep(), 100);
|
assert_eq!(instance.get_binding_dep(), 100);
|
||||||
|
|
||||||
// Half the animation
|
// Half the animation
|
||||||
sixtyfps::testing::ellapse_time(600);
|
sixtyfps::testing::mock_elapsed_time(600);
|
||||||
assert_eq!(instance.get_hello(), 50);
|
assert_eq!(instance.get_hello(), 50);
|
||||||
assert_eq!(instance.get_binding_dep(), 125);
|
assert_eq!(instance.get_binding_dep(), 125);
|
||||||
|
|
||||||
|
|
||||||
// Remaining half
|
// Remaining half
|
||||||
sixtyfps::testing::ellapse_time(600);
|
sixtyfps::testing::mock_elapsed_time(600);
|
||||||
assert_eq!(instance.get_hello(), 60);
|
assert_eq!(instance.get_hello(), 60);
|
||||||
assert_eq!(instance.get_binding_dep(), 150);
|
assert_eq!(instance.get_binding_dep(), 150);
|
||||||
|
|
||||||
sixtyfps::testing::ellapse_time(100);
|
sixtyfps::testing::mock_elapsed_time(100);
|
||||||
assert_eq!(instance.get_hello(), 60);
|
assert_eq!(instance.get_hello(), 60);
|
||||||
assert_eq!(instance.get_binding_dep(), 150);
|
assert_eq!(instance.get_binding_dep(), 150);
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ assert_eq!(instance.get_binding_dep(), 150);
|
||||||
// querying the value (because te dirty event should cause the animation to start)
|
// querying the value (because te dirty event should cause the animation to start)
|
||||||
instance.set_condition(true);
|
instance.set_condition(true);
|
||||||
instance.set_hello(30);
|
instance.set_hello(30);
|
||||||
sixtyfps::testing::ellapse_time(600);
|
sixtyfps::testing::mock_elapsed_time(600);
|
||||||
assert_eq!(instance.get_hello(), 45);
|
assert_eq!(instance.get_hello(), 45);
|
||||||
assert_eq!(instance.get_binding_dep(), 125);
|
assert_eq!(instance.get_binding_dep(), 125);
|
||||||
|
|
||||||
|
@ -67,17 +67,17 @@ assert(instance.get_hello() == 40);
|
||||||
assert(instance.get_binding_dep() == 100);
|
assert(instance.get_binding_dep() == 100);
|
||||||
|
|
||||||
// Half the animation
|
// Half the animation
|
||||||
sixtyfps::testing::ellapse_time(600);
|
sixtyfps::testing::mock_elapsed_time(600);
|
||||||
assert(instance.get_hello() == 50);
|
assert(instance.get_hello() == 50);
|
||||||
assert(instance.get_binding_dep() == 125);
|
assert(instance.get_binding_dep() == 125);
|
||||||
|
|
||||||
|
|
||||||
// Remaining half
|
// Remaining half
|
||||||
sixtyfps::testing::ellapse_time(600);
|
sixtyfps::testing::mock_elapsed_time(600);
|
||||||
assert(instance.get_hello() == 60);
|
assert(instance.get_hello() == 60);
|
||||||
assert(instance.get_binding_dep() == 150);
|
assert(instance.get_binding_dep() == 150);
|
||||||
|
|
||||||
sixtyfps::testing::ellapse_time(100);
|
sixtyfps::testing::mock_elapsed_time(100);
|
||||||
assert(instance.get_hello() == 60);
|
assert(instance.get_hello() == 60);
|
||||||
assert(instance.get_binding_dep() == 150);
|
assert(instance.get_binding_dep() == 150);
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ assert(instance.get_binding_dep() == 150);
|
||||||
// querying the value (because te dirty event should cause the animation to start)
|
// querying the value (because te dirty event should cause the animation to start)
|
||||||
instance.set_condition(true);
|
instance.set_condition(true);
|
||||||
instance.set_hello(30);
|
instance.set_hello(30);
|
||||||
sixtyfps::testing::ellapse_time(600);
|
sixtyfps::testing::mock_elapsed_time(600);
|
||||||
assert(instance.get_hello() == 45);
|
assert(instance.get_hello() == 45);
|
||||||
assert(instance.get_binding_dep() == 125);
|
assert(instance.get_binding_dep() == 125);
|
||||||
```
|
```
|
||||||
|
@ -101,14 +101,14 @@ assert.equal(instance.hello, 40);
|
||||||
assert.equal(instance.binding_dep, 100);
|
assert.equal(instance.binding_dep, 100);
|
||||||
|
|
||||||
// Half the animation
|
// Half the animation
|
||||||
sixtyfpslib.test_ellapse_time(600);
|
sixtyfpslib.mock_elapsed_time(600);
|
||||||
assert.equal(instance.hello, 50);
|
assert.equal(instance.hello, 50);
|
||||||
assert.equal(instance.binding_dep, 125);
|
assert.equal(instance.binding_dep, 125);
|
||||||
// Remaining half
|
// Remaining half
|
||||||
sixtyfpslib.test_ellapse_time(600);
|
sixtyfpslib.mock_elapsed_time(600);
|
||||||
assert.equal(instance.hello, 60);
|
assert.equal(instance.hello, 60);
|
||||||
assert.equal(instance.binding_dep, 150);
|
assert.equal(instance.binding_dep, 150);
|
||||||
sixtyfpslib.test_ellapse_time(100);
|
sixtyfpslib.mock_elapsed_time(100);
|
||||||
assert.equal(instance.hello, 60);
|
assert.equal(instance.hello, 60);
|
||||||
assert.equal(instance.binding_dep, 150);
|
assert.equal(instance.binding_dep, 150);
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ assert.equal(instance.binding_dep, 150);
|
||||||
// querying the value (because te dirty event should cause the animation to start)
|
// querying the value (because te dirty event should cause the animation to start)
|
||||||
instance.condition = true;
|
instance.condition = true;
|
||||||
instance.hello = 30;
|
instance.hello = 30;
|
||||||
sixtyfpslib.test_ellapse_time(600);
|
sixtyfpslib.mock_elapsed_time(600);
|
||||||
assert.equal(instance.hello, 45);
|
assert.equal(instance.hello, 45);
|
||||||
assert.equal(instance.binding_dep, 125);
|
assert.equal(instance.binding_dep, 125);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue