239 const std::string&
type,
246 auto duration_ms = std::chrono::duration_cast<std::chrono::milliseconds>(duration);
247 auto record_input = [&]()
249 GIVEN(
"object == " + suite::helper::to_string(object_value)){};
250 GIVEN(
"begin == " + suite::helper::to_string(begin)){};
251 GIVEN(
"end == " + suite::helper::to_string(end)){};
252 GIVEN(
"duration == " + suite::helper::to_string(duration_ms) +
"ms"){};
253 GIVEN(
"step_update == " + suite::helper::to_string(step_update)){};
256 SCENARIO(
"a valid sentinel is passed")
261 GIVEN(
"a valid object and a valid sentinel")
263 values =
values_t<T>(object_value, use_shared_ptr);
267 WHEN(
"the action action is created")
269 action =
creator(
type, values, begin, end, duration);
274 THEN(
"the action should finish successfully")
280 SCENARIO(
"an invalid sentinel is passed")
285 GIVEN(
"a valid object and an invalid sentinel")
287 values =
values_t<T>(object_value, use_shared_ptr);
292 WHEN(
"the action action is created")
294 action =
creator(
type, values, begin, end, duration);
297 THEN(
"the action should not be valid")
299 REQUIRE(!action.is_valid());
303 SCENARIO(
"the 'on_begin' callback expires the sentinel")
308 GIVEN(
"a valid object and a valid sentinel")
310 values =
values_t<T>(object_value, use_shared_ptr);
314 WHEN(
"the action action is created")
316 action =
creator(
type, values, begin, end, duration);
319 AND_WHEN(
"an 'on_begin' callback is connected")
321 action.on_begin.connect(
330 THEN(
"the action should be finished and the sentinel should be expired")
337 SCENARIO(
"the 'on_begin' callback calls 'stop'")
342 GIVEN(
"a valid object and a valid sentinel")
344 values =
values_t<T>(object_value, use_shared_ptr);
348 WHEN(
"the action action is created")
350 action =
creator(
type, values, begin, end, duration);
352 AND_WHEN(
"an 'on_begin' callback is connected")
354 action.on_begin.connect(
363 THEN(
"the action should finish successfully")
369 SCENARIO(
"the 'on_begin' callback calls 'stop_and_finish'")
374 GIVEN(
"a valid object and a valid sentinel")
376 values =
values_t<T>(object_value, use_shared_ptr);
380 WHEN(
"the action action is created")
382 action =
creator(
type, values, begin, end, duration);
385 AND_WHEN(
"an 'on_begin' callback is connected")
387 action.on_begin.connect(
396 THEN(
"the action should finish successfully")
402 SCENARIO(
"the 'on_begin' callback calls 'pause'")
407 GIVEN(
"a valid object and a valid sentinel")
409 values =
values_t<T>(object_value, use_shared_ptr);
413 WHEN(
"the action action is created")
415 action =
creator(
type, values, begin, end, duration);
417 AND_WHEN(
"an 'on_begin' callback is connected")
419 action.on_begin.connect(
430 THEN(
"the action should be paused")
437 THEN(
"the action should be finished")
444 SCENARIO(
"the 'on_update' callback expires the sentinel")
449 GIVEN(
"a valid object and a valid sentinel")
451 values =
values_t<T>(object_value, use_shared_ptr);
455 WHEN(
"the action action is created")
457 action =
creator(
type, values, begin, end, duration);
459 bool is_sentinel_reset_requested =
false;
461 AND_WHEN(
"an 'on_update' callback is connected")
463 action.on_update.connect(
466 is_sentinel_reset_requested =
true;
473 THEN(
"the action should be finished")
477 if(is_sentinel_reset_requested)
483 SCENARIO(
"the 'on_update' callback calls 'stop'")
488 GIVEN(
"a valid object and a valid sentinel")
490 values =
values_t<T>(object_value, use_shared_ptr);
494 WHEN(
"the action action is created")
496 action =
creator(
type, values, begin, end, duration);
498 AND_WHEN(
"an 'on_update' callback is connected")
500 action.on_update.connect(
509 THEN(
"the action should be finished")
515 SCENARIO(
"the 'on_update' callback calls 'stop_and_finish'")
520 GIVEN(
"a valid object and a valid sentinel")
522 values =
values_t<T>(object_value, use_shared_ptr);
526 WHEN(
"the action action is created")
528 action =
creator(
type, values, begin, end, duration);
530 AND_WHEN(
"an 'on_update' callback is connected")
532 action.on_update.connect(
541 THEN(
"the action should be finished")
547 SCENARIO(
"the 'on_update' callback calls 'pause'")
552 GIVEN(
"a valid object and a valid sentinel")
554 values =
values_t<T>(object_value, use_shared_ptr);
558 WHEN(
"the action action is created")
560 action =
creator(
type, values, begin, end, duration);
562 bool is_pause_requested =
false;
563 AND_WHEN(
"an 'on_update' callback is connected")
565 action.on_update.connect(
568 is_pause_requested =
true;
575 if(is_pause_requested && step_update)
577 THEN(
"the action should be paused")
584 THEN(
"the action should be is_finished")
591 SCENARIO(
"the 'on_step' callback expires the sentinel")
596 GIVEN(
"a valid object and a valid sentinel")
598 values =
values_t<T>(object_value, use_shared_ptr);
602 WHEN(
"the action action is created")
604 action =
creator(
type, values, begin, end, duration);
607 bool is_sentinel_reset_requested =
false;
609 AND_WHEN(
"an 'on_step' callback is connected")
611 action.on_step.connect(
614 is_sentinel_reset_requested =
true;
621 THEN(
"the action should be is_finished")
625 if(is_sentinel_reset_requested)
631 SCENARIO(
"the 'on_step' callback calls 'stop'")
636 GIVEN(
"a valid object and a valid sentinel")
638 values =
values_t<T>(object_value, use_shared_ptr);
642 WHEN(
"the action action is created")
644 action =
creator(
type, values, begin, end, duration);
647 AND_WHEN(
"an 'on_step' callback is connected")
649 action.on_step.connect(
658 THEN(
"the action should be is_finished")
664 SCENARIO(
"the 'on_step' callback calls 'stop_and_finish'")
669 GIVEN(
"a valid object and a valid sentinel")
671 values =
values_t<T>(object_value, use_shared_ptr);
675 WHEN(
"the action action is created")
677 action =
creator(
type, values, begin, end, duration);
679 AND_WHEN(
"an 'on_step' callback is connected")
681 action.on_step.connect(
682 [&action, counter = 0]()
mutable
694 THEN(
"the action should be is_finished")
700 SCENARIO(
"the 'on_step' callback calls 'pause'")
705 GIVEN(
"a valid object and a valid sentinel")
707 values =
values_t<T>(object_value, use_shared_ptr);
711 WHEN(
"the action action is created")
713 action =
creator(
type, values, begin, end, duration);
716 bool is_pause_requested =
false;
718 AND_WHEN(
"an 'on_step' callback is connected")
720 action.on_step.connect(
723 is_pause_requested =
true;
730 if(is_pause_requested && step_update)
732 THEN(
"the action should be is_paused")
739 THEN(
"the action should be is_finished")
746 SCENARIO(
"the 'on_end' callback expires the sentinel")
751 GIVEN(
"a valid object and a valid sentinel")
753 values =
values_t<T>(object_value, use_shared_ptr);
757 WHEN(
"the action action is created")
759 action =
creator(
type, values, begin, end, duration);
761 bool is_sentinel_reset_requested =
false;
763 AND_WHEN(
"an 'on_end' callback is connected")
765 action.on_end.connect(
768 is_sentinel_reset_requested =
true;
775 THEN(
"the action should be is_finished")
780 if(is_sentinel_reset_requested)
786 SCENARIO(
"the 'on_end' callback calls 'stop'")
791 GIVEN(
"a valid object and a valid sentinel")
793 values =
values_t<T>(object_value, use_shared_ptr);
797 WHEN(
"the action action is created")
799 action =
creator(
type, values, begin, end, duration);
802 AND_WHEN(
"an 'on_end' callback is connected")
804 action.on_end.connect(
813 THEN(
"the action should be is_finished")
819 SCENARIO(
"the 'on_end' callback calls 'stop_and_finish'")
824 GIVEN(
"a valid object and a valid sentinel")
826 values =
values_t<T>(object_value, use_shared_ptr);
830 WHEN(
"the action action is created")
832 action =
creator(
type, values, begin, end, duration);
834 AND_WHEN(
"an 'on_end' callback is connected")
836 action.on_end.connect(
845 THEN(
"the action should be is_finished")
851 SCENARIO(
"the 'on_end' callback calls 'pause'")
856 GIVEN(
"a valid object and a valid sentinel")
858 values =
values_t<T>(object_value, use_shared_ptr);
862 WHEN(
"the action action is created")
864 action =
creator(
type, values, begin, end, duration);
867 AND_WHEN(
"an 'on_end' callback is connected")
869 action.on_end.connect(
878 THEN(
"the action should be is_finished")