Home · All Classes · Modules |
The QTest namespace contains all the functions and declarations that are related to the QTestLib tool. More...
The QTest namespace contains all the functions and declarations that are related to the QTestLib tool.
Please refer to the QTestLib Manual documentation for information on how to write unit tests.
This enum describes possible actions for key handling.
Constant | Value | Description |
---|---|---|
QTest.Press | 0 | The key is pressed. |
QTest.Release | 1 | The key is released. |
QTest.Click | 2 | The key is clicked (pressed and released). |
This enum describes possible actions for mouse handling.
Constant | Value | Description |
---|---|---|
QTest.MousePress | 0 | A mouse button is pressed. |
QTest.MouseRelease | 1 | A mouse button is released. |
QTest.MouseClick | 2 | A mouse button is clicked (pressed and released). |
QTest.MouseDClick | 3 | A mouse button is double clicked (pressed and released twice). |
QTest.MouseMove | 4 | The mouse pointer has moved. |
Simulates clicking of key with an optional modifier on a widget. If delay is larger than 0, the test will wait for delay milliseconds.
Examples:
QTest.keyClick(myWidget, Qt.Key_Escape); QTest.keyClick(myWidget, Qt.Key_Escape, Qt.ShiftModifier, 200);
The first example above simulates clicking the escape key on myWidget without any keyboard modifiers and without delay. The second example simulates clicking shift-escape on myWidget with a following 200 ms delay of the test.
See also QTest.keyClicks().
This is an overloaded function.
Simulates clicking of key with an optional modifier on a widget. If delay is larger than 0, the test will wait for delay milliseconds.
Example:
QTest.keyClick(myWidget, 'a');
The example above simulates clicking a on myWidget without any keyboard modifiers and without delay of the test.
See also QTest.keyClicks().
Simulates clicking a sequence of keys on a widget. Optionally, a keyboard modifier can be specified as well as a delay (in milliseconds) of the test before each key click.
Example:
QTest.keyClicks(myWidget, "hello world");
The example above simulates clicking the sequence of keys representing "hello world" on myWidget without any keyboard modifiers and without delay of the test.
See also QTest.keyClick().
Sends a Qt key event to widget with the given key and an associated action. Optionally, a keyboard modifier can be specified, as well as a delay (in milliseconds) of the test before sending the event.
This is an overloaded function.
Sends a Qt key event to widget with the given key ascii and an associated action. Optionally, a keyboard modifier can be specified, as well as a delay (in milliseconds) of the test before sending the event.
Simulates pressing a key with an optional modifier on a widget. If delay is larger than 0, the test will wait for delay milliseconds.
Note: At some point you should release the key using keyRelease().
See also QTest.keyRelease() and QTest.keyClick().
This is an overloaded function.
Simulates pressing a key with an optional modifier on a widget. If delay is larger than 0, the test will wait for delay milliseconds.
Note: At some point you should release the key using keyRelease().
See also QTest.keyRelease() and QTest.keyClick().
Simulates releasing a key with an optional modifier on a widget. If delay is larger than 0, the test will wait for delay milliseconds.
See also QTest.keyPress() and QTest.keyClick().
This is an overloaded function.
Simulates releasing a key with an optional modifier on a widget. If delay is larger than 0, the test will wait for delay milliseconds.
See also QTest.keyClick().
Simulates clicking a mouse button with an optional modifier on a widget. The position of the click is defined by pos; the default position is the center of the widget. If delay is specified, the test will wait for the specified amount of milliseconds before pressing and before releasing the button.
See also QTest.mousePress() and QTest.mouseRelease().
Simulates double clicking a mouse button with an optional modifier on a widget. The position of the click is defined by pos; the default position is the center of the widget. If delay is specified, the test will wait for the specified amount of milliseconds before each press and release.
See also QTest.mouseClick().
Moves the mouse pointer to a widget. If pos is not specified, the mouse pointer moves to the center of the widget. If a delay (in milliseconds) is given, the test will wait before moving the mouse pointer.
Simulates pressing a mouse button with an optional modifier on a widget. The position is defined by pos; the default position is the center of the widget. If delay is specified, the test will wait for the specified amount of milliseconds before the press.
See also QTest.mouseRelease() and QTest.mouseClick().
Simulates releasing a mouse button with an optional modifier on a widget. The position of the release is defined by pos; the default position is the center of the widget. If delay is specified, the test will wait for the specified amount of milliseconds before releasing the button.
See also QTest.mousePress() and QTest.mouseClick().
Sleeps for ms milliseconds, blocking execution of the test. qSleep() will not do any event processing and leave your test unresponsive. Network communication might time out while sleeping. Use qWait() to do non-blocking sleeping.
ms must be greater than 0.
Note: The qSleep() function calls either nanosleep() on unix or Sleep() on windows, so the accuracy of time spent in qSleep() depends on the operating system.
Example:
QTest.qSleep(250);
See also qWait().
Waits for ms milliseconds. While waiting, events will be processed and your test will stay responsive to user interface events or network communication.
Example:
int i = 0; while (myNetworkServerNotResponding() && i++ < 50) QTest.qWait(250);
The code above will wait until the network server is responding for a maximum of about 12.5 seconds.
See also QTest.qSleep().
Waits until the window is shown in the screen. This is mainly useful for asynchronous systems like X11, where a window will be mapped to screen some time after being asked to show itself on the screen. Returns true.
Example:
QWidget widget; widget.show(); QTest.qWaitForWindowShown(&widget);
This function was introduced in Qt 4.6.
PyQt 4.12.1 for X11 | Copyright © Riverbank Computing Ltd and The Qt Company 2015 | Qt 4.8.7 |