diff --git a/2d/physics_tests/test.gd b/2d/physics_tests/test.gd index 1c31270399..466315670a 100644 --- a/2d/physics_tests/test.gd +++ b/2d/physics_tests/test.gd @@ -115,7 +115,7 @@ func cancel_timer(): func is_timer_canceled(): - return _timer.paused + return _timer and _timer.paused func wait_for_physics_ticks(tick_count): diff --git a/2d/physics_tests/tests/functional/test_character.gd b/2d/physics_tests/tests/functional/test_character.gd index 48f129ad39..e7fc6ac050 100644 --- a/2d/physics_tests/tests/functional/test_character.gd +++ b/2d/physics_tests/tests/functional/test_character.gd @@ -127,6 +127,8 @@ func _on_option_changed(option, checked): func _start_test(): + cancel_timer() + if _moving_body: _body_parent.remove_child(_moving_body) _moving_body.queue_free() diff --git a/2d/physics_tests/tests/functional/test_character_pixels.gd b/2d/physics_tests/tests/functional/test_character_pixels.gd index f15b931a73..993dc50ce8 100644 --- a/2d/physics_tests/tests/functional/test_character_pixels.gd +++ b/2d/physics_tests/tests/functional/test_character_pixels.gd @@ -101,10 +101,14 @@ func _test_all(): # Test floor detection with no snapping. yield(_start_test_case(OPTION_TEST_CASE_DETECT_FLOOR_NO_SNAP), "completed") + if is_timer_canceled(): + return # Test floor detection with no snapping. # In this test case, motion alternates different speeds. yield(_start_test_case(OPTION_TEST_CASE_DETECT_FLOOR_MOTION_CHANGES), "completed") + if is_timer_canceled(): + return Log.print_log("* Done.") diff --git a/2d/physics_tests/tests/functional/test_character_tilemap.gd b/2d/physics_tests/tests/functional/test_character_tilemap.gd index c686342907..5babe58bf3 100644 --- a/2d/physics_tests/tests/functional/test_character_tilemap.gd +++ b/2d/physics_tests/tests/functional/test_character_tilemap.gd @@ -88,12 +88,25 @@ func _test_all(): # RigidBody tests. yield(_start_test_case(OPTION_TEST_CASE_JUMP_ONE_WAY_RIGID), "completed") + if is_timer_canceled(): + return + yield(_start_test_case(OPTION_TEST_CASE_JUMP_ONE_WAY_CORNER_RIGID), "completed") + if is_timer_canceled(): + return # KinematicBody tests. yield(_start_test_case(OPTION_TEST_CASE_JUMP_ONE_WAY_KINEMATIC), "completed") + if is_timer_canceled(): + return + yield(_start_test_case(OPTION_TEST_CASE_JUMP_ONE_WAY_CORNER_KINEMATIC), "completed") + if is_timer_canceled(): + return + yield(_start_test_case(OPTION_TEST_CASE_FALL_ONE_WAY_KINEMATIC), "completed") + if is_timer_canceled(): + return Log.print_log("* Done.") diff --git a/2d/physics_tests/tests/functional/test_one_way_collision.gd b/2d/physics_tests/tests/functional/test_one_way_collision.gd index 31bd6dfe9f..19cc06c2de 100644 --- a/2d/physics_tests/tests/functional/test_one_way_collision.gd +++ b/2d/physics_tests/tests/functional/test_one_way_collision.gd @@ -44,6 +44,8 @@ var _test_step = 0 var _test_all_angles = false var _lock_controls = false +var _test_canceled = false + func _ready(): if not Engine.editor_hint: @@ -225,16 +227,24 @@ func _test_all_rigid_body(): _set_platform_size(64.0, false) _set_rigidbody_angle(0.0, false) yield(_start_test_case(OPTION_TEST_CASE_ALL_ANGLES_RIGID), "completed") + if _test_canceled: + return _set_platform_size(64.0, false) _set_rigidbody_angle(45.0, false) yield(_start_test_case(OPTION_TEST_CASE_ALL_ANGLES_RIGID), "completed") + if _test_canceled: + return _set_platform_size(32.0, false) _set_rigidbody_angle(45.0, false) yield(_start_test_case(OPTION_TEST_CASE_ALL_ANGLES_RIGID), "completed") + if _test_canceled: + return yield(_start_test_case(OPTION_TEST_CASE_MOVING_PLATFORM_RIGID), "completed") + if _test_canceled: + return func _test_all_kinematic_body(): @@ -243,16 +253,24 @@ func _test_all_kinematic_body(): _set_platform_size(64.0, false) _set_rigidbody_angle(0.0, false) yield(_start_test_case(OPTION_TEST_CASE_ALL_ANGLES_KINEMATIC), "completed") + if _test_canceled: + return _set_platform_size(64.0, false) _set_rigidbody_angle(45.0, false) yield(_start_test_case(OPTION_TEST_CASE_ALL_ANGLES_KINEMATIC), "completed") + if _test_canceled: + return _set_platform_size(32.0, false) _set_rigidbody_angle(45.0, false) yield(_start_test_case(OPTION_TEST_CASE_ALL_ANGLES_KINEMATIC), "completed") + if _test_canceled: + return yield(_start_test_case(OPTION_TEST_CASE_MOVING_PLATFORM_KINEMATIC), "completed") + if _test_canceled: + return func _test_moving_platform(): @@ -265,9 +283,13 @@ func _test_moving_platform(): _set_platform_angle(90.0, false) yield(_wait_for_test(), "completed") + if _test_canceled: + return _set_platform_angle(-90.0, false) yield(_wait_for_test(), "completed") + if _test_canceled: + return Log.print_log("* Platform moving towards body...") _set_platform_size(64.0, false) @@ -276,9 +298,13 @@ func _test_moving_platform(): _set_platform_angle(90.0, false) yield(_wait_for_test(), "completed") + if _test_canceled: + return _set_platform_angle(-90.0, false) yield(_wait_for_test(), "completed") + if _test_canceled: + return _platform_speed = 0.0 emit_signal("all_tests_done") @@ -288,7 +314,12 @@ func _test_all(): Log.print_log("* TESTING ALL...") yield(_test_all_rigid_body(), "completed") + if _test_canceled: + return + yield(_test_all_kinematic_body(), "completed") + if _test_canceled: + return Log.print_log("* Done.") @@ -342,7 +373,9 @@ func _start_test(): func _reset_test(cancel_test = true): - $Timer.stop() + _test_canceled = true + _on_timeout() + _test_canceled = false _test_step = 0 @@ -415,13 +448,27 @@ func _should_collide(): func _on_timeout(): + cancel_timer() + + if $Timer.is_stopped(): + return + + $Timer.stop() + + if _test_canceled: + emit_signal("test_done") + emit_signal("all_tests_done") + return + if not _contact_detected and not _target_entered: Log.print_log("Test TIMEOUT") _set_result() - $Timer.stop() - - yield(get_tree().create_timer(0.5), "timeout") + yield(start_timer(0.5), "timeout") + if _test_canceled: + emit_signal("test_done") + emit_signal("all_tests_done") + return var was_all_angles = _test_all_angles