-
Notifications
You must be signed in to change notification settings - Fork 29
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
UI testing #67
UI testing #67
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This all looks great to me!
One slight issue I'm seeing is that it breaks normal running of cargo test
(without the test-ui-replay feature) because it doesn't pull in itertools. Adding itertools to dev-dependencies
without optional = true
fixed that for me.
Oh, nice catch. I think that crept in due to some reordering; later in the #54 sequence itertools becomes a regular dependency so |
This avoids problems when inactive tests are left around by other branches, and makes it possible to add subdirectories in 'tests' without confusing the existing test code.
This is needed for tests using GTK to work on Linux.
This occurs when combining record-ui-test with step-decoder.
All the statements declaring submodules are now in lib.rs, which defines a packetry crate, used by main.rs. The UI code is moved to ui.rs, which is exposed to main.rs as part of the packetry crate. The UI replay test is now a separate standalone program, test_replay.rs. This is declared as a custom test in Cargo.toml, one not using the standard cargo harness. It must be enabled specifically when testing: cargo test --features=test-ui-replay This solves the problem of not being able to run that test on macOS, which requires GTK to be initialized and used only from the main thread. The CI workflow is amended to test with the test-ui-replay feature enabled, and to build the release binary without features enabled. All current features are for debug and test purposes only.
Fixed! |
Thanks! |
This PR adds new test infrastructure for recording and replaying UI interactions, along with a couple of test cases.
UI interactions are recorded through normal usage of the UI, by running with the
record-ui-test
feature, which writes out anactions.json
file describing all actions the user took, and anoutput.txt
file containing all information displayed by the UI as a result.A test case is created by adding a test name to
tests/ui/tests.txt
and creating a directorytests/ui/<name>
, containing theactions.json
and the expected output named asreference.txt
. When the tests are run, the actions are replayed into the UI, and a newoutput.txt
file is generated and compared toreference.txt
.To the extent I found practical, the replay test exercises all the same UI code as normal operation, including full use of the GTK toolkit, but without actually displaying a window. This raised a couple of side issues:
DISPLAY
setting present to use GTK, so CI is modified to run the tests with an Xvfb server available.test_replay
, which does not use the standard harness.test_replay
is a separate program, this required moving most of Packetry into a library crate.cfg(test)
set, so blocks in the UI code that are required bytest_replay
have to be feature gated instead.cargo test --features=test-ui-replay
.Some changes are also made to the existing decoder tests:
tests/tests.txt
, rather than listing thetests
directory.This PR is part of the planned sequence documented in #54. The next PR will add interleaving support to the tree view. The tests in this PR will be used to verify that the UI behaves correctly after the changes.