qtquicktest.rst 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // @snippet quick_test_main_documentation
  2. Sets up the entry point for a Qt Quick Test application.
  3. The ``name`` argument uniquely identifies this set of tests.
  4. ``sys.argv`` should be passed to the ``argv`` argument to ensure
  5. propagation of the command line arguments.
  6. .. note:: The function assumes that your test sources are in the current
  7. directory, unless the ``QUICK_TEST_SOURCE_DIR`` environment
  8. variable is set or a directory is passed in ``dir``.
  9. The following snippet demonstrates the use of this function:
  10. .. code-block:: Python
  11. import sys
  12. from PySide6.QtQuickTest import QUICK_TEST_MAIN
  13. ex = QUICK_TEST_MAIN("example", sys.argv)
  14. sys.exit(ex)
  15. // @snippet quick_test_main_documentation
  16. // @snippet quick_test_main_with_setup_documentation
  17. Sets up the entry point for a Qt Quick Test application.
  18. The ``name`` argument uniquely identifies this set of tests.
  19. ``sys.argv`` should be passed to the ``argv`` argument to ensure
  20. propagation of the command line arguments.
  21. This function is identical to ``QUICK_TEST_MAIN()``, except that it takes an
  22. additional argument ``setup``, the type of a ``QObject``-derived
  23. class which will be instantiated. With this class, it is possible to define
  24. additional setup code to execute before running the QML test.
  25. The following snippet demonstrates the use of this function:
  26. .. code-block:: Python
  27. import sys
  28. from PySide6.QtQuickTest import QUICK_TEST_MAIN_WITH_SETUP
  29. class CustomTestSetup(QObject):
  30. def __init__(self, parent=None):
  31. super().__init__(parent)
  32. @Slot(QQmlEngine)
  33. def qmlEngineAvailable(self, qmlEngine):
  34. pass
  35. ex = QUICK_TEST_MAIN_WITH_SETUP("qquicktestsetup", CustomTestSetup, sys.argv)
  36. sys.exit(ex)
  37. .. note:: The function assumes that your test sources are in the current
  38. directory, unless the ``QUICK_TEST_SOURCE_DIR`` environment
  39. variable is set or a directory is passed in ``dir``.
  40. // @snippet quick_test_main_with_setup_documentation