aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/PySide6/doc/qtquicktest.rst
blob: 9df2af0717b831b827ee61c939a08218bdb76f86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// @snippet quick_test_main_documentation

Sets up the entry point for a Qt Quick Test application.
The ``name`` argument uniquely identifies this set of tests.

``sys.argv`` should be passed to the ``argv`` argument to ensure
propagation of the command line arguments.

.. note:: The function assumes that your test sources are in the current
          directory, unless the ``QUICK_TEST_SOURCE_DIR`` environment
          variable is set or a directory is passed in ``dir``.

The following snippet demonstrates the use of this function:

.. code-block:: Python

    import sys
    from PySide6.QtQuickTest import QUICK_TEST_MAIN

    ex = QUICK_TEST_MAIN("example", sys.argv)
    sys.exit(ex)


// @snippet quick_test_main_documentation

// @snippet quick_test_main_with_setup_documentation

Sets up the entry point for a Qt Quick Test application.
The ``name`` argument uniquely identifies this set of tests.

``sys.argv`` should be passed to the ``argv`` argument to ensure
propagation of the command line arguments.

This function is identical to ``QUICK_TEST_MAIN()``, except that it takes an
additional argument ``setup``, the type of a ``QObject``-derived
class which will be instantiated. With this class, it is possible to define
additional setup code to execute before running the QML test.

The following snippet demonstrates the use of this function:

.. code-block:: Python

    import sys
    from PySide6.QtQuickTest import QUICK_TEST_MAIN_WITH_SETUP

    class CustomTestSetup(QObject):
        def __init__(self, parent=None):
            super().__init__(parent)

        @Slot(QQmlEngine)
        def qmlEngineAvailable(self, qmlEngine):
            pass

    ex = QUICK_TEST_MAIN_WITH_SETUP("qquicktestsetup", CustomTestSetup, sys.argv)
    sys.exit(ex)


.. note:: The function assumes that your test sources are in the current
          directory, unless the ``QUICK_TEST_SOURCE_DIR`` environment
          variable is set or a directory is passed in ``dir``.

// @snippet quick_test_main_with_setup_documentation