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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
|
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QTest Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">  </td><td class="postheader" valign="center"><a href="../pyqt4ref.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QTest Class Reference<br /><sup><sup>[<a href="qttest.html">QtTest</a> module]</sup></sup></h1><p>The QTest namespace contains all the functions and declarations that are related to the <a href="qtestlib-manual.html#qtestlib">QTestLib</a> tool. <a href="#details">More...</a></p>
<h3>Types</h3><ul><li><div class="fn" />enum <b><a href="qtest.html#KeyAction-enum">KeyAction</a></b> { Press, Release, Click }</li><li><div class="fn" />enum <b><a href="qtest.html#MouseAction-enum">MouseAction</a></b> { MousePress, MouseRelease, MouseClick, MouseDClick, MouseMove }</li><li><div class="fn" />class <b><a href="qtest-qtoucheventsequence.html">QTouchEventSequence</a></b></li></ul><h3>Static Methods</h3><ul><li><div class="fn" /><b><a href="qtest.html#keyClick">keyClick</a></b> (QWidget, Qt.Key, Qt.KeyboardModifiers <i>modifier</i> = Qt.NoModifier, int <i>delay</i> = -1)</li><li><div class="fn" /><b><a href="qtest.html#keyClick-2">keyClick</a></b> (QWidget, str, Qt.KeyboardModifiers <i>modifier</i> = Qt.NoModifier, int <i>delay</i> = -1)</li><li><div class="fn" /><b><a href="qtest.html#keyClicks">keyClicks</a></b> (QWidget, QString, Qt.KeyboardModifiers <i>modifier</i> = Qt.NoModifier, int <i>delay</i> = -1)</li><li><div class="fn" /><b><a href="qtest.html#keyEvent">keyEvent</a></b> (KeyAction, QWidget, Qt.Key, Qt.KeyboardModifiers <i>modifier</i> = Qt.NoModifier, int <i>delay</i> = -1)</li><li><div class="fn" /><b><a href="qtest.html#keyEvent-2">keyEvent</a></b> (KeyAction, QWidget, str, Qt.KeyboardModifiers <i>modifier</i> = Qt.NoModifier, int <i>delay</i> = -1)</li><li><div class="fn" /><b><a href="qtest.html#keyPress">keyPress</a></b> (QWidget, Qt.Key, Qt.KeyboardModifiers <i>modifier</i> = Qt.NoModifier, int <i>delay</i> = -1)</li><li><div class="fn" /><b><a href="qtest.html#keyPress-2">keyPress</a></b> (QWidget, str, Qt.KeyboardModifiers <i>modifier</i> = Qt.NoModifier, int <i>delay</i> = -1)</li><li><div class="fn" /><b><a href="qtest.html#keyRelease">keyRelease</a></b> (QWidget, Qt.Key, Qt.KeyboardModifiers <i>modifier</i> = Qt.NoModifier, int <i>delay</i> = -1)</li><li><div class="fn" /><b><a href="qtest.html#keyRelease-2">keyRelease</a></b> (QWidget, str, Qt.KeyboardModifiers <i>modifier</i> = Qt.NoModifier, int <i>delay</i> = -1)</li><li><div class="fn" /><b><a href="qtest.html#mouseClick">mouseClick</a></b> (QWidget, Qt.MouseButton, Qt.KeyboardModifiers <i>modifier</i> = 0, QPoint <i>pos</i> = QPoint(), int <i>delay</i> = -1)</li><li><div class="fn" /><b><a href="qtest.html#mouseDClick">mouseDClick</a></b> (QWidget, Qt.MouseButton, Qt.KeyboardModifiers <i>modifier</i> = 0, QPoint <i>pos</i> = QPoint(), int <i>delay</i> = -1)</li><li><div class="fn" /><b><a href="qtest.html#mouseMove">mouseMove</a></b> (QWidget, QPoint <i>pos</i> = QPoint(), int <i>delay</i> = -1)</li><li><div class="fn" /><b><a href="qtest.html#mousePress">mousePress</a></b> (QWidget, Qt.MouseButton, Qt.KeyboardModifiers <i>modifier</i> = 0, QPoint <i>pos</i> = QPoint(), int <i>delay</i> = -1)</li><li><div class="fn" /><b><a href="qtest.html#mouseRelease">mouseRelease</a></b> (QWidget, Qt.MouseButton, Qt.KeyboardModifiers <i>modifier</i> = 0, QPoint <i>pos</i> = QPoint(), int <i>delay</i> = -1)</li><li><div class="fn" /><b><a href="qtest.html#qSleep">qSleep</a></b> (int)</li><li><div class="fn" /><b><a href="qtest.html#qWait">qWait</a></b> (int)</li><li><div class="fn" />bool <b><a href="qtest.html#qWaitForWindowShown">qWaitForWindowShown</a></b> (QWidget)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QTest namespace contains all the functions and declarations that are related to the <a href="qtestlib-manual.html#qtestlib">QTestLib</a> tool.</p>
<p>Please refer to the <a href="qtestlib-manual.html">QTestLib Manual</a> documentation for information on how to write unit tests.</p>
<hr /><h2>Type Documentation</h2><h3 class="fn"><a name="KeyAction-enum" />QTest.KeyAction</h3><p>This enum describes possible actions for key handling.</p>
<p><table border="1" cellpadding="2" cellspacing="1" class="valuelist" width="100%">
<tr><th width="25%">Constant</th><th width="15%">Value</th><th width="60%">Description</th></tr>
<tr><td valign="top"><tt>QTest.Press</tt></td><td align="center" valign="top"><tt>0</tt></td><td valign="top">The key is pressed.</td></tr>
<tr><td valign="top"><tt>QTest.Release</tt></td><td align="center" valign="top"><tt>1</tt></td><td valign="top">The key is released.</td></tr>
<tr><td valign="top"><tt>QTest.Click</tt></td><td align="center" valign="top"><tt>2</tt></td><td valign="top">The key is clicked (pressed and released).</td></tr>
</table></p>
<a name="//apple_ref/cpp/tag/QTest/LogElementType" />
<a name="//apple_ref/cpp/econst/QTest/LET_Undefined" />
<a name="//apple_ref/cpp/econst/QTest/LET_Property" />
<a name="//apple_ref/cpp/econst/QTest/LET_Properties" />
<a name="//apple_ref/cpp/econst/QTest/LET_Failure" />
<a name="//apple_ref/cpp/econst/QTest/LET_Error" />
<a name="//apple_ref/cpp/econst/QTest/LET_TestCase" />
<a name="//apple_ref/cpp/econst/QTest/LET_TestSuite" />
<a name="//apple_ref/cpp/econst/QTest/LET_Benchmark" />
<a name="//apple_ref/cpp/econst/QTest/LET_SystemError" />
<h3 class="fn"><a name="MouseAction-enum" />QTest.MouseAction</h3><p>This enum describes possible actions for mouse handling.</p>
<p><table border="1" cellpadding="2" cellspacing="1" class="valuelist" width="100%">
<tr><th width="25%">Constant</th><th width="15%">Value</th><th width="60%">Description</th></tr>
<tr><td valign="top"><tt>QTest.MousePress</tt></td><td align="center" valign="top"><tt>0</tt></td><td valign="top">A mouse button is pressed.</td></tr>
<tr><td valign="top"><tt>QTest.MouseRelease</tt></td><td align="center" valign="top"><tt>1</tt></td><td valign="top">A mouse button is released.</td></tr>
<tr><td valign="top"><tt>QTest.MouseClick</tt></td><td align="center" valign="top"><tt>2</tt></td><td valign="top">A mouse button is clicked (pressed and released).</td></tr>
<tr><td valign="top"><tt>QTest.MouseDClick</tt></td><td align="center" valign="top"><tt>3</tt></td><td valign="top">A mouse button is double clicked (pressed and released twice).</td></tr>
<tr><td valign="top"><tt>QTest.MouseMove</tt></td><td align="center" valign="top"><tt>4</tt></td><td valign="top">The mouse pointer has moved.</td></tr>
</table></p>
<a name="//apple_ref/cpp/tag/QTest/SkipMode" />
<a name="//apple_ref/cpp/econst/QTest/SkipSingle" />
<a name="//apple_ref/cpp/econst/QTest/SkipAll" />
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="keyClick" />QTest.keyClick (<a href="qwidget.html">QWidget</a>, <a href="qt.html#Key-enum">Qt.Key</a>, <a href="qt-keyboardmodifiers.html">Qt.KeyboardModifiers</a> <i>modifier</i> = Qt.NoModifier, int <i>delay</i> = -1)</h3><p>Simulates clicking of <i>key</i> with an optional <i>modifier</i> on a <i>widget</i>. If <i>delay</i> is larger than 0, the test will wait for <i>delay</i> milliseconds.</p>
<p>Examples:</p>
<pre> QTest.keyClick(myWidget, Qt.Key_Escape);
QTest.keyClick(myWidget, Qt.Key_Escape, Qt.ShiftModifier, 200);</pre>
<p>The first example above simulates clicking the <tt>escape</tt> key on <tt>myWidget</tt> without any keyboard modifiers and without delay. The second example simulates clicking <tt>shift-escape</tt> on <tt>myWidget</tt> with a following 200 ms delay of the test.</p>
<p>See also <a href="qtest.html#keyClicks">QTest.keyClicks</a>().</p>
<h3 class="fn"><a name="keyClick-2" />QTest.keyClick (<a href="qwidget.html">QWidget</a>, str, <a href="qt-keyboardmodifiers.html">Qt.KeyboardModifiers</a> <i>modifier</i> = Qt.NoModifier, int <i>delay</i> = -1)</h3><p>This is an overloaded function.</p>
<p>Simulates clicking of <i>key</i> with an optional <i>modifier</i> on a <i>widget</i>. If <i>delay</i> is larger than 0, the test will wait for <i>delay</i> milliseconds.</p>
<p>Example:</p>
<pre> QTest.keyClick(myWidget, 'a');</pre>
<p>The example above simulates clicking <tt>a</tt> on <tt>myWidget</tt> without any keyboard modifiers and without delay of the test.</p>
<p>See also <a href="qtest.html#keyClicks">QTest.keyClicks</a>().</p>
<a name="//apple_ref/cpp/clm/QTest/keyClicks" />
<h3 class="fn"><a name="keyClicks" />QTest.keyClicks (<a href="qwidget.html">QWidget</a>, QString, <a href="qt-keyboardmodifiers.html">Qt.KeyboardModifiers</a> <i>modifier</i> = Qt.NoModifier, int <i>delay</i> = -1)</h3><p>Simulates clicking a <i>sequence</i> of keys on a <i>widget</i>. Optionally, a keyboard <i>modifier</i> can be specified as well as a <i>delay</i> (in milliseconds) of the test before each key click.</p>
<p>Example:</p>
<pre> QTest.keyClicks(myWidget, "hello world");</pre>
<p>The example above simulates clicking the sequence of keys representing "hello world" on <tt>myWidget</tt> without any keyboard modifiers and without delay of the test.</p>
<p>See also <a href="qtest.html#keyClick">QTest.keyClick</a>().</p>
<a name="//apple_ref/cpp/clm/QTest/keyEvent" />
<h3 class="fn"><a name="keyEvent" />QTest.keyEvent (<a href="qtest.html#KeyAction-enum">KeyAction</a>, <a href="qwidget.html">QWidget</a>, <a href="qt.html#Key-enum">Qt.Key</a>, <a href="qt-keyboardmodifiers.html">Qt.KeyboardModifiers</a> <i>modifier</i> = Qt.NoModifier, int <i>delay</i> = -1)</h3><p>Sends a Qt key event to <i>widget</i> with the given <i>key</i> and an associated <i>action</i>. Optionally, a keyboard <i>modifier</i> can be specified, as well as a <i>delay</i> (in milliseconds) of the test before sending the event.</p>
<h3 class="fn"><a name="keyEvent-2" />QTest.keyEvent (<a href="qtest.html#KeyAction-enum">KeyAction</a>, <a href="qwidget.html">QWidget</a>, str, <a href="qt-keyboardmodifiers.html">Qt.KeyboardModifiers</a> <i>modifier</i> = Qt.NoModifier, int <i>delay</i> = -1)</h3><p>This is an overloaded function.</p>
<p>Sends a Qt key event to <i>widget</i> with the given key <i>ascii</i> and an associated <i>action</i>. Optionally, a keyboard <i>modifier</i> can be specified, as well as a <i>delay</i> (in milliseconds) of the test before sending the event.</p>
<a name="//apple_ref/cpp/clm/QTest/keyPress" />
<h3 class="fn"><a name="keyPress" />QTest.keyPress (<a href="qwidget.html">QWidget</a>, <a href="qt.html#Key-enum">Qt.Key</a>, <a href="qt-keyboardmodifiers.html">Qt.KeyboardModifiers</a> <i>modifier</i> = Qt.NoModifier, int <i>delay</i> = -1)</h3><p>Simulates pressing a <i>key</i> with an optional <i>modifier</i> on a <i>widget</i>. If <i>delay</i> is larger than 0, the test will wait for <i>delay</i> milliseconds.</p>
<p><b>Note:</b> At some point you should release the key using <a href="qtest.html#keyRelease">keyRelease</a>().</p>
<p>See also <a href="qtest.html#keyRelease">QTest.keyRelease</a>() and <a href="qtest.html#keyClick">QTest.keyClick</a>().</p>
<h3 class="fn"><a name="keyPress-2" />QTest.keyPress (<a href="qwidget.html">QWidget</a>, str, <a href="qt-keyboardmodifiers.html">Qt.KeyboardModifiers</a> <i>modifier</i> = Qt.NoModifier, int <i>delay</i> = -1)</h3><p>This is an overloaded function.</p>
<p>Simulates pressing a <i>key</i> with an optional <i>modifier</i> on a <i>widget</i>. If <i>delay</i> is larger than 0, the test will wait for <i>delay</i> milliseconds.</p>
<p><b>Note:</b> At some point you should release the key using <a href="qtest.html#keyRelease">keyRelease</a>().</p>
<p>See also <a href="qtest.html#keyRelease">QTest.keyRelease</a>() and <a href="qtest.html#keyClick">QTest.keyClick</a>().</p>
<a name="//apple_ref/cpp/clm/QTest/keyRelease" />
<h3 class="fn"><a name="keyRelease" />QTest.keyRelease (<a href="qwidget.html">QWidget</a>, <a href="qt.html#Key-enum">Qt.Key</a>, <a href="qt-keyboardmodifiers.html">Qt.KeyboardModifiers</a> <i>modifier</i> = Qt.NoModifier, int <i>delay</i> = -1)</h3><p>Simulates releasing a <i>key</i> with an optional <i>modifier</i> on a <i>widget</i>. If <i>delay</i> is larger than 0, the test will wait for <i>delay</i> milliseconds.</p>
<p>See also <a href="qtest.html#keyPress">QTest.keyPress</a>() and <a href="qtest.html#keyClick">QTest.keyClick</a>().</p>
<h3 class="fn"><a name="keyRelease-2" />QTest.keyRelease (<a href="qwidget.html">QWidget</a>, str, <a href="qt-keyboardmodifiers.html">Qt.KeyboardModifiers</a> <i>modifier</i> = Qt.NoModifier, int <i>delay</i> = -1)</h3><p>This is an overloaded function.</p>
<p>Simulates releasing a <i>key</i> with an optional <i>modifier</i> on a <i>widget</i>. If <i>delay</i> is larger than 0, the test will wait for <i>delay</i> milliseconds.</p>
<p>See also <a href="qtest.html#keyClick">QTest.keyClick</a>().</p>
<a name="//apple_ref/cpp/instm/QTest/mouseClick" />
<h3 class="fn"><a name="mouseClick" />QTest.mouseClick (<a href="qwidget.html">QWidget</a>, <a href="qt.html#MouseButton-enum">Qt.MouseButton</a>, <a href="qt-keyboardmodifiers.html">Qt.KeyboardModifiers</a> <i>modifier</i> = 0, <a href="qpoint.html">QPoint</a> <i>pos</i> = QPoint(), int <i>delay</i> = -1)</h3><p>Simulates clicking a mouse <i>button</i> with an optional <i>modifier</i> on a <i>widget</i>. The position of the click is defined by <i>pos</i>; the default position is the center of the widget. If <i>delay</i> is specified, the test will wait for the specified amount of milliseconds before pressing and before releasing the button.</p>
<p>See also <a href="qtest.html#mousePress">QTest.mousePress</a>() and <a href="qtest.html#mouseRelease">QTest.mouseRelease</a>().</p>
<a name="//apple_ref/cpp/instm/QTest/mouseDClick" />
<h3 class="fn"><a name="mouseDClick" />QTest.mouseDClick (<a href="qwidget.html">QWidget</a>, <a href="qt.html#MouseButton-enum">Qt.MouseButton</a>, <a href="qt-keyboardmodifiers.html">Qt.KeyboardModifiers</a> <i>modifier</i> = 0, <a href="qpoint.html">QPoint</a> <i>pos</i> = QPoint(), int <i>delay</i> = -1)</h3><p>Simulates double clicking a mouse <i>button</i> with an optional <i>modifier</i> on a <i>widget</i>. The position of the click is defined by <i>pos</i>; the default position is the center of the widget. If <i>delay</i> is specified, the test will wait for the specified amount of milliseconds before each press and release.</p>
<p>See also <a href="qtest.html#mouseClick">QTest.mouseClick</a>().</p>
<a name="//apple_ref/cpp/instm/QTest/mouseMove" />
<h3 class="fn"><a name="mouseMove" />QTest.mouseMove (<a href="qwidget.html">QWidget</a>, <a href="qpoint.html">QPoint</a> <i>pos</i> = QPoint(), int <i>delay</i> = -1)</h3><p>Moves the mouse pointer to a <i>widget</i>. If <i>pos</i> is not specified, the mouse pointer moves to the center of the widget. If a <i>delay</i> (in milliseconds) is given, the test will wait before moving the mouse pointer.</p>
<a name="//apple_ref/cpp/instm/QTest/mousePress" />
<h3 class="fn"><a name="mousePress" />QTest.mousePress (<a href="qwidget.html">QWidget</a>, <a href="qt.html#MouseButton-enum">Qt.MouseButton</a>, <a href="qt-keyboardmodifiers.html">Qt.KeyboardModifiers</a> <i>modifier</i> = 0, <a href="qpoint.html">QPoint</a> <i>pos</i> = QPoint(), int <i>delay</i> = -1)</h3><p>Simulates pressing a mouse <i>button</i> with an optional <i>modifier</i> on a <i>widget</i>. The position is defined by <i>pos</i>; the default position is the center of the widget. If <i>delay</i> is specified, the test will wait for the specified amount of milliseconds before the press.</p>
<p>See also <a href="qtest.html#mouseRelease">QTest.mouseRelease</a>() and <a href="qtest.html#mouseClick">QTest.mouseClick</a>().</p>
<a name="//apple_ref/cpp/instm/QTest/mouseRelease" />
<h3 class="fn"><a name="mouseRelease" />QTest.mouseRelease (<a href="qwidget.html">QWidget</a>, <a href="qt.html#MouseButton-enum">Qt.MouseButton</a>, <a href="qt-keyboardmodifiers.html">Qt.KeyboardModifiers</a> <i>modifier</i> = 0, <a href="qpoint.html">QPoint</a> <i>pos</i> = QPoint(), int <i>delay</i> = -1)</h3><p>Simulates releasing a mouse <i>button</i> with an optional <i>modifier</i> on a <i>widget</i>. The position of the release is defined by <i>pos</i>; the default position is the center of the widget. If <i>delay</i> is specified, the test will wait for the specified amount of milliseconds before releasing the button.</p>
<p>See also <a href="qtest.html#mousePress">QTest.mousePress</a>() and <a href="qtest.html#mouseClick">QTest.mouseClick</a>().</p>
<a name="//apple_ref/cpp/instm/QTest/newRow" />
<h3 class="fn"><a name="qSleep" />QTest.qSleep (int)</h3><p>Sleeps for <i>ms</i> 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 <a href="qtest.html#qWait">qWait</a>() to do non-blocking sleeping.</p>
<p><i>ms</i> must be greater than 0.</p>
<p><b>Note:</b> The qSleep() function calls either <tt>nanosleep()</tt> on unix or <tt>Sleep()</tt> on windows, so the accuracy of time spent in qSleep() depends on the operating system.</p>
<p>Example:</p>
<pre> QTest.qSleep(250);</pre>
<p>See also <a href="qtest.html#qWait">qWait</a>().</p>
<a name="//apple_ref/cpp/clm/QTest/qWait" />
<h3 class="fn"><a name="qWait" />QTest.qWait (int)</h3><p>Waits for <i>ms</i> milliseconds. While waiting, events will be processed and your test will stay responsive to user interface events or network communication.</p>
<p>Example:</p>
<pre> int i = 0;
while (myNetworkServerNotResponding() && i++ < 50)
QTest.qWait(250);</pre>
<p>The code above will wait until the network server is responding for a maximum of about 12.5 seconds.</p>
<p>See also <a href="qtest.html#qSleep">QTest.qSleep</a>().</p>
<a name="//apple_ref/cpp/clm/QTest/qWaitForWindowShown" />
<h3 class="fn"><a name="qWaitForWindowShown" />bool QTest.qWaitForWindowShown (<a href="qwidget.html">QWidget</a>)</h3><p>Waits until the <i>window</i> 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.</p>
<p>Example:</p>
<pre> QWidget widget;
widget.show();
QTest.qWaitForWindowShown(&widget);</pre>
<p>This function was introduced in Qt 4.6.</p>
<a name="//apple_ref/cpp/instm/QTest/toHexRepresentation" />
<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt 4.7.3 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2010</td><td align="right" width="25%">Qt 4.6.2</td></tr></table></div></address></body></html>
|