1/**************************************************************************** 2** 3** Copyright (C) 2020 The Qt Company Ltd. 4** Contact: https://www.qt.io/licensing/ 5** 6** This file is part of the documentation of the Qt Toolkit. 7** 8** $QT_BEGIN_LICENSE:FDL$ 9** Commercial License Usage 10** Licensees holding valid commercial Qt licenses may use this file in 11** accordance with the commercial license agreement provided with the 12** Software or, alternatively, in accordance with the terms contained in 13** a written agreement between you and The Qt Company. For licensing terms 14** and conditions see https://www.qt.io/terms-conditions. For further 15** information use the contact form at https://www.qt.io/contact-us. 16** 17** GNU Free Documentation License Usage 18** Alternatively, this file may be used under the terms of the GNU Free 19** Documentation License version 1.3 as published by the Free Software 20** Foundation and appearing in the file included in the packaging of 21** this file. Please review the following information to ensure 22** the GNU Free Documentation License version 1.3 requirements 23** will be met: https://www.gnu.org/licenses/fdl-1.3.html. 24** $QT_END_LICENSE$ 25** 26****************************************************************************/ 27 28/*! 29 \namespace QTest 30 \inmodule QtTest 31 32 \brief The QTest namespace contains all the functions and 33 declarations that are related to Qt Test. 34 35 See the \l{Qt Test Overview} for information about how to write unit tests. 36*/ 37 38/*! \macro QVERIFY(condition) 39 40 \relates QTest 41 42 The QVERIFY() macro checks whether the \a condition is true or not. If it is 43 true, execution continues. If not, a failure is recorded in the test log 44 and the test won't be executed further. 45 46 You can use \l QVERIFY2() when it is practical and valuable to put additional 47 information into the test failure report. 48 49 \note This macro can only be used in a test function that is invoked 50 by the test framework. 51 52 For example, the following code shows this macro being used to verify that a 53 \l QSignalSpy object is valid: 54 55 \snippet code/src_qtestlib_qtestcase_snippet.cpp 0 56 57 For more information about the failure, use \c QCOMPARE(x, y) instead of 58 \c QVERIFY(x == y), because it reports both the expected and actual value 59 when the comparison fails. 60 61 \sa QCOMPARE(), QTRY_VERIFY(), QSignalSpy, QEXPECT_FAIL() 62*/ 63 64/*! \macro QVERIFY2(condition, message) 65 66 \relates QTest 67 68 The QVERIFY2() macro behaves exactly like QVERIFY(), except that it reports 69 a \a message when \a condition is false. The \a message is a plain C string. 70 71 The message can also be obtained from a function call that produces a plain 72 C string, such as qPrintable() applied to a QString, which may be built in 73 any of its usual ways, including applying \c {.args()} to format some data. 74 75 Example: 76 \snippet code/src_qtestlib_qtestcase.cpp 1 77 78 For example, if you have a file object and you are testing its \c open() 79 function, you might write a test with a statement like: 80 81 \snippet code/src_qtestlib_qtestcase.cpp 32 82 83 If this test fails, it will give no clue as to why the file failed to open: 84 85 \c {FAIL! : tst_QFile::open_write() 'opened' returned FALSE. ()} 86 87 If there is a more informative error message you could construct from the 88 values being tested, you can use \c QVERIFY2() to pass that message along 89 with your test condition, to provide a more informative message on failure: 90 91 \snippet code/src_qtestlib_qtestcase.cpp 33 92 93 If this branch is being tested in the Qt CI system, the above detailed 94 failure message will be inserted into the summary posted to the code-review 95 system: 96 97 \c {FAIL! : tst_QFile::open_write() 'opened' returned FALSE. 98 (open /tmp/qt.a3B42Cd: No space left on device)} 99 100 \sa QVERIFY(), QCOMPARE(), QEXPECT_FAIL() 101*/ 102 103/*! \macro QCOMPARE(actual, expected) 104 105 \relates QTest 106 107 The QCOMPARE() macro compares an \a actual value to an \a expected value 108 using the equality operator. If \a actual and \a expected match, execution 109 continues. If not, a failure is recorded in the test log and the test 110 function returns without attempting any later checks. 111 112 Always respect QCOMPARE() parameter semantics. The first parameter passed to 113 it should always be the actual value produced by the code-under-test, while 114 the second parameter should always be the expected value. When the values 115 don't match, QCOMPARE() prints them with the labels \e Actual and \e 116 Expected. If the parameter order is swapped, debugging a failing test can be 117 confusing and tests expecting zero may fail due to rounding errors. 118 119 When comparing floating-point types (\c float, \c double, and \c qfloat16), 120 \l qFuzzyCompare() is used for finite values. If qFuzzyIsNull() is true for 121 both values, they are also considered equal. Infinities match if they have 122 the same sign, and any NaN as actual value matches with any NaN as expected 123 value (even though NaN != NaN, even when they're identical). 124 125 QCOMPARE() tries to output the contents of the values if the comparison fails, 126 so it is visible from the test log why the comparison failed. 127 128 Example: 129 \snippet code/src_qtestlib_qtestcase.cpp 2 130 131 \note This macro can only be used in a test function that is invoked 132 by the test framework. 133 134 For your own classes, you can use \l QTest::toString() to format values for 135 outputting into the test log. 136 137 Example: 138 \snippet code/src_qtestlib_qtestcase_snippet.cpp 34 139 140 The return from \c toString() must be a \c {new char []}. That is, it shall 141 be released with \c delete[] (rather than \c free() or plain \c delete) once 142 the calling code is done with it. 143 144 \sa QVERIFY(), QTRY_COMPARE(), QTest::toString(), QEXPECT_FAIL() 145*/ 146 147/*! \macro QVERIFY_EXCEPTION_THROWN(expression, exceptiontype) 148 \since 5.3 149 150 \relates QTest 151 152 The QVERIFY_EXCEPTION_THROWN macro executes an \a expression and tries 153 to catch an exception thrown from the \a expression. If the \a expression 154 throws an exception and its type is the same as \a exceptiontype 155 or \a exceptiontype is substitutable with the type of thrown exception 156 (i.e. usually the type of thrown exception is publicly derived 157 from \a exceptiontype) then execution will be continued. If not-substitutable 158 type of exception is thrown or the \a expression doesn't throw an exception 159 at all, then a failure will be recorded in the test log and 160 the test won't be executed further. 161 162 \note This macro can only be used in a test function that is invoked 163 by the test framework. 164*/ 165 166/*! \macro QTRY_VERIFY_WITH_TIMEOUT(condition, timeout) 167 \since 5.0 168 169 \relates QTest 170 171 The QTRY_VERIFY_WITH_TIMEOUT() macro is similar to QVERIFY(), but checks the \a condition 172 repeatedly, until either the condition becomes true or the \a timeout (in milliseconds) is 173 reached. Between each evaluation, events will be processed. If the timeout 174 is reached, a failure is recorded in the test log and the test won't be 175 executed further. 176 177 \note This macro can only be used in a test function that is invoked 178 by the test framework. 179 180 \sa QTRY_VERIFY(), QTRY_VERIFY2_WITH_TIMEOUT(), QVERIFY(), QCOMPARE(), QTRY_COMPARE(), 181 QEXPECT_FAIL() 182*/ 183 184 185/*! \macro QTRY_VERIFY(condition) 186 \since 5.0 187 188 \relates QTest 189 190 Checks the \a condition by invoking QTRY_VERIFY_WITH_TIMEOUT() with a timeout of five seconds. 191 192 \note This macro can only be used in a test function that is invoked 193 by the test framework. 194 195 \sa QTRY_VERIFY_WITH_TIMEOUT(), QTRY_VERIFY2(), QVERIFY(), QCOMPARE(), QTRY_COMPARE(), 196 QEXPECT_FAIL() 197*/ 198 199/*! \macro QTRY_VERIFY2_WITH_TIMEOUT(condition, message, timeout) 200 \since 5.6 201 202 \relates QTest 203 204 The QTRY_VERIFY2_WITH_TIMEOUT macro is similar to QTRY_VERIFY_WITH_TIMEOUT() 205 except that it outputs a verbose \a message when \a condition is still false 206 after the specified \a timeout (in milliseconds). The \a message is a plain C string. 207 208 Example: 209 \code 210 QTRY_VERIFY2_WITH_TIMEOUT(list.size() > 2, QByteArray::number(list.size()).constData(), 10000); 211 \endcode 212 213 \note This macro can only be used in a test function that is invoked 214 by the test framework. 215 216 \sa QTRY_VERIFY(), QTRY_VERIFY_WITH_TIMEOUT(), QVERIFY(), QCOMPARE(), QTRY_COMPARE(), 217 QEXPECT_FAIL() 218*/ 219 220/*! \macro QTRY_VERIFY2(condition, message) 221 \since 5.6 222 223 \relates QTest 224 225 Checks the \a condition by invoking QTRY_VERIFY2_WITH_TIMEOUT() with a timeout 226 of five seconds. If \a condition is then still false, \a message is output. 227 The \a message is a plain C string. 228 229 Example: 230 \code 231 QTRY_VERIFY2_WITH_TIMEOUT(list.size() > 2, QByteArray::number(list.size()).constData()); 232 \endcode 233 234 \note This macro can only be used in a test function that is invoked 235 by the test framework. 236 237 \sa QTRY_VERIFY2_WITH_TIMEOUT(), QTRY_VERIFY2(), QVERIFY(), QCOMPARE(), QTRY_COMPARE(), 238 QEXPECT_FAIL() 239*/ 240 241/*! \macro QTRY_COMPARE_WITH_TIMEOUT(actual, expected, timeout) 242 \since 5.0 243 244 \relates QTest 245 246 The QTRY_COMPARE_WITH_TIMEOUT() macro is similar to QCOMPARE(), but performs the comparison 247 of the \a actual and \a expected values repeatedly, until either the two values 248 are equal or the \a timeout (in milliseconds) is reached. Between each comparison, events 249 will be processed. If the timeout is reached, a failure is recorded in the 250 test log and the test won't be executed further. 251 252 \note This macro can only be used in a test function that is invoked 253 by the test framework. 254 255 \sa QTRY_COMPARE(), QCOMPARE(), QVERIFY(), QTRY_VERIFY(), QEXPECT_FAIL() 256*/ 257 258/*! \macro QTRY_COMPARE(actual, expected) 259 \since 5.0 260 261 \relates QTest 262 263 Performs a comparison of the \a actual and \a expected values by 264 invoking QTRY_COMPARE_WITH_TIMEOUT() with a timeout of five seconds. 265 266 \note This macro can only be used in a test function that is invoked 267 by the test framework. 268 269 \sa QTRY_COMPARE_WITH_TIMEOUT(), QCOMPARE(), QVERIFY(), QTRY_VERIFY(), 270 QEXPECT_FAIL() 271*/ 272 273/*! \macro QFETCH(type, name) 274 275 \relates QTest 276 277 The fetch macro creates a local variable named \a name with the type \a type 278 on the stack. The \a name and \a type must match a column from the test's 279 data table. This is asserted and the test will abort if the assertion fails. 280 281 Assuming a test has the following data: 282 283 \snippet code/src_qtestlib_qtestcase.cpp 3 284 285 The test data has two elements, a QString called \c aString and an integer 286 called \c expected. To fetch these values in the actual test: 287 288 \snippet code/src_qtestlib_qtestcase.cpp 4 289 290 \c aString and \c expected are variables on the stack that are initialized with 291 the current test data. 292 293 \note This macro can only be used in a test function that is invoked 294 by the test framework. The test function must have a _data function. 295*/ 296 297/*! \macro QFETCH_GLOBAL(type, name) 298 299 \relates QTest 300 301 This macro fetches a variable named \a name with the type \a type from 302 a row in the global data table. The \a name and \a type must match a 303 column in the global data table. This is asserted and the test will abort 304 if the assertion fails. 305 306 Assuming a test has the following data: 307 308 \snippet code/src_qtestlib_qtestcase_snippet.cpp 30 309 310 The test's own data is a single number per row. In this case, 311 \c initTestCase_data() also supplies a locale per row. Therefore, 312 this test will be run with every combination of locale from the 313 latter and number from the former. Thus, with four rows in the 314 global table and three in the local, the test function is run for 315 12 distinct test-cases (4 * 3 = 12). 316 317 \snippet code/src_qtestlib_qtestcase_snippet.cpp 31 318 319 The locale is read from the global data table using QFETCH_GLOBAL(), 320 and the number is read from the local data table using QFETCH(). 321 322 \note This macro can only be used in test methods of a class with an 323 \c initTestCase_data() method. 324*/ 325 326/*! \macro QWARN(message) 327 328 \relates QTest 329 \threadsafe 330 331 Appends \a message as a warning to the test log. This macro can be used anywhere 332 in your tests. 333*/ 334 335/*! \macro QFAIL(message) 336 337 \relates QTest 338 339 This macro can be used to force a test failure. The test stops 340 executing and the failure \a message is appended to the test log. 341 342 \note This macro can only be used in a test function that is invoked 343 by the test framework. 344 345 Example: 346 347 \snippet code/src_qtestlib_qtestcase.cpp 5 348*/ 349 350/*! \macro QTEST(actual, testElement) 351 352 \relates QTest 353 354 QTEST() is a convenience macro for \l QCOMPARE() that compares 355 the value \a actual with the element \a testElement from the test's data. 356 If there is no such element, the test asserts. 357 358 Apart from that, QTEST() behaves exactly as \l QCOMPARE(). 359 360 Instead of writing: 361 362 \snippet code/src_qtestlib_qtestcase.cpp 6 363 364 you can write: 365 366 \snippet code/src_qtestlib_qtestcase.cpp 7 367 368 \sa QCOMPARE() 369*/ 370 371/*! \macro QSKIP(description) 372 373 \relates QTest 374 375 If called from a test function, the QSKIP() macro stops execution of the test 376 without adding a failure to the test log. You can use it to skip tests that 377 wouldn't make sense in the current configuration. For example, a test of font 378 rendering may call QSKIP() if the needed fonts are not installed on the test 379 system. 380 381 The text \a description is appended to the test log and should contain an 382 explanation of why the test couldn't be executed. 383 384 If the test is data-driven, each call to QSKIP() in the test function will 385 skip only the current row of test data, so an unconditional call to QSKIP() 386 will produce one skip message in the test log for each row of test data. 387 388 If called from an \c _data function, the QSKIP() macro will stop execution of 389 the \c _data function and will prevent execution of the associated test 390 function. This entirely omits a data-driven test. To omit individual rows, 391 make them conditional by using a simple \c{if (condition) newRow(...) << ...} 392 in the \c _data function, instead of using QSKIP() in the test function. 393 394 If called from \c initTestCase_data(), the QSKIP() macro will skip all test 395 and \c _data functions. If called from \c initTestCase() when there is no 396 \c initTestCase_data(), or when it only sets up one row, QSKIP() will 397 likewise skip the whole test. However, if \c initTestCase_data() contains 398 more than one row, then \c initTestCase() is called (followed by each test 399 and finally the wrap-up) once per row of it. Therefore, a call to QSKIP() in 400 \c initTestCase() will merely skip all test functions for the current row of 401 global data, set up by \c initTestCase_data(). 402 403 \note This macro can only be used in a test function or \c _data 404 function that is invoked by the test framework. 405 406 Example: 407 \snippet code/src_qtestlib_qtestcase.cpp 8 408 409 \section2 Skipping Known Bugs 410 411 If a test exposes a known bug that will not be fixed immediately, use the 412 QEXPECT_FAIL() macro to document the failure and reference the bug tracking 413 identifier for the known issue. When the test is run, expected failures will 414 be marked as XFAIL in the test output and will not be counted as failures 415 when setting the test program's return code. If an expected failure does 416 not occur, the XPASS (unexpected pass) will be reported in the test output 417 and will be counted as a test failure. 418 419 For known bugs, QEXPECT_FAIL() is better than QSKIP() because a developer 420 cannot fix the bug without an XPASS result reminding them that the test 421 needs to be updated too. If QSKIP() is used, there is no reminder to revise 422 or re-enable the test, without which subsequent regressions will not be 423 reported. 424 425 \sa QEXPECT_FAIL(), {Select Appropriate Mechanisms to Exclude Tests} 426*/ 427 428/*! \macro QEXPECT_FAIL(dataIndex, comment, mode) 429 430 \relates QTest 431 432 The QEXPECT_FAIL() macro marks the next \l QCOMPARE() or \l QVERIFY() as an 433 expected failure. Instead of adding a failure to the test log, an expected 434 failure will be reported. 435 436 If a \l QVERIFY() or \l QCOMPARE() is marked as an expected failure, 437 but passes instead, an unexpected pass (XPASS) is written to the test log. 438 439 The parameter \a dataIndex describes for which entry in the test data the 440 failure is expected. Pass an empty string (\c{""}) if the failure 441 is expected for all entries or if no test data exists. 442 443 \a comment will be appended to the test log for the expected failure. 444 445 \a mode is a \l QTest::TestFailMode and sets whether the test should 446 continue to execute or not. 447 448 \note This macro can only be used in a test function that is invoked 449 by the test framework. 450 451 Example 1: 452 \snippet code/src_qtestlib_qtestcase.cpp 9 453 454 In the example above, an expected fail will be written into the test output 455 if the variable \c i is not 42. If the variable \c i is 42, an unexpected pass 456 is written instead. The QEXPECT_FAIL() has no influence on the second QCOMPARE() 457 statement in the example. 458 459 Example 2: 460 \snippet code/src_qtestlib_qtestcase.cpp 10 461 462 The above testfunction will not continue executing for the test data 463 entry \c{data27}. 464 465 \sa QTest::TestFailMode, QVERIFY(), QCOMPARE() 466*/ 467 468/*! \macro QFINDTESTDATA(filename) 469 \since 5.0 470 471 \relates QTest 472 473 Returns a QString for the testdata file referred to by \a filename, or an 474 empty QString if the testdata file could not be found. 475 476 This macro allows the test to load data from an external file without 477 hardcoding an absolute filename into the test, or using relative paths 478 which may be error prone. 479 480 The returned path will be the first path from the following list which 481 resolves to an existing file or directory: 482 483 \list 484 \li \a filename relative to QCoreApplication::applicationDirPath() 485 (only if a QCoreApplication or QApplication object has been created). 486 \li \a filename relative to the test's standard install directory 487 (QLibraryInfo::TestsPath with the lowercased testcase name appended). 488 \li \a filename relative to the directory containing the source file from which 489 QFINDTESTDATA is invoked. 490 \endlist 491 492 If the named file/directory does not exist at any of these locations, 493 a warning is printed to the test log. 494 495 For example, in this code: 496 \snippet code/src_qtestlib_qtestcase_snippet.cpp 26 497 498 The testdata file will be resolved as the first existing file from: 499 500 \list 501 \li \c{/home/user/build/myxmlparser/tests/tst_myxmlparser/testxml/simple1.xml} 502 \li \c{/usr/local/Qt-5.0.0/tests/tst_myxmlparser/testxml/simple1.xml} 503 \li \c{/home/user/sources/myxmlparser/tests/tst_myxmlparser/testxml/simple1.xml} 504 \endlist 505 506 This allows the test to find its testdata regardless of whether the 507 test has been installed, and regardless of whether the test's build tree 508 is equal to the test's source tree. 509 510 \note reliable detection of testdata from the source directory requires 511 either that qmake is used, or the \c{QT_TESTCASE_BUILDDIR} macro is defined to 512 point to the working directory from which the compiler is invoked, or only 513 absolute paths to the source files are passed to the compiler. Otherwise, the 514 absolute path of the source directory cannot be determined. 515 516 \note For tests that use the \l QTEST_APPLESS_MAIN() macro to generate a 517 \c{main()} function, \c{QFINDTESTDATA} will not attempt to find test data 518 relative to QCoreApplication::applicationDirPath(). In practice, this means that 519 tests using \c{QTEST_APPLESS_MAIN()} will fail to find their test data 520 if run from a shadow build tree. 521*/ 522 523/*! \macro QTEST_MAIN(TestClass) 524 525 \relates QTest 526 527 Implements a main() function that instantiates an application object and 528 the \a TestClass, and executes all tests in the order they were defined. 529 Use this macro to build stand-alone executables. 530 531 If \c QT_WIDGETS_LIB is defined, the application object will be a QApplication, 532 if \c QT_GUI_LIB is defined, the application object will be a QGuiApplication, 533 otherwise it will be a QCoreApplication. If qmake is used and the configuration 534 includes \c{QT += widgets}, then \c QT_WIDGETS_LIB will be defined automatically. 535 Similarly, if qmake is used and the configuration includes \c{QT += gui}, then 536 \c QT_GUI_LIB will be defined automatically. 537 538 \note On platforms that have keypad navigation enabled by default, 539 this macro will forcefully disable it if \c QT_WIDGETS_LIB is defined. This is done 540 to simplify the usage of key events when writing autotests. If you wish to write a 541 test case that uses keypad navigation, you should enable it either in the 542 \c {initTestCase()} or \c {init()} functions of your test case by calling 543 \l {QApplication::setNavigationMode()}. 544 545 Example: 546 \snippet code/src_qtestlib_qtestcase.cpp 11 547 548 \sa QTEST_APPLESS_MAIN(), QTEST_GUILESS_MAIN(), QTest::qExec(), 549 QApplication::setNavigationMode() 550*/ 551 552/*! \macro QTEST_APPLESS_MAIN(TestClass) 553 554 \relates QTest 555 556 Implements a main() function that executes all tests in \a TestClass. 557 558 Behaves like \l QTEST_MAIN(), but doesn't instantiate a QApplication 559 object. Use this macro for really simple stand-alone non-GUI tests. 560 561 \sa QTEST_MAIN() 562*/ 563 564/*! \macro QTEST_GUILESS_MAIN(TestClass) 565 \since 5.0 566 567 \relates QTest 568 569 Implements a main() function that instantiates a QCoreApplication object 570 and the \a TestClass, and executes all tests in the order they were 571 defined. Use this macro to build stand-alone executables. 572 573 Behaves like \l QTEST_MAIN(), but instantiates a QCoreApplication instead 574 of the QApplication object. Use this macro if your test case doesn't need 575 functionality offered by QApplication, but the event loop is still necessary. 576 577 \sa QTEST_MAIN() 578*/ 579 580/*! 581 \macro QBENCHMARK 582 583 \relates QTest 584 585 This macro is used to measure the performance of code within a test. 586 The code to be benchmarked is contained within a code block following 587 this macro. 588 589 For example: 590 591 \snippet code/src_qtestlib_qtestcase.cpp 27 592 593 \sa {Qt Test Overview#Creating a Benchmark}{Creating a Benchmark}, 594 {Chapter 5: Writing a Benchmark}{Writing a Benchmark} 595*/ 596 597/*! 598 \macro QBENCHMARK_ONCE 599 \since 4.6 600 601 \relates QTest 602 603 \brief The QBENCHMARK_ONCE macro is for measuring performance of a 604 code block by running it once. 605 606 This macro is used to measure the performance of code within a test. 607 The code to be benchmarked is contained within a code block following 608 this macro. 609 610 Unlike QBENCHMARK, the contents of the contained code block is only run 611 once. The elapsed time will be reported as "0" if it's to short to 612 be measured by the selected backend. (Use) 613 614 \sa {Qt Test Overview#Creating a Benchmark}{Creating a Benchmark}, 615 {Chapter 5: Writing a Benchmark}{Writing a Benchmark} 616*/ 617 618/*! \enum QTest::TestFailMode 619 620 This enum describes the modes for handling an expected failure of the 621 \l QVERIFY() or \l QCOMPARE() macros. 622 623 \value Abort Aborts the execution of the test. Use this mode when it 624 doesn't make sense to execute the test any further after the 625 expected failure. 626 627 \value Continue Continues execution of the test after the expected failure. 628 629 \sa QEXPECT_FAIL() 630*/ 631 632/*! \enum QTest::KeyAction 633 634 This enum describes possible actions for key handling. 635 636 \value Press The key is pressed. 637 \value Release The key is released. 638 \value Click The key is clicked (pressed and released). 639 \value Shortcut A shortcut is activated. This value has been added in Qt 5.6. 640*/ 641 642/*! \enum QTest::MouseAction 643 644 This enum describes possible actions for mouse handling. 645 646 \value MousePress A mouse button is pressed. 647 \value MouseRelease A mouse button is released. 648 \value MouseClick A mouse button is clicked (pressed and released). 649 \value MouseDClick A mouse button is double clicked (pressed and released twice). 650 \value MouseMove The mouse pointer has moved. 651*/ 652 653/*! \fn void QTest::keyClick(QWidget *widget, Qt::Key key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) 654 655 Simulates clicking of \a key with an optional \a modifier on a \a widget. 656 If \a delay is larger than 0, the test will wait for \a delay milliseconds 657 before clicking the key. 658 659 Examples: 660 \snippet code/src_qtestlib_qtestcase_snippet.cpp 14 661 662 The first example above simulates clicking the \c escape key on \c 663 myWidget without any keyboard modifiers and without delay. The 664 second example simulates clicking \c shift-escape on \c myWidget 665 following a 200 ms delay of the test. 666 667 \sa QTest::keyClicks() 668*/ 669 670/*! \fn void QTest::keyClick(QWidget *widget, char key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) 671 \overload 672 673 Simulates clicking of \a key with an optional \a modifier on a \a widget. 674 If \a delay is larger than 0, the test will wait for \a delay milliseconds 675 before clicking the key. 676 677 Example: 678 \snippet code/src_qtestlib_qtestcase_snippet.cpp 13 679 680 The example above simulates clicking \c a on \c myWidget without 681 any keyboard modifiers and without delay of the test. 682 683 \sa QTest::keyClicks() 684*/ 685 686/*! \fn void QTest::keySequence(QWidget *widget, const QKeySequence &keySequence) 687 \overload 688 \since 5.10 689 690 Simulates typing of \a keySequence into a \a widget. 691 692 \sa QTest::keyClick(), QTest::keyClicks() 693*/ 694 695/*! \fn void QTest::keyClick(QWindow *window, Qt::Key key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) 696 \overload 697 \since 5.0 698 699 Simulates clicking of \a key with an optional \a modifier on a \a window. 700 If \a delay is larger than 0, the test will wait for \a delay milliseconds 701 before clicking the key. 702 703 Examples: 704 \snippet code/src_qtestlib_qtestcase_snippet.cpp 29 705 706 The first example above simulates clicking the \c escape key on \c 707 myWindow without any keyboard modifiers and without delay. The 708 second example simulates clicking \c shift-escape on \c myWindow 709 following a 200 ms delay of the test. 710 711 \sa QTest::keyClicks() 712*/ 713 714/*! \fn void QTest::keyClick(QWindow *window, char key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) 715 \overload 716 \since 5.0 717 718 Simulates clicking of \a key with an optional \a modifier on a \a window. 719 If \a delay is larger than 0, the test will wait for \a delay milliseconds 720 before clicking the key. 721 722 Example: 723 \snippet code/src_qtestlib_qtestcase_snippet.cpp 28 724 725 The example above simulates clicking \c a on \c myWindow without 726 any keyboard modifiers and without delay of the test. 727 728 \sa QTest::keyClicks() 729*/ 730 731/*! \fn void QTest::keySequence(QWindow *window, const QKeySequence &keySequence) 732 \overload 733 \since 5.10 734 735 Simulates typing of \a keySequence into a \a window. 736 737 \sa QTest::keyClick(), QTest::keyClicks() 738*/ 739 740/*! \fn void QTest::keyEvent(KeyAction action, QWidget *widget, Qt::Key key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) 741 742 Sends a Qt key event to \a widget with the given \a key and an associated \a action. 743 Optionally, a keyboard \a modifier can be specified, as well as a \a delay 744 (in milliseconds) of the test before sending the event. 745*/ 746 747/*! \fn void QTest::keyEvent(KeyAction action, QWidget *widget, char ascii, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) 748 \overload 749 750 Sends a Qt key event to \a widget with the given key \a ascii and an associated \a action. 751 Optionally, a keyboard \a modifier can be specified, as well as a \a delay 752 (in milliseconds) of the test before sending the event. 753*/ 754 755/*! \fn void QTest::keyEvent(KeyAction action, QWindow *window, Qt::Key key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) 756 \overload 757 \since 5.0 758 759 Sends a Qt key event to \a window with the given \a key and an associated \a action. 760 Optionally, a keyboard \a modifier can be specified, as well as a \a delay 761 (in milliseconds) of the test before sending the event. 762*/ 763 764/*! \fn void QTest::keyEvent(KeyAction action, QWindow *window, char ascii, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) 765 \overload 766 \since 5.0 767 768 Sends a Qt key event to \a window with the given key \a ascii and an associated \a action. 769 Optionally, a keyboard \a modifier can be specified, as well as a \a delay 770 (in milliseconds) of the test before sending the event. 771*/ 772 773/*! \fn void QTest::keyPress(QWidget *widget, Qt::Key key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) 774 775 Simulates pressing a \a key with an optional \a modifier on a \a widget. If \a delay 776 is larger than 0, the test will wait for \a delay milliseconds before pressing the key. 777 778 \note At some point you should release the key using \l keyRelease(). 779 780 \sa QTest::keyRelease(), QTest::keyClick() 781*/ 782 783/*! \fn void QTest::keyPress(QWidget *widget, char key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) 784 \overload 785 786 Simulates pressing a \a key with an optional \a modifier on a \a widget. 787 If \a delay is larger than 0, the test will wait for \a delay milliseconds 788 before pressing the key. 789 790 \note At some point you should release the key using \l keyRelease(). 791 792 \sa QTest::keyRelease(), QTest::keyClick() 793*/ 794 795/*! \fn void QTest::keyPress(QWindow *window, Qt::Key key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) 796 \overload 797 \since 5.0 798 799 Simulates pressing a \a key with an optional \a modifier on a \a window. If \a delay 800 is larger than 0, the test will wait for \a delay milliseconds before pressing the key. 801 802 \note At some point you should release the key using \l keyRelease(). 803 804 \sa QTest::keyRelease(), QTest::keyClick() 805*/ 806 807/*! \fn void QTest::keyPress(QWindow *window, char key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) 808 \overload 809 \since 5.0 810 811 Simulates pressing a \a key with an optional \a modifier on a \a window. 812 If \a delay is larger than 0, the test will wait for \a delay milliseconds 813 before pressing the key. 814 815 \note At some point you should release the key using \l keyRelease(). 816 817 \sa QTest::keyRelease(), QTest::keyClick() 818*/ 819 820/*! \fn void QTest::keyRelease(QWidget *widget, Qt::Key key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) 821 822 Simulates releasing a \a key with an optional \a modifier on a \a widget. 823 If \a delay is larger than 0, the test will wait for \a delay milliseconds 824 before releasing the key. 825 826 \sa QTest::keyPress(), QTest::keyClick() 827*/ 828 829/*! \fn void QTest::keyRelease(QWidget *widget, char key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) 830 \overload 831 832 Simulates releasing a \a key with an optional \a modifier on a \a widget. 833 If \a delay is larger than 0, the test will wait for \a delay milliseconds 834 before releasing the key. 835 836 \sa QTest::keyClick() 837*/ 838 839/*! \fn void QTest::keyRelease(QWindow *window, Qt::Key key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) 840 \overload 841 \since 5.0 842 843 Simulates releasing a \a key with an optional \a modifier on a \a window. 844 If \a delay is larger than 0, the test will wait for \a delay milliseconds 845 before releasing the key. 846 847 \sa QTest::keyPress(), QTest::keyClick() 848*/ 849 850/*! \fn void QTest::keyRelease(QWindow *window, char key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) 851 \overload 852 \since 5.0 853 854 Simulates releasing a \a key with an optional \a modifier on a \a window. 855 If \a delay is larger than 0, the test will wait for \a delay milliseconds 856 before releasing the key. 857 858 \sa QTest::keyClick() 859*/ 860 861/*! \fn void QTest::keyClicks(QWidget *widget, const QString &sequence, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) 862 863 Simulates clicking a \a sequence of keys on a \a 864 widget. Optionally, a keyboard \a modifier can be specified as 865 well as a \a delay (in milliseconds) of the test before each key 866 click. 867 868 Example: 869 \snippet code/src_qtestlib_qtestcase_snippet.cpp 15 870 871 The example above simulates clicking the sequence of keys 872 representing "hello world" on \c myWidget without any keyboard 873 modifiers and without delay of the test. 874 875 \sa QTest::keyClick() 876*/ 877 878/*! \fn void QTest::mousePress(QWidget *widget, Qt::MouseButton button, Qt::KeyboardModifiers modifier = 0, QPoint pos = QPoint(), int delay=-1) 879 880 Simulates pressing a mouse \a button with an optional \a modifier 881 on a \a widget. The position is defined by \a pos; the default 882 position is the center of the widget. If \a delay is specified, 883 the test will wait for the specified amount of milliseconds before 884 the press. 885 886 \sa QTest::mouseRelease(), QTest::mouseClick() 887*/ 888 889/*! \fn void QTest::mousePress(QWindow *window, Qt::MouseButton button, Qt::KeyboardModifiers stateKey = 0, QPoint pos = QPoint(), int delay=-1) 890 \overload 891 \since 5.0 892 893 Simulates pressing a mouse \a button with an optional \a stateKey modifier 894 on a \a window. The position is defined by \a pos; the default 895 position is the center of the window. If \a delay is specified, 896 the test will wait for the specified amount of milliseconds before 897 the press. 898 899 \sa QTest::mouseRelease(), QTest::mouseClick() 900*/ 901 902/*! \fn void QTest::mouseRelease(QWidget *widget, Qt::MouseButton button, Qt::KeyboardModifiers modifier = 0, QPoint pos = QPoint(), int delay=-1) 903 904 Simulates releasing a mouse \a button with an optional \a modifier 905 on a \a widget. The position of the release is defined by \a pos; 906 the default position is the center of the widget. If \a delay is 907 specified, the test will wait for the specified amount of 908 milliseconds before releasing the button. 909 910 \sa QTest::mousePress(), QTest::mouseClick() 911*/ 912 913/*! \fn void QTest::mouseRelease(QWindow *window, Qt::MouseButton button, Qt::KeyboardModifiers stateKey = 0, QPoint pos = QPoint(), int delay=-1) 914 \overload 915 \since 5.0 916 917 Simulates releasing a mouse \a button with an optional \a stateKey modifier 918 on a \a window. The position of the release is defined by \a pos; 919 the default position is the center of the window. If \a delay is 920 specified, the test will wait for the specified amount of 921 milliseconds before releasing the button. 922 923 \sa QTest::mousePress(), QTest::mouseClick() 924*/ 925 926/*! \fn void QTest::mouseClick(QWidget *widget, Qt::MouseButton button, Qt::KeyboardModifiers modifier = 0, QPoint pos = QPoint(), int delay=-1) 927 928 Simulates clicking a mouse \a button with an optional \a modifier 929 on a \a widget. The position of the click is defined by \a pos; 930 the default position is the center of the widget. If \a delay is 931 specified, the test will wait for the specified amount of 932 milliseconds before pressing and before releasing the button. 933 934 \sa QTest::mousePress(), QTest::mouseRelease() 935*/ 936 937/*! \fn void QTest::mouseClick(QWindow *window, Qt::MouseButton button, Qt::KeyboardModifiers stateKey = 0, QPoint pos = QPoint(), int delay=-1) 938 \overload 939 \since 5.0 940 941 Simulates clicking a mouse \a button with an optional \a stateKey modifier 942 on a \a window. The position of the click is defined by \a pos; 943 the default position is the center of the window. If \a delay is 944 specified, the test will wait for the specified amount of 945 milliseconds before pressing and before releasing the button. 946 947 \sa QTest::mousePress(), QTest::mouseRelease() 948*/ 949 950/*! \fn void QTest::mouseDClick(QWidget *widget, Qt::MouseButton button, Qt::KeyboardModifiers modifier = 0, QPoint pos = QPoint(), int delay=-1) 951 952 Simulates double clicking a mouse \a button with an optional \a 953 modifier on a \a widget. The position of the click is defined by 954 \a pos; the default position is the center of the widget. If \a 955 delay is specified, the test will wait for the specified amount of 956 milliseconds before each press and release. 957 958 \sa QTest::mouseClick() 959*/ 960 961/*! \fn void QTest::mouseDClick(QWindow *window, Qt::MouseButton button, Qt::KeyboardModifiers stateKey = 0, QPoint pos = QPoint(), int delay=-1) 962 \overload 963 \since 5.0 964 965 Simulates double clicking a mouse \a button with an optional \a stateKey 966 modifier on a \a window. The position of the click is defined by 967 \a pos; the default position is the center of the window. If \a 968 delay is specified, the test will wait for the specified amount of 969 milliseconds before each press and release. 970 971 \sa QTest::mouseClick() 972*/ 973 974/*! \fn void QTest::mouseMove(QWidget *widget, QPoint pos = QPoint(), int delay=-1) 975 976 Moves the mouse pointer to a \a widget. If \a pos is not 977 specified, the mouse pointer moves to the center of the widget. If 978 a \a delay (in milliseconds) is given, the test will wait before 979 moving the mouse pointer. 980*/ 981 982/*! \fn void QTest::mouseMove(QWindow *window, QPoint pos = QPoint(), int delay=-1) 983 \overload 984 \since 5.0 985 986 Moves the mouse pointer to a \a window. If \a pos is not 987 specified, the mouse pointer moves to the center of the window. If 988 a \a delay (in milliseconds) is given, the test will wait before 989 moving the mouse pointer. 990*/ 991 992/*! 993 \fn template <typename T1, typename T2> char *QTest::toString(const QPair<T1, T2> &pair) 994 \overload 995 \since 5.11 996 Returns a textual representation of the \a pair. 997*/ 998 999/*! 1000 \fn template <typename T1, typename T2> char *QTest::toString(const std::pair<T1, T2> &pair) 1001 \overload 1002 \since 5.11 1003 Returns a textual representation of the \a pair. 1004*/ 1005 1006/*! 1007 \fn char *QTest::toString(const QVector2D &v) 1008 \overload 1009 \since 5.11 1010 Returns a textual representation of the 2D vector \a v. 1011*/ 1012 1013/*! 1014 \fn char *QTest::toString(const QVector3D &v) 1015 \overload 1016 \since 5.11 1017 Returns a textual representation of the 3D vector \a v. 1018*/ 1019 1020/*! 1021 \fn char *QTest::toString(const QVector4D &v) 1022 \overload 1023 \since 5.11 1024 Returns a textual representation of the 4D vector \a v. 1025*/ 1026 1027/*! 1028 \fn template<typename T> char *QTest::toString(const T &value) 1029 1030 Returns a textual representation of \a value. This function is used by 1031 \l QCOMPARE() to output verbose information in case of a test failure. 1032 1033 You can add specializations or overloads of this function to your test to enable 1034 verbose output. 1035 1036 \note Starting with Qt 5.5, you should prefer to provide a toString() function 1037 in the type's namespace instead of specializing this template. 1038 If your code needs to continue to work with the QTestLib from Qt 5.4 or 1039 earlier, you need to continue to use specialization. 1040 1041 \note The caller of toString() must delete the returned data 1042 using \c{delete[]}. Your implementation should return a string 1043 created with \c{new[]} or qstrdup(). The easiest way to do so is to 1044 create a QByteArray or QString and call QTest::toString() on it 1045 (see second example below). 1046 1047 Example for specializing (Qt ≤ 5.4): 1048 1049 \snippet code/src_qtestlib_qtestcase_snippet.cpp 16 1050 1051 The example above defines a toString() specialization for a class 1052 called \c MyPoint. Whenever a comparison of two instances of \c 1053 MyPoint fails, \l QCOMPARE() will call this function to output the 1054 contents of \c MyPoint to the test log. 1055 1056 Same example, but with overloading (Qt ≥ 5.5): 1057 1058 \snippet code/src_qtestlib_qtestcase_snippet.cpp toString-overload 1059 1060 \sa QCOMPARE() 1061*/ 1062 1063/*! 1064 \fn char *QTest::toString(const QLatin1String &string) 1065 \overload 1066 1067 Returns a textual representation of the given \a string. 1068*/ 1069 1070/*! 1071 \fn char *QTest::toString(std::nullptr_t) 1072 \overload 1073 \since 5.8 1074 1075 Returns a string containing \nullptr. 1076*/ 1077 1078/*! 1079 \fn char *QTest::toString(const QStringView &string) 1080 \overload 1081 \since 5.11 1082 1083 Returns a textual representation of the given \a string. 1084*/ 1085 1086/*! 1087 \fn char *QTest::toString(const QUuid &uuid) 1088 \overload 1089 \since 5.11 1090 1091 Returns a textual representation of the given \a uuid. 1092*/ 1093 1094/*! 1095 \fn char *QTest::toString(const QString &string) 1096 \overload 1097 1098 Returns a textual representation of the given \a string. 1099*/ 1100 1101/*! 1102 \fn char *QTest::toString(const QByteArray &ba) 1103 \overload 1104 1105 Returns a textual representation of the byte array \a ba. 1106 1107 \sa QTest::toHexRepresentation() 1108*/ 1109 1110/*! 1111 \fn char *QTest::toString(const QCborError &c) 1112 \overload 1113 \since 5.12 1114 1115 Returns a textual representation of the given CBOR error \a c. 1116*/ 1117 1118/*! 1119 \fn template <class... Types> char *QTest::toString(const std::tuple<Types...> &tuple) 1120 \overload 1121 \since 5.12 1122 1123 Returns a textual representation of the given \a tuple. 1124*/ 1125 1126/*! 1127 \fn char *QTest::toString(const QTime &time) 1128 \overload 1129 1130 Returns a textual representation of the given \a time. 1131*/ 1132 1133/*! 1134 \fn char *QTest::toString(const QDate &date) 1135 \overload 1136 1137 Returns a textual representation of the given \a date. 1138*/ 1139 1140/*! 1141 \fn char *QTest::toString(const QDateTime &dateTime) 1142 \overload 1143 1144 Returns a textual representation of the date and time specified by 1145 \a dateTime. 1146*/ 1147 1148/*! 1149 \fn char *QTest::toString(const QChar &character) 1150 \overload 1151 1152 Returns a textual representation of the given \a character. 1153*/ 1154 1155/*! 1156 \fn char *QTest::toString(const QPoint &point) 1157 \overload 1158 1159 Returns a textual representation of the given \a point. 1160*/ 1161 1162/*! 1163 \fn char *QTest::toString(const QSize &size) 1164 \overload 1165 1166 Returns a textual representation of the given \a size. 1167*/ 1168 1169/*! 1170 \fn char *QTest::toString(const QRect &rectangle) 1171 \overload 1172 1173 Returns a textual representation of the given \a rectangle. 1174*/ 1175 1176/*! 1177 \fn char *QTest::toString(const QUrl &url) 1178 \since 4.4 1179 \overload 1180 1181 Returns a textual representation of the given \a url. 1182*/ 1183 1184/*! 1185 \fn char *QTest::toString(const QPointF &point) 1186 \overload 1187 1188 Returns a textual representation of the given \a point. 1189*/ 1190 1191/*! 1192 \fn char *QTest::toString(const QSizeF &size) 1193 \overload 1194 1195 Returns a textual representation of the given \a size. 1196*/ 1197 1198/*! 1199 \fn char *QTest::toString(const QRectF &rectangle) 1200 \overload 1201 1202 Returns a textual representation of the given \a rectangle. 1203*/ 1204 1205/*! 1206 \fn char *QTest::toString(const QVariant &variant) 1207 \overload 1208 1209 Returns a textual representation of the given \a variant. 1210*/ 1211 1212/*! 1213 \fn char *QTest::toString(QSizePolicy::ControlType ct) 1214 \overload 1215 \since 5.5 1216 1217 Returns a textual representation of control type \a ct. 1218*/ 1219 1220/*! 1221 \fn char *QTest::toString(QSizePolicy::ControlTypes cts) 1222 \overload 1223 \since 5.5 1224 1225 Returns a textual representation of control types \a cts. 1226*/ 1227 1228/*! 1229 \fn char *QTest::toString(QSizePolicy::Policy p) 1230 \overload 1231 \since 5.5 1232 1233 Returns a textual representation of policy \a p. 1234*/ 1235 1236/*! 1237 \fn char *QTest::toString(QSizePolicy sp) 1238 \overload 1239 \since 5.5 1240 1241 Returns a textual representation of size policy \a sp. 1242*/ 1243 1244/*! 1245 \fn template <typename Tuple, int... I> char *QTest::toString(const Tuple &tuple, QtPrivate::IndexesList<I...> ) 1246 \internal 1247 \since 5.12 1248*/ 1249 1250/*! 1251 \fn QTouchDevice *QTest::createTouchDevice(QTouchDevice::DeviceType devType = QTouchDevice::TouchScreen) 1252 \since 5.8 1253 1254 Creates a dummy touch device of type \a devType for simulation of touch events. 1255 1256 The touch device will be registered with the QPA window system interface, 1257 and deleted automatically when the QCoreApplication is deleted. So you 1258 should typically use createTouchDevice() to initialize a QTouchDevice 1259 member variable in your test case class, and use the same instance for all tests. 1260 1261 \sa QTest::QTouchEventSequence, touchEvent() 1262*/ 1263 1264/*! 1265 \class QTest::QTouchEventSequence 1266 \inmodule QtTest 1267 \since 4.6 1268 1269 \brief The QTouchEventSequence class is used to simulate a sequence of touch events. 1270 1271 To simulate a sequence of touch events on a specific device for a window or widget, call 1272 QTest::touchEvent to create a QTouchEventSequence instance. Add touch events to 1273 the sequence by calling press(), move(), release() and stationary(), and let the 1274 instance run out of scope to commit the sequence to the event system. 1275 1276 Example: 1277 \snippet code/src_qtestlib_qtestcase_snippet.cpp 25 1278*/ 1279 1280/*! 1281 \fn QTest::QTouchEventSequence::~QTouchEventSequence() 1282 1283 Commits this sequence of touch events, unless autoCommit was disabled, and frees allocated resources. 1284*/ 1285 1286/*! 1287 \fn void QTest::QTouchEventSequence::commit(bool processEvents) 1288 1289 Commits this sequence of touch events to the event system. Normally there is no need to call this 1290 function because it is called from the destructor. However, if autoCommit is disabled, the events 1291 only get committed upon explicitly calling this function. 1292 1293 In special cases tests may want to disable the processing of the events. This can be achieved by 1294 setting \a processEvents to false. This results in merely queuing the events, the event loop will 1295 not be forced to process them. 1296*/ 1297 1298/*! 1299 \fn QTouchEventSequence &QTest::QTouchEventSequence::press(int touchId, const QPoint &pt, QWindow *window) 1300 \since 5.0 1301 1302 Adds a press event for touchpoint \a touchId at position \a pt to this sequence and returns 1303 a reference to this QTouchEventSequence. 1304 1305 The position \a pt is interpreted as relative to \a window. If \a window is the null pointer, then 1306 \a pt is interpreted as relative to the window provided when instantiating this QTouchEventSequence. 1307 1308 Simulates that the user pressed the touch screen or pad with the finger identified by \a touchId. 1309*/ 1310 1311/*! 1312 \fn QTouchEventSequence &QTest::QTouchEventSequence::press(int touchId, const QPoint &pt, QWidget *widget) 1313 1314 Adds a press event for touchpoint \a touchId at position \a pt to this sequence and returns 1315 a reference to this QTouchEventSequence. 1316 1317 The position \a pt is interpreted as relative to \a widget. If \a widget is the null pointer, then 1318 \a pt is interpreted as relative to the widget provided when instantiating this QTouchEventSequence. 1319 1320 Simulates that the user pressed the touch screen or pad with the finger identified by \a touchId. 1321*/ 1322 1323/*! 1324 \fn QTouchEventSequence &QTest::QTouchEventSequence::move(int touchId, const QPoint &pt, QWindow *window) 1325 \since 5.0 1326 1327 Adds a move event for touchpoint \a touchId at position \a pt to this sequence and returns 1328 a reference to this QTouchEventSequence. 1329 1330 The position \a pt is interpreted as relative to \a window. If \a window is the null pointer, then 1331 \a pt is interpreted as relative to the window provided when instantiating this QTouchEventSequence. 1332 1333 Simulates that the user moved the finger identified by \a touchId. 1334*/ 1335 1336/*! 1337 \fn QTouchEventSequence &QTest::QTouchEventSequence::move(int touchId, const QPoint &pt, QWidget *widget) 1338 1339 Adds a move event for touchpoint \a touchId at position \a pt to this sequence and returns 1340 a reference to this QTouchEventSequence. 1341 1342 The position \a pt is interpreted as relative to \a widget. If \a widget is the null pointer, then 1343 \a pt is interpreted as relative to the widget provided when instantiating this QTouchEventSequence. 1344 1345 Simulates that the user moved the finger identified by \a touchId. 1346*/ 1347 1348/*! 1349 \fn QTouchEventSequence &QTest::QTouchEventSequence::release(int touchId, const QPoint &pt, QWindow *window) 1350 \since 5.0 1351 1352 Adds a release event for touchpoint \a touchId at position \a pt to this sequence and returns 1353 a reference to this QTouchEventSequence. 1354 1355 The position \a pt is interpreted as relative to \a window. If \a window is the null pointer, then 1356 \a pt is interpreted as relative to the window provided when instantiating this QTouchEventSequence. 1357 1358 Simulates that the user lifted the finger identified by \a touchId. 1359*/ 1360 1361/*! 1362 \fn QTouchEventSequence &QTest::QTouchEventSequence::release(int touchId, const QPoint &pt, QWidget *widget) 1363 1364 Adds a release event for touchpoint \a touchId at position \a pt to this sequence and returns 1365 a reference to this QTouchEventSequence. 1366 1367 The position \a pt is interpreted as relative to \a widget. If \a widget is the null pointer, then 1368 \a pt is interpreted as relative to the widget provided when instantiating this QTouchEventSequence. 1369 1370 Simulates that the user lifted the finger identified by \a touchId. 1371*/ 1372 1373/*! 1374 \fn QTouchEventSequence &QTest::QTouchEventSequence::stationary(int touchId) 1375 1376 Adds a stationary event for touchpoint \a touchId to this sequence and returns 1377 a reference to this QTouchEventSequence. 1378 1379 Simulates that the user did not move the finger identified by \a touchId. 1380*/ 1381 1382/*! 1383 \fn QTouchEventSequence QTest::touchEvent(QWindow *window, QTouchDevice *device, bool autoCommit) 1384 \since 5.0 1385 1386 Creates and returns a QTouchEventSequence for the \a device to 1387 simulate events for \a window. 1388 1389 When adding touch events to the sequence, \a window will also be used to translate 1390 the position provided to screen coordinates, unless another window is provided in the 1391 respective calls to press(), move() etc. 1392 1393 The touch events are committed to the event system when the destructor of the 1394 QTouchEventSequence is called (ie when the object returned runs out of scope), unless 1395 \a autoCommit is set to false. When \a autoCommit is false, commit() has to be called 1396 manually. 1397 1398 \l createTouchDevice() can be called to create a test touch device for use with this 1399 function. 1400*/ 1401 1402/*! 1403 \fn QTouchEventSequence QTest::touchEvent(QWidget *widget, QTouchDevice *device, bool autoCommit) 1404 1405 Creates and returns a QTouchEventSequence for the \a device to 1406 simulate events for \a widget. 1407 1408 When adding touch events to the sequence, \a widget will also be used to translate 1409 the position provided to screen coordinates, unless another widget is provided in the 1410 respective calls to press(), move() etc. 1411 1412 The touch events are committed to the event system when the destructor of the 1413 QTouchEventSequence is called (ie when the object returned runs out of scope), unless 1414 \a autoCommit is set to false. When \a autoCommit is false, commit() has to be called 1415 manually. 1416 1417 \l createTouchDevice() can be called to create a test touch device for use with this 1418 function. 1419*/ 1420 1421// Internals of qtestmouse.h: 1422 1423/*! \fn void QTest::mouseEvent(MouseAction action, QWidget *widget, Qt::MouseButton button, Qt::KeyboardModifiers stateKey, QPoint pos, int delay=-1) 1424 \internal 1425*/ 1426 1427/*! \fn void QTest::mouseEvent(MouseAction action, QWindow *window, Qt::MouseButton button, Qt::KeyboardModifiers stateKey, QPoint pos, int delay=-1) 1428 \internal 1429*/ 1430