Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support SceneTree and signal testing - Code edit unit tests #50375

Merged
merged 6 commits into from
Sep 13, 2021

Conversation

Paulb23
Copy link
Member

@Paulb23 Paulb23 commented Jul 11, 2021

Builds on and used to test #50372

Related godotengine/godot-proposals/issues/1307


Support SceneTree and signal testing, opening up for feedback.

Test code changes can be added separately to #50372 but I figured it made sense to have an example with it, so included it here.

Added a doctest reporter GodotTestCaseListener. When doctest runs the test_case_start callback (not subcase) it will check if the case name contains, [SceneTree]; if found will create all the required engine parts.

It will then cleanup that code on the test_case_end callback.

A key part of #50372 is user input and signals.

To handle this a macro SEND_GUI_ACTION(object, action_name) has been added, this will call the _gui_input method on the object with a given action, i.e SEND_GUI_ACTION(code_edit, "ui_text_newline"). This requires a MessageQueue and InputMap.

For signals a test singleton SignalWatcher as been added, when a signal is connected, the SignalWatcher between checks, will capture every time it is emitted with it's args.

The following macros can be use to check signals:

  • SIGNAL_WATCH(*object, "signal_name") to start watching.
  • SIGNAL_UNWATCH(*object, "signal_name") to stop watching.
  • SIGNAL_CHECK("signal_name"), Vector<Vector<Variant>>), to check the arguments of all fired signals.
    • The outer vector is each fired signal, the inner vector the list of arguments for that signal. Order does matter.
  • SIGNAL_CHECK_FALSE("signal_name") to check if a signal was not fired.
  • SIGNAL_DISCARD("signal_name") to discard records all of the given signal

Finally, two minor bugfixs where the input map and display server where not nulling it's singleton var, causing it to print a warning every time it was re-setup. In addition rasterizer_dummy.h was returning true when it has not freed the memory causing a minor memory leak.

@Paulb23 Paulb23 added this to the 4.0 milestone Jul 11, 2021
@Paulb23 Paulb23 force-pushed the code_edit_unit_tests branch 3 times, most recently from 3d30c77 to 2b6fd03 Compare August 15, 2021 13:30
@Paulb23 Paulb23 marked this pull request as ready for review August 15, 2021 14:39
@Paulb23 Paulb23 requested review from a team as code owners August 15, 2021 14:39
@Paulb23 Paulb23 requested a review from a team as a code owner August 25, 2021 17:49
@Paulb23
Copy link
Member Author

Paulb23 commented Aug 25, 2021

Reabsed following #51983 which removed the ability to call "_gui_input". As a result the SEND_GUI_ACTION macro now makes a ordinary c++ call to gui_input, meaning it has to be made public.

@Paulb23
Copy link
Member Author

Paulb23 commented Sep 1, 2021

Fixed a crash after #51296 which assumed there would be an AudioServer, added a check for the singleton in Viewport before we call it.

@akien-mga akien-mga merged commit 70ba366 into godotengine:master Sep 13, 2021
@akien-mga
Copy link
Member

Thanks!

@Paulb23 Paulb23 deleted the code_edit_unit_tests branch September 14, 2021 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants