Rename test_ellapse_time to mock_elapsed_time

This commit is contained in:
Simon Hausmann 2020-08-03 17:52:42 +02:00
parent f2166d91a6
commit 37f874a26b
6 changed files with 22 additions and 21 deletions

View file

@ -3,7 +3,8 @@
#include "sixtyfps.h"
namespace sixtyfps::testing {
inline void ellapse_time(int64_t time_in_ms) {
internal::sixtyfps_test_ellapse_time(time_in_ms);
inline void mock_elapsed_time(int64_t time_in_ms)
{
internal::sixtyfps_mock_elapsed_time(time_in_ms);
}
} // namespace sixtyfps

View file

@ -306,13 +306,13 @@ declare_types! {
register_module!(mut m, {
m.export_function("load", load)?;
m.export_function("test_ellapse_time", test_ellapse_time)?;
m.export_function("mock_elapsed_time", mock_elapsed_time)?;
Ok(())
});
/// 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();
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))
}

View file

@ -108,7 +108,7 @@ pub fn create_window() -> re_exports::ComponentWindow {
/// This module contains functions usefull for unit tests
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

View file

@ -72,7 +72,7 @@ pub mod tests;
#[doc(hidden)]
#[cold]
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::sharedarray::sixtyfps_shared_array_drop as usize
+ layout::solve_grid_layout as usize

View file

@ -5,7 +5,7 @@
/// real time, but in tests, it is more convinient to use the fake time.
/// This function will add some milliseconds to the fake time
#[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| {
let mut tick = driver.current_tick();
tick += instant::Duration::from_millis(time_in_ms);

View file

@ -31,17 +31,17 @@ assert_eq!(instance.get_hello(), 40);
assert_eq!(instance.get_binding_dep(), 100);
// Half the animation
sixtyfps::testing::ellapse_time(600);
sixtyfps::testing::mock_elapsed_time(600);
assert_eq!(instance.get_hello(), 50);
assert_eq!(instance.get_binding_dep(), 125);
// Remaining half
sixtyfps::testing::ellapse_time(600);
sixtyfps::testing::mock_elapsed_time(600);
assert_eq!(instance.get_hello(), 60);
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_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)
instance.set_condition(true);
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_binding_dep(), 125);
@ -67,17 +67,17 @@ assert(instance.get_hello() == 40);
assert(instance.get_binding_dep() == 100);
// Half the animation
sixtyfps::testing::ellapse_time(600);
sixtyfps::testing::mock_elapsed_time(600);
assert(instance.get_hello() == 50);
assert(instance.get_binding_dep() == 125);
// Remaining half
sixtyfps::testing::ellapse_time(600);
sixtyfps::testing::mock_elapsed_time(600);
assert(instance.get_hello() == 60);
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_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)
instance.set_condition(true);
instance.set_hello(30);
sixtyfps::testing::ellapse_time(600);
sixtyfps::testing::mock_elapsed_time(600);
assert(instance.get_hello() == 45);
assert(instance.get_binding_dep() == 125);
```
@ -101,14 +101,14 @@ assert.equal(instance.hello, 40);
assert.equal(instance.binding_dep, 100);
// Half the animation
sixtyfpslib.test_ellapse_time(600);
sixtyfpslib.mock_elapsed_time(600);
assert.equal(instance.hello, 50);
assert.equal(instance.binding_dep, 125);
// Remaining half
sixtyfpslib.test_ellapse_time(600);
sixtyfpslib.mock_elapsed_time(600);
assert.equal(instance.hello, 60);
assert.equal(instance.binding_dep, 150);
sixtyfpslib.test_ellapse_time(100);
sixtyfpslib.mock_elapsed_time(100);
assert.equal(instance.hello, 60);
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)
instance.condition = true;
instance.hello = 30;
sixtyfpslib.test_ellapse_time(600);
sixtyfpslib.mock_elapsed_time(600);
assert.equal(instance.hello, 45);
assert.equal(instance.binding_dep, 125);