Skip to content

main.cpp

file tests/app/main.cpp ยท Test suite

Entry point of nmeasim_app_tests, the Catch2 suite for the desktop application.

Source tests/app/main.cpp

The suite has its own main instead of the one Catch2 provides because widgets can only be created once a QApplication exists. The runner forces the Qt platform plugin to offscreen, so that windows are created, laid out and painted without a display; the ctest registration in tests/CMakeLists.txt sets QT_QPA_PLATFORM=offscreen as well. It also redirects QSettings to INI files in a temporary directory, deleted when the run ends, under the application and organisation name NMEASimulatorX-tests, so that the tests never read or overwrite the operator's preferences. In those settings it switches tile downloads off (map/online) and points the map tile cache (map/cache_directory) at a second temporary directory, so that a MainWindow never reaches the tile server and never reads or fills a tile cache outside the run.

Summary

File-local functions

Name Description
main() Creates the offscreen QApplication, isolates the settings and the tile cache, and runs the Catch2 session.

File-local functions

main()

int main(int argc, char* argv[])

Creates the offscreen QApplication, isolates the settings and the tile cache, and runs the Catch2 session.

Parameters

Name Type Description
argc int Number of command-line arguments.
argv char* Command-line arguments; Qt removes the options it recognises, and the rest are passed to Catch2 (test names, tags such as "[.screenshot]", reporter options).

Returns int: The exit code of the Catch2 session: 0 when every selected test passed, non-zero when a test failed.

Declared in tests/app/main.cpp:32