qtestcase.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -
4** Contact: http://www.qt-project.org/legal -
5** -
6** This file is part of the QtTest module of the Qt Toolkit. -
7** -
8** $QT_BEGIN_LICENSE:LGPL$ -
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 Digia. For licensing terms and -
14** conditions see http://qt.digia.com/licensing. For further information -
15** use the contact form at http://qt.digia.com/contact-us. -
16** -
17** GNU Lesser General Public License Usage -
18** Alternatively, this file may be used under the terms of the GNU Lesser -
19** General Public License version 2.1 as published by the Free Software -
20** Foundation and appearing in the file LICENSE.LGPL included in the -
21** packaging of this file. Please review the following information to -
22** ensure the GNU Lesser General Public License version 2.1 requirements -
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
24** -
25** In addition, as a special exception, Digia gives you certain additional -
26** rights. These rights are described in the Digia Qt LGPL Exception -
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
28** -
29** GNU General Public License Usage -
30** Alternatively, this file may be used under the terms of the GNU -
31** General Public License version 3.0 as published by the Free Software -
32** Foundation and appearing in the file LICENSE.GPL included in the -
33** packaging of this file. Please review the following information to -
34** ensure the GNU General Public License version 3.0 requirements will be -
35** met: http://www.gnu.org/copyleft/gpl.html. -
36** -
37** -
38** $QT_END_LICENSE$ -
39** -
40****************************************************************************/ -
41 -
42#include <QtTest/qtestcase.h> -
43#include <QtTest/qtestassert.h> -
44 -
45#include <QtCore/qbytearray.h> -
46#include <QtCore/qmetaobject.h> -
47#include <QtCore/qobject.h> -
48#include <QtCore/qstringlist.h> -
49#include <QtCore/qvector.h> -
50#include <QtCore/qvarlengtharray.h> -
51#include <QtCore/qcoreapplication.h> -
52#include <QtCore/qfile.h> -
53#include <QtCore/qfileinfo.h> -
54#include <QtCore/qdir.h> -
55#include <QtCore/qprocess.h> -
56#include <QtCore/qdebug.h> -
57#include <QtCore/qlibraryinfo.h> -
58 -
59#include <QtTest/private/qtestlog_p.h> -
60#include <QtTest/private/qtesttable_p.h> -
61#include <QtTest/qtestdata.h> -
62#include <QtTest/private/qtestresult_p.h> -
63#include <QtTest/private/qsignaldumper_p.h> -
64#include <QtTest/private/qbenchmark_p.h> -
65#include <QtTest/private/cycle_p.h> -
66 -
67#include <stdarg.h> -
68#include <stdio.h> -
69#include <stdlib.h> -
70 -
71#ifdef Q_OS_WIN -
72#ifndef Q_OS_WINCE -
73# if !defined(Q_CC_MINGW) || (defined(Q_CC_MINGW) && defined(__MINGW64_VERSION_MAJOR)) -
74# include <crtdbg.h> -
75# endif -
76#endif -
77#include <windows.h> // for Sleep -
78#endif -
79#ifdef Q_OS_UNIX -
80#include <errno.h> -
81#include <signal.h> -
82#include <time.h> -
83#endif -
84 -
85#ifdef Q_OS_MAC -
86#include <IOKit/pwr_mgt/IOPMLib.h> -
87#endif -
88 -
89QT_BEGIN_NAMESPACE -
90 -
91/*! -
92 \namespace QTest -
93 \inmodule QtTest -
94 -
95 \brief The QTest namespace contains all the functions and -
96 declarations that are related to Qt Test. -
97 -
98 See the \l{Qt Test Overview} for information about how to write unit tests. -
99*/ -
100 -
101/*! \macro QVERIFY(condition) -
102 -
103 \relates QTest -
104 -
105 The QVERIFY() macro checks whether the \a condition is true or not. If it is -
106 true, execution continues. If not, a failure is recorded in the test log -
107 and the test won't be executed further. -
108 -
109 \b {Note:} This macro can only be used in a test function that is invoked -
110 by the test framework. -
111 -
112 Example: -
113 \snippet code/src_qtestlib_qtestcase.cpp 0 -
114 -
115 \sa QCOMPARE(), QTRY_VERIFY() -
116*/ -
117 -
118/*! \macro QVERIFY2(condition, message) -
119 -
120 \relates QTest -
121 -
122 The QVERIFY2() macro behaves exactly like QVERIFY(), except that it outputs -
123 a verbose \a message when \a condition is false. The \a message is a plain -
124 C string. -
125 -
126 Example: -
127 \snippet code/src_qtestlib_qtestcase.cpp 1 -
128 -
129 \sa QVERIFY(), QCOMPARE() -
130*/ -
131 -
132/*! \macro QCOMPARE(actual, expected) -
133 -
134 \relates QTest -
135 -
136 The QCOMPARE macro compares an \a actual value to an \a expected value using -
137 the equals operator. If \a actual and \a expected are identical, execution -
138 continues. If not, a failure is recorded in the test log and the test -
139 won't be executed further. -
140 -
141 In the case of comparing floats and doubles, qFuzzyCompare() is used for -
142 comparing. This means that comparing to 0 will likely fail. One solution -
143 to this is to compare to 1, and add 1 to the produced output. -
144 -
145 QCOMPARE tries to output the contents of the values if the comparison fails, -
146 so it is visible from the test log why the comparison failed. -
147 -
148 QCOMPARE is very strict on the data types. Both \a actual and \a expected -
149 have to be of the same type, otherwise the test won't compile. This prohibits -
150 unspecified behavior from being introduced; that is behavior that usually -
151 occurs when the compiler implicitly casts the argument. -
152 -
153 For your own classes, you can use \l QTest::toString() to format values for -
154 outputting into the test log. -
155 -
156 \note This macro can only be used in a test function that is invoked -
157 by the test framework. -
158 -
159 Example: -
160 \snippet code/src_qtestlib_qtestcase.cpp 2 -
161 -
162 \sa QVERIFY(), QTRY_COMPARE(), QTest::toString() -
163*/ -
164 -
165/*! \macro QTRY_VERIFY_WITH_TIMEOUT(condition, timeout) -
166 \since 5.0 -
167 -
168 \relates QTest -
169 -
170 The QTRY_VERIFY_WITH_TIMEOUT() macro is similar to QVERIFY(), but checks the \a condition -
171 repeatedly, until either the condition becomes true or the \a timeout is -
172 reached. Between each evaluation, events will be processed. If the timeout -
173 is reached, a failure is recorded in the test log and the test won't be -
174 executed further. -
175 -
176 \note This macro can only be used in a test function that is invoked -
177 by the test framework. -
178 -
179 \sa QTRY_VERIFY(), QVERIFY(), QCOMPARE(), QTRY_COMPARE() -
180*/ -
181 -
182 -
183/*! \macro QTRY_VERIFY(condition) -
184 \since 5.0 -
185 -
186 \relates QTest -
187 -
188 Checks the \a condition by invoking QTRY_VERIFY_WITH_TIMEOUT() with a timeout of five seconds. -
189 -
190 \note This macro can only be used in a test function that is invoked -
191 by the test framework. -
192 -
193 \sa QTRY_VERIFY_WITH_TIMEOUT(), QVERIFY(), QCOMPARE(), QTRY_COMPARE() -
194*/ -
195 -
196/*! \macro QTRY_COMPARE_WITH_TIMEOUT(actual, expected, timeout) -
197 \since 5.0 -
198 -
199 \relates QTest -
200 -
201 The QTRY_COMPARE_WITH_TIMEOUT() macro is similar to QCOMPARE(), but performs the comparison -
202 of the \a actual and \a expected values repeatedly, until either the two values -
203 are equal or the \a timeout is reached. Between each comparison, events -
204 will be processed. If the timeout is reached, a failure is recorded in the -
205 test log and the test won't be executed further. -
206 -
207 \note This macro can only be used in a test function that is invoked -
208 by the test framework. -
209 -
210 \sa QTRY_COMPARE(), QCOMPARE(), QVERIFY(), QTRY_VERIFY() -
211*/ -
212 -
213/*! \macro QTRY_COMPARE(actual, expected) -
214 \since 5.0 -
215 -
216 \relates QTest -
217 -
218 Performs a comparison of the \a actual and \a expected values by -
219 invoking QTRY_COMPARE_WITH_TIMEOUT() with a timeout of five seconds. -
220 -
221 \note This macro can only be used in a test function that is invoked -
222 by the test framework. -
223 -
224 \sa QTRY_COMPARE_WITH_TIMEOUT(), QCOMPARE(), QVERIFY(), QTRY_VERIFY() -
225*/ -
226 -
227/*! \macro QFETCH(type, name) -
228 -
229 \relates QTest -
230 -
231 The fetch macro creates a local variable named \a name with the type \a type -
232 on the stack. \a name has to match the element name from the test's data. -
233 If no such element exists, the test will assert. -
234 -
235 Assuming a test has the following data: -
236 -
237 \snippet code/src_qtestlib_qtestcase.cpp 3 -
238 -
239 The test data has two elements, a QString called \c aString and an integer -
240 called \c expected. To fetch these values in the actual test: -
241 -
242 \snippet code/src_qtestlib_qtestcase.cpp 4 -
243 -
244 \c aString and \c expected are variables on the stack that are initialized with -
245 the current test data. -
246 -
247 \b {Note:} This macro can only be used in a test function that is invoked -
248 by the test framework. The test function must have a _data function. -
249*/ -
250 -
251/*! \macro QWARN(message) -
252 -
253 \relates QTest -
254 \threadsafe -
255 -
256 Appends \a message as a warning to the test log. This macro can be used anywhere -
257 in your tests. -
258*/ -
259 -
260/*! \macro QFAIL(message) -
261 -
262 \relates QTest -
263 -
264 This macro can be used to force a test failure. The test stops -
265 executing and the failure \a message is appended to the test log. -
266 -
267 \b {Note:} This macro can only be used in a test function that is invoked -
268 by the test framework. -
269 -
270 Example: -
271 -
272 \snippet code/src_qtestlib_qtestcase.cpp 5 -
273*/ -
274 -
275/*! \macro QTEST(actual, testElement) -
276 -
277 \relates QTest -
278 -
279 QTEST() is a convenience macro for \l QCOMPARE() that compares -
280 the value \a actual with the element \a testElement from the test's data. -
281 If there is no such element, the test asserts. -
282 -
283 Apart from that, QTEST() behaves exactly as \l QCOMPARE(). -
284 -
285 Instead of writing: -
286 -
287 \snippet code/src_qtestlib_qtestcase.cpp 6 -
288 -
289 you can write: -
290 -
291 \snippet code/src_qtestlib_qtestcase.cpp 7 -
292 -
293 \sa QCOMPARE() -
294*/ -
295 -
296/*! \macro QSKIP(description) -
297 -
298 \relates QTest -
299 -
300 If called from a test function, the QSKIP() macro stops execution of the test -
301 without adding a failure to the test log. You can use it to skip tests that -
302 wouldn't make sense in the current configuration. The text \a description is -
303 appended to the test log and should contain an explanation of why the test -
304 couldn't be executed. -
305 -
306 If the test is data-driven, each call to QSKIP() will skip only the current -
307 row of test data, so an unconditional call to QSKIP will produce one skip -
308 message in the test log for each row of test data. -
309 -
310 If called from an _data function, the QSKIP() macro will stop execution of -
311 the _data function and will prevent execution of the associated test -
312 function. -
313 -
314 If called from initTestCase() or initTestCase_data(), the QSKIP() macro will -
315 skip all test and _data functions. -
316 -
317 \b {Note:} This macro can only be used in a test function or _data -
318 function that is invoked by the test framework. -
319 -
320 Example: -
321 \snippet code/src_qtestlib_qtestcase.cpp 8 -
322*/ -
323 -
324/*! \macro QEXPECT_FAIL(dataIndex, comment, mode) -
325 -
326 \relates QTest -
327 -
328 The QEXPECT_FAIL() macro marks the next \l QCOMPARE() or \l QVERIFY() as an -
329 expected failure. Instead of adding a failure to the test log, an expected -
330 failure will be reported. -
331 -
332 If a \l QVERIFY() or \l QCOMPARE() is marked as an expected failure, -
333 but passes instead, an unexpected pass (XPASS) is written to the test log. -
334 -
335 The parameter \a dataIndex describes for which entry in the test data the -
336 failure is expected. Pass an empty string (\c{""}) if the failure -
337 is expected for all entries or if no test data exists. -
338 -
339 \a comment will be appended to the test log for the expected failure. -
340 -
341 \a mode is a \l QTest::TestFailMode and sets whether the test should -
342 continue to execute or not. -
343 -
344 \b {Note:} This macro can only be used in a test function that is invoked -
345 by the test framework. -
346 -
347 Example 1: -
348 \snippet code/src_qtestlib_qtestcase.cpp 9 -
349 -
350 In the example above, an expected fail will be written into the test output -
351 if the variable \c i is not 42. If the variable \c i is 42, an unexpected pass -
352 is written instead. The QEXPECT_FAIL() has no influence on the second QCOMPARE() -
353 statement in the example. -
354 -
355 Example 2: -
356 \snippet code/src_qtestlib_qtestcase.cpp 10 -
357 -
358 The above testfunction will not continue executing for the test data -
359 entry \c{data27}. -
360 -
361 \sa QTest::TestFailMode, QVERIFY(), QCOMPARE() -
362*/ -
363 -
364/*! \macro QFINDTESTDATA(filename) -
365 \since 5.0 -
366 -
367 \relates QTest -
368 -
369 Returns a QString for the testdata file referred to by \a filename, or an -
370 empty QString if the testdata file could not be found. -
371 -
372 This macro allows the test to load data from an external file without -
373 hardcoding an absolute filename into the test, or using relative paths -
374 which may be error prone. -
375 -
376 The returned path will be the first path from the following list which -
377 resolves to an existing file or directory: -
378 -
379 \list -
380 \li \a filename relative to QCoreApplication::applicationDirPath() -
381 (only if a QCoreApplication or QApplication object has been created). -
382 \li \a filename relative to the test's standard install directory -
383 (QLibraryInfo::TestsPath with the lowercased testcase name appended). -
384 \li \a filename relative to the directory containing the source file from which -
385 QFINDTESTDATA is invoked. -
386 \endlist -
387 -
388 If the named file/directory does not exist at any of these locations, -
389 a warning is printed to the test log. -
390 -
391 For example, in this code: -
392 \snippet code/src_qtestlib_qtestcase.cpp 26 -
393 -
394 The testdata file will be resolved as the first existing file from: -
395 -
396 \list -
397 \li \c{/home/user/build/myxmlparser/tests/tst_myxmlparser/testxml/simple1.xml} -
398 \li \c{/usr/local/Qt-5.0.0/tests/tst_myxmlparser/testxml/simple1.xml} -
399 \li \c{/home/user/sources/myxmlparser/tests/tst_myxmlparser/testxml/simple1.xml} -
400 \endlist -
401 -
402 This allows the test to find its testdata regardless of whether the -
403 test has been installed, and regardless of whether the test's build tree -
404 is equal to the test's source tree. -
405 -
406 \b {Note:} reliable detection of testdata from the source directory requires -
407 either that qmake is used, or the \c{QT_TESTCASE_BUILDDIR} macro is defined to -
408 point to the working directory from which the compiler is invoked, or only -
409 absolute paths to the source files are passed to the compiler. Otherwise, the -
410 absolute path of the source directory cannot be determined. -
411 -
412 \b {Note:} For tests that use the \l QTEST_APPLESS_MAIN() macro to generate a -
413 \c{main()} function, \c{QFINDTESTDATA} will not attempt to find test data -
414 relative to QCoreApplication::applicationDirPath(). In practice, this means that -
415 tests using \c{QTEST_APPLESS_MAIN()} will fail to find their test data -
416 if run from a shadow build tree. -
417*/ -
418 -
419/*! \macro QTEST_MAIN(TestClass) -
420 -
421 \relates QTest -
422 -
423 Implements a main() function that instantiates an application object and -
424 the \a TestClass, and executes all tests in the order they were defined. -
425 Use this macro to build stand-alone executables. -
426 -
427 If \c QT_WIDGETS_LIB is defined, the application object will be a QApplication, -
428 if \c QT_GUI_LIB is defined, the application object will be a QGuiApplication, -
429 otherwise it will be a QCoreApplication. If qmake is used and the configuration -
430 includes \c{QT += widgets}, then \c QT_WIDGETS_LIB will be defined automatically. -
431 Similarly, if qmake is used and the configuration includes \c{QT += gui}, then -
432 \c QT_GUI_LIB will be defined automatically. -
433 -
434 \b {Note:} On platforms that have keypad navigation enabled by default, -
435 this macro will forcefully disable it if \c QT_WIDGETS_LIB is defined. This is done -
436 to simplify the usage of key events when writing autotests. If you wish to write a -
437 test case that uses keypad navigation, you should enable it either in the -
438 \c {initTestCase()} or \c {init()} functions of your test case by calling -
439 \l {QApplication::setNavigationMode()}. -
440 -
441 Example: -
442 \snippet code/src_qtestlib_qtestcase.cpp 11 -
443 -
444 \sa QTEST_APPLESS_MAIN(), QTEST_GUILESS_MAIN(), QTest::qExec(), -
445 QApplication::setNavigationMode() -
446*/ -
447 -
448/*! \macro QTEST_APPLESS_MAIN(TestClass) -
449 -
450 \relates QTest -
451 -
452 Implements a main() function that executes all tests in \a TestClass. -
453 -
454 Behaves like \l QTEST_MAIN(), but doesn't instantiate a QApplication -
455 object. Use this macro for really simple stand-alone non-GUI tests. -
456 -
457 \sa QTEST_MAIN() -
458*/ -
459 -
460/*! \macro QTEST_GUILESS_MAIN(TestClass) -
461 \since 5.0 -
462 -
463 \relates QTest -
464 -
465 Implements a main() function that instantiates a QCoreApplication object -
466 and the \a TestClass, and executes all tests in the order they were -
467 defined. Use this macro to build stand-alone executables. -
468 -
469 Behaves like \l QTEST_MAIN(), but instantiates a QCoreApplication instead -
470 of the QApplication object. Use this macro if your test case doesn't need -
471 functionality offered by QApplication, but the event loop is still necessary. -
472 -
473 \sa QTEST_MAIN() -
474*/ -
475 -
476/*! -
477 \macro QBENCHMARK -
478 -
479 \relates QTest -
480 -
481 This macro is used to measure the performance of code within a test. -
482 The code to be benchmarked is contained within a code block following -
483 this macro. -
484 -
485 For example: -
486 -
487 \snippet code/src_qtestlib_qtestcase.cpp 27 -
488 -
489 \sa {Qt Test Overview#Creating a Benchmark}{Creating a Benchmark}, -
490 {Chapter 5: Writing a Benchmark}{Writing a Benchmark} -
491*/ -
492 -
493/*! -
494 \macro QBENCHMARK_ONCE -
495 \since 4.6 -
496 -
497 \relates QTest -
498 -
499 \brief The QBENCHMARK_ONCE macro is for measuring performance of a -
500 code block by running it once. -
501 -
502 This macro is used to measure the performance of code within a test. -
503 The code to be benchmarked is contained within a code block following -
504 this macro. -
505 -
506 Unlike QBENCHMARK, the contents of the contained code block is only run -
507 once. The elapsed time will be reported as "0" if it's to short to -
508 be measured by the selected backend. (Use) -
509 -
510 \sa {Qt Test Overview#Creating a Benchmark}{Creating a Benchmark}, -
511 {Chapter 5: Writing a Benchmark}{Writing a Benchmark} -
512*/ -
513 -
514/*! \enum QTest::TestFailMode -
515 -
516 This enum describes the modes for handling an expected failure of the -
517 \l QVERIFY() or \l QCOMPARE() macros. -
518 -
519 \value Abort Aborts the execution of the test. Use this mode when it -
520 doesn't make sense to execute the test any further after the -
521 expected failure. -
522 -
523 \value Continue Continues execution of the test after the expected failure. -
524 -
525 \sa QEXPECT_FAIL() -
526*/ -
527 -
528/*! \enum QTest::KeyAction -
529 -
530 This enum describes possible actions for key handling. -
531 -
532 \value Press The key is pressed. -
533 \value Release The key is released. -
534 \value Click The key is clicked (pressed and released). -
535*/ -
536 -
537/*! \enum QTest::MouseAction -
538 -
539 This enum describes possible actions for mouse handling. -
540 -
541 \value MousePress A mouse button is pressed. -
542 \value MouseRelease A mouse button is released. -
543 \value MouseClick A mouse button is clicked (pressed and released). -
544 \value MouseDClick A mouse button is double clicked (pressed and released twice). -
545 \value MouseMove The mouse pointer has moved. -
546*/ -
547 -
548/*! \fn void QTest::keyClick(QWidget *widget, char key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) -
549 -
550 \overload -
551 -
552 Simulates clicking of \a key with an optional \a modifier on a \a widget. -
553 If \a delay is larger than 0, the test will wait for \a delay milliseconds -
554 before clicking the key. -
555 -
556 Example: -
557 \snippet code/src_qtestlib_qtestcase.cpp 13 -
558 -
559 The example above simulates clicking \c a on \c myWidget without -
560 any keyboard modifiers and without delay of the test. -
561 -
562 \sa QTest::keyClicks() -
563*/ -
564 -
565/*! \fn void QTest::keyClick(QWidget *widget, Qt::Key key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) -
566 -
567 Simulates clicking of \a key with an optional \a modifier on a \a widget. -
568 If \a delay is larger than 0, the test will wait for \a delay milliseconds -
569 before clicking the key. -
570 -
571 Examples: -
572 \snippet code/src_qtestlib_qtestcase.cpp 14 -
573 -
574 The first example above simulates clicking the \c escape key on \c -
575 myWidget without any keyboard modifiers and without delay. The -
576 second example simulates clicking \c shift-escape on \c myWidget -
577 following a 200 ms delay of the test. -
578 -
579 \sa QTest::keyClicks() -
580*/ -
581 -
582/*! \fn void QTest::keyEvent(KeyAction action, QWidget *widget, Qt::Key key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) -
583 -
584 Sends a Qt key event to \a widget with the given \a key and an associated \a action. -
585 Optionally, a keyboard \a modifier can be specified, as well as a \a delay -
586 (in milliseconds) of the test before sending the event. -
587*/ -
588 -
589/*! \fn void QTest::keyEvent(KeyAction action, QWidget *widget, char ascii, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) -
590 -
591 \overload -
592 -
593 Sends a Qt key event to \a widget with the given key \a ascii and an associated \a action. -
594 Optionally, a keyboard \a modifier can be specified, as well as a \a delay -
595 (in milliseconds) of the test before sending the event. -
596 -
597*/ -
598 -
599/*! \fn void QTest::keyPress(QWidget *widget, Qt::Key key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) -
600 -
601 Simulates pressing a \a key with an optional \a modifier on a \a widget. If \a delay -
602 is larger than 0, the test will wait for \a delay milliseconds before pressing the key. -
603 -
604 \b {Note:} At some point you should release the key using \l keyRelease(). -
605 -
606 \sa QTest::keyRelease(), QTest::keyClick() -
607*/ -
608 -
609/*! \fn void QTest::keyPress(QWidget *widget, char key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) -
610 -
611 \overload -
612 -
613 Simulates pressing a \a key with an optional \a modifier on a \a widget. -
614 If \a delay is larger than 0, the test will wait for \a delay milliseconds -
615 before pressing the key. -
616 -
617 \b {Note:} At some point you should release the key using \l keyRelease(). -
618 -
619 \sa QTest::keyRelease(), QTest::keyClick() -
620*/ -
621 -
622/*! \fn void QTest::keyRelease(QWidget *widget, Qt::Key key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) -
623 -
624 Simulates releasing a \a key with an optional \a modifier on a \a widget. -
625 If \a delay is larger than 0, the test will wait for \a delay milliseconds -
626 before releasing the key. -
627 -
628 \sa QTest::keyPress(), QTest::keyClick() -
629*/ -
630 -
631/*! \fn void QTest::keyRelease(QWidget *widget, char key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) -
632 -
633 \overload -
634 -
635 Simulates releasing a \a key with an optional \a modifier on a \a widget. -
636 If \a delay is larger than 0, the test will wait for \a delay milliseconds -
637 before releasing the key. -
638 -
639 \sa QTest::keyClick() -
640*/ -
641 -
642 -
643/*! \fn void QTest::keyClicks(QWidget *widget, const QString &sequence, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) -
644 -
645 Simulates clicking a \a sequence of keys on a \a -
646 widget. Optionally, a keyboard \a modifier can be specified as -
647 well as a \a delay (in milliseconds) of the test before each key -
648 click. -
649 -
650 Example: -
651 \snippet code/src_qtestlib_qtestcase.cpp 15 -
652 -
653 The example above simulates clicking the sequence of keys -
654 representing "hello world" on \c myWidget without any keyboard -
655 modifiers and without delay of the test. -
656 -
657 \sa QTest::keyClick() -
658*/ -
659 -
660/*! \fn void QTest::mousePress(QWidget *widget, Qt::MouseButton button, Qt::KeyboardModifiers modifier = 0, QPoint pos = QPoint(), int delay=-1) -
661 -
662 Simulates pressing a mouse \a button with an optional \a modifier -
663 on a \a widget. The position is defined by \a pos; the default -
664 position is the center of the widget. If \a delay is specified, -
665 the test will wait for the specified amount of milliseconds before -
666 the press. -
667 -
668 \sa QTest::mouseRelease(), QTest::mouseClick() -
669*/ -
670 -
671/*! \fn void QTest::mouseRelease(QWidget *widget, Qt::MouseButton button, Qt::KeyboardModifiers modifier = 0, QPoint pos = QPoint(), int delay=-1) -
672 -
673 Simulates releasing a mouse \a button with an optional \a modifier -
674 on a \a widget. The position of the release is defined by \a pos; -
675 the default position is the center of the widget. If \a delay is -
676 specified, the test will wait for the specified amount of -
677 milliseconds before releasing the button. -
678 -
679 \sa QTest::mousePress(), QTest::mouseClick() -
680*/ -
681 -
682/*! \fn void QTest::mouseClick(QWidget *widget, Qt::MouseButton button, Qt::KeyboardModifiers modifier = 0, QPoint pos = QPoint(), int delay=-1) -
683 -
684 Simulates clicking a mouse \a button with an optional \a modifier -
685 on a \a widget. The position of the click is defined by \a pos; -
686 the default position is the center of the widget. If \a delay is -
687 specified, the test will wait for the specified amount of -
688 milliseconds before pressing and before releasing the button. -
689 -
690 \sa QTest::mousePress(), QTest::mouseRelease() -
691*/ -
692 -
693/*! \fn void QTest::mouseDClick(QWidget *widget, Qt::MouseButton button, Qt::KeyboardModifiers modifier = 0, QPoint pos = QPoint(), int delay=-1) -
694 -
695 Simulates double clicking a mouse \a button with an optional \a -
696 modifier on a \a widget. The position of the click is defined by -
697 \a pos; the default position is the center of the widget. If \a -
698 delay is specified, the test will wait for the specified amount of -
699 milliseconds before each press and release. -
700 -
701 \sa QTest::mouseClick() -
702*/ -
703 -
704/*! \fn void QTest::mouseMove(QWidget *widget, QPoint pos = QPoint(), int delay=-1) -
705 -
706 Moves the mouse pointer to a \a widget. If \a pos is not -
707 specified, the mouse pointer moves to the center of the widget. If -
708 a \a delay (in milliseconds) is given, the test will wait before -
709 moving the mouse pointer. -
710*/ -
711 -
712/*! -
713 \fn char *QTest::toString(const T &value) -
714 -
715 Returns a textual representation of \a value. This function is used by -
716 \l QCOMPARE() to output verbose information in case of a test failure. -
717 -
718 You can add specializations of this function to your test to enable -
719 verbose output. -
720 -
721 \b {Note:} The caller of toString() must delete the returned data -
722 using \c{delete[]}. Your implementation should return a string -
723 created with \c{new[]} or qstrdup(). -
724 -
725 Example: -
726 -
727 \snippet code/src_qtestlib_qtestcase.cpp 16 -
728 -
729 The example above defines a toString() specialization for a class -
730 called \c MyPoint. Whenever a comparison of two instances of \c -
731 MyPoint fails, \l QCOMPARE() will call this function to output the -
732 contents of \c MyPoint to the test log. -
733 -
734 \sa QCOMPARE() -
735*/ -
736 -
737/*! -
738 \fn char *QTest::toString(const QLatin1String &string) -
739 \overload -
740 -
741 Returns a textual representation of the given \a string. -
742*/ -
743 -
744/*! -
745 \fn char *QTest::toString(const QString &string) -
746 \overload -
747 -
748 Returns a textual representation of the given \a string. -
749*/ -
750 -
751/*! -
752 \fn char *QTest::toString(const QByteArray &ba) -
753 \overload -
754 -
755 Returns a textual representation of the byte array \a ba. -
756 -
757 \sa QTest::toHexRepresentation() -
758*/ -
759 -
760/*! -
761 \fn char *QTest::toString(const QTime &time) -
762 \overload -
763 -
764 Returns a textual representation of the given \a time. -
765*/ -
766 -
767/*! -
768 \fn char *QTest::toString(const QDate &date) -
769 \overload -
770 -
771 Returns a textual representation of the given \a date. -
772*/ -
773 -
774/*! -
775 \fn char *QTest::toString(const QDateTime &dateTime) -
776 \overload -
777 -
778 Returns a textual representation of the date and time specified by -
779 \a dateTime. -
780*/ -
781 -
782/*! -
783 \fn char *QTest::toString(const QChar &character) -
784 \overload -
785 -
786 Returns a textual representation of the given \a character. -
787*/ -
788 -
789/*! -
790 \fn char *QTest::toString(const QPoint &point) -
791 \overload -
792 -
793 Returns a textual representation of the given \a point. -
794*/ -
795 -
796/*! -
797 \fn char *QTest::toString(const QSize &size) -
798 \overload -
799 -
800 Returns a textual representation of the given \a size. -
801*/ -
802 -
803/*! -
804 \fn char *QTest::toString(const QRect &rectangle) -
805 \overload -
806 -
807 Returns a textual representation of the given \a rectangle. -
808*/ -
809 -
810/*! -
811 \fn char *QTest::toString(const QUrl &url) -
812 \since 4.4 -
813 \overload -
814 -
815 Returns a textual representation of the given \a url. -
816*/ -
817 -
818/*! -
819 \fn char *QTest::toString(const QPointF &point) -
820 \overload -
821 -
822 Returns a textual representation of the given \a point. -
823*/ -
824 -
825/*! -
826 \fn char *QTest::toString(const QSizeF &size) -
827 \overload -
828 -
829 Returns a textual representation of the given \a size. -
830*/ -
831 -
832/*! -
833 \fn char *QTest::toString(const QRectF &rectangle) -
834 \overload -
835 -
836 Returns a textual representation of the given \a rectangle. -
837*/ -
838 -
839/*! -
840 \fn char *QTest::toString(const QVariant &variant) -
841 \overload -
842 -
843 Returns a textual representation of the given \a variant. -
844*/ -
845 -
846/*! \fn void QTest::qWait(int ms) -
847 -
848 Waits for \a ms milliseconds. While waiting, events will be processed and -
849 your test will stay responsive to user interface events or network communication. -
850 -
851 Example: -
852 \snippet code/src_qtestlib_qtestcase.cpp 17 -
853 -
854 The code above will wait until the network server is responding for a -
855 maximum of about 12.5 seconds. -
856 -
857 \sa QTest::qSleep(), QSignalSpy::wait() -
858*/ -
859 -
860/*! \fn bool QTest::qWaitForWindowExposed(QWindow *window, int timeout) -
861 \since 5.0 -
862 -
863 Waits for \a timeout milliseconds or until the \a window is exposed. -
864 Returns true if \c window is exposed within \a timeout milliseconds, otherwise returns false. -
865 -
866 This is mainly useful for asynchronous systems like X11, where a window will be mapped to screen some -
867 time after being asked to show itself on the screen. -
868 -
869 \sa QTest::qWaitForWindowActive(), QWindow::isExposed() -
870*/ -
871 -
872/*! \fn bool QTest::qWaitForWindowActive(QWindow *window, int timeout) -
873 \since 5.0 -
874 -
875 Waits for \a timeout milliseconds or until the \a window is active. -
876 -
877 Returns true if \c window is active within \a timeout milliseconds, otherwise returns false. -
878 -
879 \sa QTest::qWaitForWindowExposed(), QWindow::isActive() -
880*/ -
881 -
882/*! \fn bool QTest::qWaitForWindowExposed(QWidget *widget, int timeout) -
883 \since 5.0 -
884 -
885 Waits for \a timeout milliseconds or until the \a widget's window is exposed. -
886 Returns true if \c widget's window is exposed within \a timeout milliseconds, otherwise returns false. -
887 -
888 This is mainly useful for asynchronous systems like X11, where a window will be mapped to screen some -
889 time after being asked to show itself on the screen. -
890 -
891 \sa QTest::qWaitForWindowActive() -
892*/ -
893 -
894/*! \fn bool QTest::qWaitForWindowActive(QWidget *widget, int timeout) -
895 \since 5.0 -
896 -
897 Waits for \a timeout milliseconds or until the \a widget's window is active. -
898 -
899 Returns true if \c widget's window is active within \a timeout milliseconds, otherwise returns false. -
900 -
901 \sa QTest::qWaitForWindowExposed(), QWidget::isActiveWindow() -
902*/ -
903 -
904/*! \fn bool QTest::qWaitForWindowShown(QWidget *widget, int timeout) -
905 \since 5.0 -
906 \deprecated -
907 -
908 Waits for \a timeout milliseconds or until the \a widget's window is exposed. -
909 Returns true if \c widget's window is exposed within \a timeout milliseconds, otherwise returns false. -
910 -
911 This function does the same as qWaitForWindowExposed(). -
912 -
913 Example: -
914 \snippet code/src_qtestlib_qtestcase.cpp 24 -
915 -
916 \sa QTest::qWaitForWindowActive(), QTest::qWaitForWindowExposed() -
917*/ -
918 -
919/*! -
920 \class QTest::QTouchEventSequence -
921 \inmodule QtTest -
922 \since 4.6 -
923 -
924 \brief The QTouchEventSequence class is used to simulate a sequence of touch events. -
925 -
926 To simulate a sequence of touch events on a specific device for a window or widget, call -
927 QTest::touchEvent to create a QTouchEventSequence instance. Add touch events to -
928 the sequence by calling press(), move(), release() and stationary(), and let the -
929 instance run out of scope to commit the sequence to the event system. -
930 -
931 Example: -
932 \snippet code/src_qtestlib_qtestcase.cpp 25 -
933*/ -
934 -
935/*! -
936 \fn QTest::QTouchEventSequence::~QTouchEventSequence() -
937 -
938 Commits this sequence of touch events, unless autoCommit was disabled, and frees allocated resources. -
939*/ -
940 -
941/*! -
942 \fn void QTest::QTouchEventSequence::commit(bool processEvents) -
943 -
944 Commits this sequence of touch events to the event system. Normally there is no need to call this -
945 function because it is called from the destructor. However, if autoCommit is disabled, the events -
946 only get committed upon explicitly calling this function. -
947 -
948 In special cases tests may want to disable the processing of the events. This can be achieved by -
949 setting \a processEvents to false. This results in merely queuing the events, the event loop will -
950 not be forced to process them. -
951*/ -
952 -
953/*! -
954 \fn QTouchEventSequence &QTest::QTouchEventSequence::press(int touchId, const QPoint &pt, QWindow *window) -
955 \since 5.0 -
956 -
957 Adds a press event for touchpoint \a touchId at position \a pt to this sequence and returns -
958 a reference to this QTouchEventSequence. -
959 -
960 The position \a pt is interpreted as relative to \a window. If \a window is the null pointer, then -
961 \a pt is interpreted as relative to the window provided when instantiating this QTouchEventSequence. -
962 -
963 Simulates that the user pressed the touch screen or pad with the finger identified by \a touchId. -
964*/ -
965 -
966/*! -
967 \fn QTouchEventSequence &QTest::QTouchEventSequence::press(int touchId, const QPoint &pt, QWidget *widget) -
968 -
969 Adds a press event for touchpoint \a touchId at position \a pt to this sequence and returns -
970 a reference to this QTouchEventSequence. -
971 -
972 The position \a pt is interpreted as relative to \a widget. If \a widget is the null pointer, then -
973 \a pt is interpreted as relative to the widget provided when instantiating this QTouchEventSequence. -
974 -
975 Simulates that the user pressed the touch screen or pad with the finger identified by \a touchId. -
976*/ -
977 -
978/*! -
979 \fn QTouchEventSequence &QTest::QTouchEventSequence::move(int touchId, const QPoint &pt, QWindow *window) -
980 \since 5.0 -
981 -
982 Adds a move event for touchpoint \a touchId at position \a pt to this sequence and returns -
983 a reference to this QTouchEventSequence. -
984 -
985 The position \a pt is interpreted as relative to \a window. If \a window is the null pointer, then -
986 \a pt is interpreted as relative to the window provided when instantiating this QTouchEventSequence. -
987 -
988 Simulates that the user moved the finger identified by \a touchId. -
989*/ -
990 -
991/*! -
992 \fn QTouchEventSequence &QTest::QTouchEventSequence::move(int touchId, const QPoint &pt, QWidget *widget) -
993 -
994 Adds a move event for touchpoint \a touchId at position \a pt to this sequence and returns -
995 a reference to this QTouchEventSequence. -
996 -
997 The position \a pt is interpreted as relative to \a widget. If \a widget is the null pointer, then -
998 \a pt is interpreted as relative to the widget provided when instantiating this QTouchEventSequence. -
999 -
1000 Simulates that the user moved the finger identified by \a touchId. -
1001*/ -
1002 -
1003/*! -
1004 \fn QTouchEventSequence &QTest::QTouchEventSequence::release(int touchId, const QPoint &pt, QWindow *window) -
1005 \since 5.0 -
1006 -
1007 Adds a release event for touchpoint \a touchId at position \a pt to this sequence and returns -
1008 a reference to this QTouchEventSequence. -
1009 -
1010 The position \a pt is interpreted as relative to \a window. If \a window is the null pointer, then -
1011 \a pt is interpreted as relative to the window provided when instantiating this QTouchEventSequence. -
1012 -
1013 Simulates that the user lifted the finger identified by \a touchId. -
1014*/ -
1015 -
1016/*! -
1017 \fn QTouchEventSequence &QTest::QTouchEventSequence::release(int touchId, const QPoint &pt, QWidget *widget) -
1018 -
1019 Adds a release event for touchpoint \a touchId at position \a pt to this sequence and returns -
1020 a reference to this QTouchEventSequence. -
1021 -
1022 The position \a pt is interpreted as relative to \a widget. If \a widget is the null pointer, then -
1023 \a pt is interpreted as relative to the widget provided when instantiating this QTouchEventSequence. -
1024 -
1025 Simulates that the user lifted the finger identified by \a touchId. -
1026*/ -
1027 -
1028/*! -
1029 \fn QTouchEventSequence &QTest::QTouchEventSequence::stationary(int touchId) -
1030 -
1031 Adds a stationary event for touchpoint \a touchId to this sequence and returns -
1032 a reference to this QTouchEventSequence. -
1033 -
1034 Simulates that the user did not move the finger identified by \a touchId. -
1035*/ -
1036 -
1037/*! -
1038 \fn QTouchEventSequence QTest::touchEvent(QWindow *window, QTouchDevice *device, bool autoCommit = true) -
1039 \since 5.0 -
1040 -
1041 Creates and returns a QTouchEventSequence for the \a device to -
1042 simulate events for \a window. -
1043 -
1044 When adding touch events to the sequence, \a window will also be used to translate -
1045 the position provided to screen coordinates, unless another window is provided in the -
1046 respective calls to press(), move() etc. -
1047 -
1048 The touch events are committed to the event system when the destructor of the -
1049 QTouchEventSequence is called (ie when the object returned runs out of scope), unless -
1050 \a autoCommit is set to false. When \a autoCommit is false, commit() has to be called -
1051 manually. -
1052*/ -
1053 -
1054/*! -
1055 \fn QTouchEventSequence QTest::touchEvent(QWidget *widget, QTouchDevice *device, bool autoCommit = true) -
1056 -
1057 Creates and returns a QTouchEventSequence for the \a device to -
1058 simulate events for \a widget. -
1059 -
1060 When adding touch events to the sequence, \a widget will also be used to translate -
1061 the position provided to screen coordinates, unless another widget is provided in the -
1062 respective calls to press(), move() etc. -
1063 -
1064 The touch events are committed to the event system when the destructor of the -
1065 QTouchEventSequence is called (ie when the object returned runs out of scope), unless -
1066 \a autoCommit is set to false. When \a autoCommit is false, commit() has to be called -
1067 manually. -
1068*/ -
1069 -
1070static bool installCoverageTool(const char * appname, const char * testname) -
1071{ -
1072#ifdef __COVERAGESCANNER__ -
1073 if (!qEnvironmentVariableIsEmpty("QT_TESTCOCOON_ACTIVE"))
never evaluated: !qEnvironmentVariableIsEmpty("QT_TESTCOCOON_ACTIVE")
0
1074 return false;
never executed: return false;
0
1075 // Set environment variable QT_TESTCOCOON_ACTIVE to prevent an eventual subtest from -
1076 // being considered as a stand-alone test regarding the coverage analysis. -
1077 qputenv("QT_TESTCOCOON_ACTIVE", "1");
executed (the execution status of this line is deduced): qputenv("QT_TESTCOCOON_ACTIVE", "1");
-
1078 -
1079 // Install Coverage Tool -
1080 __coveragescanner_install(appname);
executed (the execution status of this line is deduced): __coveragescanner_install(appname);
-
1081 __coveragescanner_testname(testname);
executed (the execution status of this line is deduced): __coveragescanner_testname(testname);
-
1082 __coveragescanner_clear();
executed (the execution status of this line is deduced): __coveragescanner_clear();
-
1083 return true;
executed: return true;
Execution Count:399
399
1084#else -
1085 Q_UNUSED(appname); -
1086 Q_UNUSED(testname); -
1087 return false; -
1088#endif -
1089} -
1090 -
1091namespace QTest -
1092{ -
1093 static QObject *currentTestObject = 0; -
1094 -
1095 class TestFunction { -
1096 public: -
1097 TestFunction() : function_(-1), data_(0) {}
never executed: }
0
1098 void set(int function, char *data) { function_ = function; data_ = data; }
never executed: }
0
1099 char *data() const { return data_; }
never executed: return data_;
0
1100 int function() const { return function_; }
never executed: return function_;
0
1101 ~TestFunction() { delete[] data_; }
never executed: }
0
1102 private: -
1103 int function_; -
1104 char *data_; -
1105 }; -
1106 /** -
1107 * Contains the list of test functions that was supplied -
1108 * on the command line, if any. Hence, if not empty, -
1109 * those functions should be run instead of -
1110 * all appearing in the test case. -
1111 */ -
1112 static TestFunction * testFuncs = 0; -
1113 static int testFuncCount = 0; -
1114 -
1115 /** Don't leak testFuncs on exit even on error */ -
1116 static struct TestFuncCleanup -
1117 { -
1118 void cleanup() -
1119 { -
1120 delete[] testFuncs;
executed (the execution status of this line is deduced): delete[] testFuncs;
-
1121 testFuncCount = 0;
executed (the execution status of this line is deduced): testFuncCount = 0;
-
1122 testFuncs = 0;
executed (the execution status of this line is deduced): testFuncs = 0;
-
1123 }
executed: }
Execution Count:396
396
1124 -
1125 ~TestFuncCleanup() { cleanup(); }
executed: }
Execution Count:396
396
1126 } testFuncCleaner; -
1127 -
1128 static int keyDelay = -1; -
1129 static int mouseDelay = -1; -
1130 static int eventDelay = -1; -
1131#if defined(Q_OS_UNIX) -
1132 static bool noCrashHandler = false; -
1133#endif -
1134 -
1135/*! \internal -
1136 Invoke a method of the object without generating warning if the method does not exist -
1137 */ -
1138static void invokeMethod(QObject *obj, const char *methodName) -
1139{ -
1140 const QMetaObject *metaObject = obj->metaObject();
executed (the execution status of this line is deduced): const QMetaObject *metaObject = obj->metaObject();
-
1141 int funcIndex = metaObject->indexOfMethod(methodName);
executed (the execution status of this line is deduced): int funcIndex = metaObject->indexOfMethod(methodName);
-
1142 if (funcIndex >= 0) {
evaluated: funcIndex >= 0
TRUEFALSE
yes
Evaluation Count:73999
yes
Evaluation Count:66896
66896-73999
1143 QMetaMethod method = metaObject->method(funcIndex);
executed (the execution status of this line is deduced): QMetaMethod method = metaObject->method(funcIndex);
-
1144 method.invoke(obj, Qt::DirectConnection);
executed (the execution status of this line is deduced): method.invoke(obj, Qt::DirectConnection);
-
1145 }
executed: }
Execution Count:73997
73997
1146}
executed: }
Execution Count:140893
140893
1147 -
1148int defaultEventDelay() -
1149{ -
1150 if (eventDelay == -1) {
evaluated: eventDelay == -1
TRUEFALSE
yes
Evaluation Count:58
yes
Evaluation Count:26
26-58
1151 const QByteArray env = qgetenv("QTEST_EVENT_DELAY");
executed (the execution status of this line is deduced): const QByteArray env = qgetenv("QTEST_EVENT_DELAY");
-
1152 if (!env.isEmpty())
partially evaluated: !env.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:58
0-58
1153 eventDelay = atoi(env.constData());
never executed: eventDelay = atoi(env.constData());
0
1154 else -
1155 eventDelay = 0;
executed: eventDelay = 0;
Execution Count:58
58
1156 } -
1157 return eventDelay;
executed: return eventDelay;
Execution Count:84
84
1158} -
1159 -
1160int Q_TESTLIB_EXPORT defaultMouseDelay() -
1161{ -
1162 if (mouseDelay == -1) {
evaluated: mouseDelay == -1
TRUEFALSE
yes
Evaluation Count:37
yes
Evaluation Count:16232
37-16232
1163 const QByteArray env = qgetenv("QTEST_MOUSEEVENT_DELAY");
executed (the execution status of this line is deduced): const QByteArray env = qgetenv("QTEST_MOUSEEVENT_DELAY");
-
1164 if (!env.isEmpty())
partially evaluated: !env.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:37
0-37
1165 mouseDelay = atoi(env.constData());
never executed: mouseDelay = atoi(env.constData());
0
1166 else -
1167 mouseDelay = defaultEventDelay();
executed: mouseDelay = defaultEventDelay();
Execution Count:37
37
1168 } -
1169 return mouseDelay;
executed: return mouseDelay;
Execution Count:16269
16269
1170} -
1171 -
1172int Q_TESTLIB_EXPORT defaultKeyDelay() -
1173{ -
1174 if (keyDelay == -1) {
evaluated: keyDelay == -1
TRUEFALSE
yes
Evaluation Count:47
yes
Evaluation Count:10553
47-10553
1175 const QByteArray env = qgetenv("QTEST_KEYEVENT_DELAY");
executed (the execution status of this line is deduced): const QByteArray env = qgetenv("QTEST_KEYEVENT_DELAY");
-
1176 if (!env.isEmpty())
partially evaluated: !env.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:47
0-47
1177 keyDelay = atoi(env.constData());
never executed: keyDelay = atoi(env.constData());
0
1178 else -
1179 keyDelay = defaultEventDelay();
executed: keyDelay = defaultEventDelay();
Execution Count:47
47
1180 } -
1181 return keyDelay;
executed: return keyDelay;
Execution Count:10600
10600
1182} -
1183 -
1184static bool isValidSlot(const QMetaMethod &sl) -
1185{ -
1186 if (sl.access() != QMetaMethod::Private || sl.parameterCount() != 0
evaluated: sl.access() != QMetaMethod::Private
TRUEFALSE
yes
Evaluation Count:2172
yes
Evaluation Count:9192
evaluated: sl.parameterCount() != 0
TRUEFALSE
yes
Evaluation Count:399
yes
Evaluation Count:8793
399-9192
1187 || sl.returnType() != QMetaType::Void || sl.methodType() != QMetaMethod::Slot)
partially evaluated: sl.returnType() != QMetaType::Void
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8793
partially evaluated: sl.methodType() != QMetaMethod::Slot
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8793
0-8793
1188 return false;
executed: return false;
Execution Count:2571
2571
1189 QByteArray name = sl.name();
executed (the execution status of this line is deduced): QByteArray name = sl.name();
-
1190 if (name.isEmpty())
partially evaluated: name.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8793
0-8793
1191 return false;
never executed: return false;
0
1192 if (name.endsWith("_data"))
evaluated: name.endsWith("_data")
TRUEFALSE
yes
Evaluation Count:1880
yes
Evaluation Count:6913
1880-6913
1193 return false;
executed: return false;
Execution Count:1880
1880
1194 if (name == "initTestCase" || name == "cleanupTestCase"
evaluated: name == "initTestCase"
TRUEFALSE
yes
Evaluation Count:50
yes
Evaluation Count:6863
evaluated: name == "cleanupTestCase"
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:6846
17-6863
1195 || name == "cleanup" || name == "init")
evaluated: name == "cleanup"
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:6835
evaluated: name == "init"
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:6819
11-6835
1196 return false;
executed: return false;
Execution Count:94
94
1197 return true;
executed: return true;
Execution Count:6819
6819
1198} -
1199 -
1200Q_TESTLIB_EXPORT bool printAvailableFunctions = false; -
1201Q_TESTLIB_EXPORT QStringList testFunctions; -
1202Q_TESTLIB_EXPORT QStringList testTags; -
1203 -
1204static void qPrintTestSlots(FILE *stream, const char *filter = 0) -
1205{ -
1206 for (int i = 0; i < QTest::currentTestObject->metaObject()->methodCount(); ++i) {
never evaluated: i < QTest::currentTestObject->metaObject()->methodCount()
0
1207 QMetaMethod sl = QTest::currentTestObject->metaObject()->method(i);
never executed (the execution status of this line is deduced): QMetaMethod sl = QTest::currentTestObject->metaObject()->method(i);
-
1208 if (isValidSlot(sl)) {
never evaluated: isValidSlot(sl)
0
1209 const QByteArray signature = sl.methodSignature();
never executed (the execution status of this line is deduced): const QByteArray signature = sl.methodSignature();
-
1210 if (!filter || QString::fromLatin1(signature).contains(QLatin1String(filter), Qt::CaseInsensitive))
never evaluated: !filter
never evaluated: QString::fromLatin1(signature).contains(QLatin1String(filter), Qt::CaseInsensitive)
0
1211 fprintf(stream, "%s\n", signature.constData());
never executed: fprintf(stream, "%s\n", signature.constData());
0
1212 }
never executed: }
0
1213 }
never executed: }
0
1214}
never executed: }
0
1215 -
1216static void qPrintDataTags(FILE *stream) -
1217{ -
1218 // Avoid invoking the actual test functions, and also avoid printing irrelevant output: -
1219 QTestLog::setPrintAvailableTagsMode();
never executed (the execution status of this line is deduced): QTestLog::setPrintAvailableTagsMode();
-
1220 -
1221 // Get global data tags: -
1222 QTestTable::globalTestTable();
never executed (the execution status of this line is deduced): QTestTable::globalTestTable();
-
1223 invokeMethod(QTest::currentTestObject, "initTestCase_data()");
never executed (the execution status of this line is deduced): invokeMethod(QTest::currentTestObject, "initTestCase_data()");
-
1224 const QTestTable *gTable = QTestTable::globalTestTable();
never executed (the execution status of this line is deduced): const QTestTable *gTable = QTestTable::globalTestTable();
-
1225 -
1226 const QMetaObject *currTestMetaObj = QTest::currentTestObject->metaObject();
never executed (the execution status of this line is deduced): const QMetaObject *currTestMetaObj = QTest::currentTestObject->metaObject();
-
1227 -
1228 // Process test functions: -
1229 for (int i = 0; i < currTestMetaObj->methodCount(); ++i) {
never evaluated: i < currTestMetaObj->methodCount()
0
1230 QMetaMethod tf = currTestMetaObj->method(i);
never executed (the execution status of this line is deduced): QMetaMethod tf = currTestMetaObj->method(i);
-
1231 -
1232 if (isValidSlot(tf)) {
never evaluated: isValidSlot(tf)
0
1233 -
1234 // Retrieve local tags: -
1235 QStringList localTags;
never executed (the execution status of this line is deduced): QStringList localTags;
-
1236 QTestTable table;
never executed (the execution status of this line is deduced): QTestTable table;
-
1237 char *slot = qstrdup(tf.methodSignature().constData());
never executed (the execution status of this line is deduced): char *slot = qstrdup(tf.methodSignature().constData());
-
1238 slot[strlen(slot) - 2] = '\0';
never executed (the execution status of this line is deduced): slot[strlen(slot) - 2] = '\0';
-
1239 QByteArray member;
never executed (the execution status of this line is deduced): QByteArray member;
-
1240 member.resize(qstrlen(slot) + qstrlen("_data()") + 1);
never executed (the execution status of this line is deduced): member.resize(qstrlen(slot) + qstrlen("_data()") + 1);
-
1241 qsnprintf(member.data(), member.size(), "%s_data()", slot);
never executed (the execution status of this line is deduced): qsnprintf(member.data(), member.size(), "%s_data()", slot);
-
1242 invokeMethod(QTest::currentTestObject, member.constData());
never executed (the execution status of this line is deduced): invokeMethod(QTest::currentTestObject, member.constData());
-
1243 for (int j = 0; j < table.dataCount(); ++j)
never evaluated: j < table.dataCount()
0
1244 localTags << QLatin1String(table.testData(j)->dataTag());
never executed: localTags << QLatin1String(table.testData(j)->dataTag());
0
1245 -
1246 // Print all tag combinations: -
1247 if (gTable->dataCount() == 0) {
never evaluated: gTable->dataCount() == 0
0
1248 if (localTags.count() == 0) {
never evaluated: localTags.count() == 0
0
1249 // No tags at all, so just print the test function: -
1250 fprintf(stream, "%s %s\n", currTestMetaObj->className(), slot);
never executed (the execution status of this line is deduced): fprintf(stream, "%s %s\n", currTestMetaObj->className(), slot);
-
1251 } else {
never executed: }
0
1252 // Only local tags, so print each of them: -
1253 for (int k = 0; k < localTags.size(); ++k)
never evaluated: k < localTags.size()
0
1254 fprintf(
never executed: fprintf( stream, "%s %s %s\n", currTestMetaObj->className(), slot, localTags.at(k).toLatin1().data());
0
1255 stream, "%s %s %s\n",
never executed: fprintf( stream, "%s %s %s\n", currTestMetaObj->className(), slot, localTags.at(k).toLatin1().data());
0
1256 currTestMetaObj->className(), slot, localTags.at(k).toLatin1().data());
never executed: fprintf( stream, "%s %s %s\n", currTestMetaObj->className(), slot, localTags.at(k).toLatin1().data());
0
1257 }
never executed: }
0
1258 } else { -
1259 for (int j = 0; j < gTable->dataCount(); ++j) {
never evaluated: j < gTable->dataCount()
0
1260 if (localTags.count() == 0) {
never evaluated: localTags.count() == 0
0
1261 // Only global tags, so print the current one: -
1262 fprintf(
never executed (the execution status of this line is deduced): fprintf(
-
1263 stream, "%s %s __global__ %s\n",
never executed (the execution status of this line is deduced): stream, "%s %s __global__ %s\n",
-
1264 currTestMetaObj->className(), slot, gTable->testData(j)->dataTag());
never executed (the execution status of this line is deduced): currTestMetaObj->className(), slot, gTable->testData(j)->dataTag());
-
1265 } else {
never executed: }
0
1266 // Local and global tags, so print each of the local ones and -
1267 // the current global one: -
1268 for (int k = 0; k < localTags.size(); ++k)
never evaluated: k < localTags.size()
0
1269 fprintf(
never executed: fprintf( stream, "%s %s %s __global__ %s\n", currTestMetaObj->className(), slot, localTags.at(k).toLatin1().data(), gTable->testData(j)->dataTag());
0
1270 stream, "%s %s %s __global__ %s\n", currTestMetaObj->className(), slot,
never executed: fprintf( stream, "%s %s %s __global__ %s\n", currTestMetaObj->className(), slot, localTags.at(k).toLatin1().data(), gTable->testData(j)->dataTag());
0
1271 localTags.at(k).toLatin1().data(), gTable->testData(j)->dataTag());
never executed: fprintf( stream, "%s %s %s __global__ %s\n", currTestMetaObj->className(), slot, localTags.at(k).toLatin1().data(), gTable->testData(j)->dataTag());
0
1272 }
never executed: }
0
1273 } -
1274 }
never executed: }
0
1275 -
1276 delete[] slot;
never executed (the execution status of this line is deduced): delete[] slot;
-
1277 }
never executed: }
0
1278 }
never executed: }
0
1279}
never executed: }
0
1280 -
1281static int qToInt(char *str) -
1282{ -
1283 char *pEnd;
never executed (the execution status of this line is deduced): char *pEnd;
-
1284 int l = (int)strtol(str, &pEnd, 10);
never executed (the execution status of this line is deduced): int l = (int)strtol(str, &pEnd, 10);
-
1285 if (*pEnd != 0) {
never evaluated: *pEnd != 0
0
1286 fprintf(stderr, "Invalid numeric parameter: '%s'\n", str);
never executed (the execution status of this line is deduced): fprintf(stderr, "Invalid numeric parameter: '%s'\n", str);
-
1287 exit(1);
never executed: exit(1);
0
1288 } -
1289 return l;
never executed: return l;
0
1290} -
1291 -
1292Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml) -
1293{ -
1294 QTestLog::LogMode logFormat = QTestLog::Plain;
never executed (the execution status of this line is deduced): QTestLog::LogMode logFormat = QTestLog::Plain;
-
1295 const char *logFilename = 0;
never executed (the execution status of this line is deduced): const char *logFilename = 0;
-
1296 -
1297 const char *testOptions =
never executed (the execution status of this line is deduced): const char *testOptions =
-
1298 " New-style logging options:\n"
never executed (the execution status of this line is deduced): " New-style logging options:\n"
-
1299 " -o filename,format : Output results to file in the specified format\n"
never executed (the execution status of this line is deduced): " -o filename,format : Output results to file in the specified format\n"
-
1300 " Use - to output to stdout\n"
never executed (the execution status of this line is deduced): " Use - to output to stdout\n"
-
1301 " Valid formats are:\n"
never executed (the execution status of this line is deduced): " Valid formats are:\n"
-
1302 " txt : Plain text\n"
never executed (the execution status of this line is deduced): " txt : Plain text\n"
-
1303 " xunitxml : XML XUnit document\n"
never executed (the execution status of this line is deduced): " xunitxml : XML XUnit document\n"
-
1304 " xml : XML document\n"
never executed (the execution status of this line is deduced): " xml : XML document\n"
-
1305 " lightxml : A stream of XML tags\n"
never executed (the execution status of this line is deduced): " lightxml : A stream of XML tags\n"
-
1306 "\n"
never executed (the execution status of this line is deduced): "\n"
-
1307 " *** Multiple loggers can be specified, but at most one can log to stdout.\n"
never executed (the execution status of this line is deduced): " *** Multiple loggers can be specified, but at most one can log to stdout.\n"
-
1308 "\n"
never executed (the execution status of this line is deduced): "\n"
-
1309 " Old-style logging options:\n"
never executed (the execution status of this line is deduced): " Old-style logging options:\n"
-
1310 " -o filename : Write the output into file\n"
never executed (the execution status of this line is deduced): " -o filename : Write the output into file\n"
-
1311 " -txt : Output results in Plain Text\n"
never executed (the execution status of this line is deduced): " -txt : Output results in Plain Text\n"
-
1312 " -xunitxml : Output results as XML XUnit document\n"
never executed (the execution status of this line is deduced): " -xunitxml : Output results as XML XUnit document\n"
-
1313 " -xml : Output results as XML document\n"
never executed (the execution status of this line is deduced): " -xml : Output results as XML document\n"
-
1314 " -lightxml : Output results as stream of XML tags\n"
never executed (the execution status of this line is deduced): " -lightxml : Output results as stream of XML tags\n"
-
1315 "\n"
never executed (the execution status of this line is deduced): "\n"
-
1316 " *** If no output file is specified, stdout is assumed.\n"
never executed (the execution status of this line is deduced): " *** If no output file is specified, stdout is assumed.\n"
-
1317 " *** If no output format is specified, -txt is assumed.\n"
never executed (the execution status of this line is deduced): " *** If no output format is specified, -txt is assumed.\n"
-
1318 "\n"
never executed (the execution status of this line is deduced): "\n"
-
1319 " Test log detail options:\n"
never executed (the execution status of this line is deduced): " Test log detail options:\n"
-
1320 " -silent : Log failures and fatal errors only\n"
never executed (the execution status of this line is deduced): " -silent : Log failures and fatal errors only\n"
-
1321 " -v1 : Log the start of each testfunction\n"
never executed (the execution status of this line is deduced): " -v1 : Log the start of each testfunction\n"
-
1322 " -v2 : Log each QVERIFY/QCOMPARE/QTEST (implies -v1)\n"
never executed (the execution status of this line is deduced): " -v2 : Log each QVERIFY/QCOMPARE/QTEST (implies -v1)\n"
-
1323 " -vs : Log every signal emission and resulting slot invocations\n"
never executed (the execution status of this line is deduced): " -vs : Log every signal emission and resulting slot invocations\n"
-
1324 "\n"
never executed (the execution status of this line is deduced): "\n"
-
1325 " *** The -silent and -v1 options only affect plain text output.\n"
never executed (the execution status of this line is deduced): " *** The -silent and -v1 options only affect plain text output.\n"
-
1326 "\n"
never executed (the execution status of this line is deduced): "\n"
-
1327 " Testing options:\n"
never executed (the execution status of this line is deduced): " Testing options:\n"
-
1328 " -functions : Returns a list of current testfunctions\n"
never executed (the execution status of this line is deduced): " -functions : Returns a list of current testfunctions\n"
-
1329 " -datatags : Returns a list of current data tags.\n"
never executed (the execution status of this line is deduced): " -datatags : Returns a list of current data tags.\n"
-
1330 " A global data tag is preceded by ' __global__ '.\n"
never executed (the execution status of this line is deduced): " A global data tag is preceded by ' __global__ '.\n"
-
1331 " -eventdelay ms : Set default delay for mouse and keyboard simulation to ms milliseconds\n"
never executed (the execution status of this line is deduced): " -eventdelay ms : Set default delay for mouse and keyboard simulation to ms milliseconds\n"
-
1332 " -keydelay ms : Set default delay for keyboard simulation to ms milliseconds\n"
never executed (the execution status of this line is deduced): " -keydelay ms : Set default delay for keyboard simulation to ms milliseconds\n"
-
1333 " -mousedelay ms : Set default delay for mouse simulation to ms milliseconds\n"
never executed (the execution status of this line is deduced): " -mousedelay ms : Set default delay for mouse simulation to ms milliseconds\n"
-
1334 " -maxwarnings n : Sets the maximum amount of messages to output.\n"
never executed (the execution status of this line is deduced): " -maxwarnings n : Sets the maximum amount of messages to output.\n"
-
1335 " 0 means unlimited, default: 2000\n"
never executed (the execution status of this line is deduced): " 0 means unlimited, default: 2000\n"
-
1336#if defined(Q_OS_UNIX)
never executed (the execution status of this line is deduced):
-
1337 " -nocrashhandler : Disables the crash handler\n"
never executed (the execution status of this line is deduced): " -nocrashhandler : Disables the crash handler\n"
-
1338#endif
never executed (the execution status of this line is deduced):
-
1339 "\n"
never executed (the execution status of this line is deduced): "\n"
-
1340 " Benchmarking options:\n"
never executed (the execution status of this line is deduced): " Benchmarking options:\n"
-
1341#ifdef QTESTLIB_USE_VALGRIND
never executed (the execution status of this line is deduced):
-
1342 " -callgrind : Use callgrind to time benchmarks\n"
never executed (the execution status of this line is deduced): " -callgrind : Use callgrind to time benchmarks\n"
-
1343#endif
never executed (the execution status of this line is deduced):
-
1344#ifdef HAVE_TICK_COUNTER
never executed (the execution status of this line is deduced):
-
1345 " -tickcounter : Use CPU tick counters to time benchmarks\n"
never executed (the execution status of this line is deduced): " -tickcounter : Use CPU tick counters to time benchmarks\n"
-
1346#endif
never executed (the execution status of this line is deduced):
-
1347 " -eventcounter : Counts events received during benchmarks\n"
never executed (the execution status of this line is deduced): " -eventcounter : Counts events received during benchmarks\n"
-
1348 " -minimumvalue n : Sets the minimum acceptable measurement value\n"
never executed (the execution status of this line is deduced): " -minimumvalue n : Sets the minimum acceptable measurement value\n"
-
1349 " -iterations n : Sets the number of accumulation iterations.\n"
never executed (the execution status of this line is deduced): " -iterations n : Sets the number of accumulation iterations.\n"
-
1350 " -median n : Sets the number of median iterations.\n"
never executed (the execution status of this line is deduced): " -median n : Sets the number of median iterations.\n"
-
1351 " -vb : Print out verbose benchmarking information.\n";
never executed (the execution status of this line is deduced): " -vb : Print out verbose benchmarking information.\n";
-
1352 -
1353 for (int i = 1; i < argc; ++i) {
never evaluated: i < argc
0
1354 if (strcmp(argv[i], "-help") == 0 || strcmp(argv[i], "--help") == 0
never evaluated: strcmp(argv[i], "-help") == 0
never evaluated: strcmp(argv[i], "--help") == 0
0
1355 || strcmp(argv[i], "/?") == 0) {
never evaluated: strcmp(argv[i], "/?") == 0
0
1356 printf(" Usage: %s [options] [testfunction[:testdata]]...\n"
never executed (the execution status of this line is deduced): printf(" Usage: %s [options] [testfunction[:testdata]]...\n"
-
1357 " By default, all testfunctions will be run.\n\n"
never executed (the execution status of this line is deduced): " By default, all testfunctions will be run.\n\n"
-
1358 "%s", argv[0], testOptions);
never executed (the execution status of this line is deduced): "%s", argv[0], testOptions);
-
1359 -
1360 if (qml) {
never evaluated: qml
0
1361 printf ("\n"
never executed (the execution status of this line is deduced): printf ("\n"
-
1362 " QmlTest options:\n"
never executed (the execution status of this line is deduced): " QmlTest options:\n"
-
1363 " -import dir : Specify an import directory.\n"
never executed (the execution status of this line is deduced): " -import dir : Specify an import directory.\n"
-
1364 " -input dir/file : Specify the root directory for test cases or a single test case file.\n"
never executed (the execution status of this line is deduced): " -input dir/file : Specify the root directory for test cases or a single test case file.\n"
-
1365 " -qtquick1 : Run with QtQuick 1 rather than QtQuick 2.\n"
never executed (the execution status of this line is deduced): " -qtquick1 : Run with QtQuick 1 rather than QtQuick 2.\n"
-
1366 " -translation file : Specify the translation file.\n"
never executed (the execution status of this line is deduced): " -translation file : Specify the translation file.\n"
-
1367 );
never executed (the execution status of this line is deduced): );
-
1368 }
never executed: }
0
1369 -
1370 printf("\n"
never executed (the execution status of this line is deduced): printf("\n"
-
1371 " -help : This help\n");
never executed (the execution status of this line is deduced): " -help : This help\n");
-
1372 exit(0);
never executed: exit(0);
0
1373 } else if (strcmp(argv[i], "-functions") == 0) {
never evaluated: strcmp(argv[i], "-functions") == 0
0
1374 if (qml) {
never evaluated: qml
0
1375 QTest::printAvailableFunctions = true;
never executed (the execution status of this line is deduced): QTest::printAvailableFunctions = true;
-
1376 } else {
never executed: }
0
1377 qPrintTestSlots(stdout);
never executed (the execution status of this line is deduced): qPrintTestSlots(stdout);
-
1378 exit(0);
never executed: exit(0);
0
1379 } -
1380 } else if (strcmp(argv[i], "-datatags") == 0) {
never evaluated: strcmp(argv[i], "-datatags") == 0
0
1381 if (!qml) {
never evaluated: !qml
0
1382 qPrintDataTags(stdout);
never executed (the execution status of this line is deduced): qPrintDataTags(stdout);
-
1383 exit(0);
never executed: exit(0);
0
1384 } -
1385 } else if (strcmp(argv[i], "-txt") == 0) {
never executed: }
never evaluated: strcmp(argv[i], "-txt") == 0
0
1386 logFormat = QTestLog::Plain;
never executed (the execution status of this line is deduced): logFormat = QTestLog::Plain;
-
1387 } else if (strcmp(argv[i], "-xunitxml") == 0) {
never executed: }
never evaluated: strcmp(argv[i], "-xunitxml") == 0
0
1388 logFormat = QTestLog::XunitXML;
never executed (the execution status of this line is deduced): logFormat = QTestLog::XunitXML;
-
1389 } else if (strcmp(argv[i], "-xml") == 0) {
never executed: }
never evaluated: strcmp(argv[i], "-xml") == 0
0
1390 logFormat = QTestLog::XML;
never executed (the execution status of this line is deduced): logFormat = QTestLog::XML;
-
1391 } else if (strcmp(argv[i], "-lightxml") == 0) {
never executed: }
never evaluated: strcmp(argv[i], "-lightxml") == 0
0
1392 logFormat = QTestLog::LightXML;
never executed (the execution status of this line is deduced): logFormat = QTestLog::LightXML;
-
1393 } else if (strcmp(argv[i], "-silent") == 0) {
never executed: }
never evaluated: strcmp(argv[i], "-silent") == 0
0
1394 QTestLog::setVerboseLevel(-1);
never executed (the execution status of this line is deduced): QTestLog::setVerboseLevel(-1);
-
1395 } else if (strcmp(argv[i], "-v1") == 0) {
never executed: }
never evaluated: strcmp(argv[i], "-v1") == 0
0
1396 QTestLog::setVerboseLevel(1);
never executed (the execution status of this line is deduced): QTestLog::setVerboseLevel(1);
-
1397 } else if (strcmp(argv[i], "-v2") == 0) {
never executed: }
never evaluated: strcmp(argv[i], "-v2") == 0
0
1398 QTestLog::setVerboseLevel(2);
never executed (the execution status of this line is deduced): QTestLog::setVerboseLevel(2);
-
1399 } else if (strcmp(argv[i], "-vs") == 0) {
never executed: }
never evaluated: strcmp(argv[i], "-vs") == 0
0
1400 QSignalDumper::startDump();
never executed (the execution status of this line is deduced): QSignalDumper::startDump();
-
1401 } else if (strcmp(argv[i], "-o") == 0) {
never executed: }
never evaluated: strcmp(argv[i], "-o") == 0
0
1402 if (i + 1 >= argc) {
never evaluated: i + 1 >= argc
0
1403 fprintf(stderr, "-o needs an extra parameter specifying the filename and optional format\n");
never executed (the execution status of this line is deduced): fprintf(stderr, "-o needs an extra parameter specifying the filename and optional format\n");
-
1404 exit(1);
never executed: exit(1);
0
1405 } -
1406 ++i;
never executed (the execution status of this line is deduced): ++i;
-
1407 // Do we have the old or new style -o option? -
1408 char *filename = new char[strlen(argv[i])+1];
never executed (the execution status of this line is deduced): char *filename = new char[strlen(argv[i])+1];
-
1409 char *format = new char[strlen(argv[i])+1];
never executed (the execution status of this line is deduced): char *format = new char[strlen(argv[i])+1];
-
1410 if (sscanf(argv[i], "%[^,],%s", filename, format) == 1) {
never evaluated: sscanf(argv[i], "%[^,],%s", filename, format) == 1
0
1411 // Old-style -
1412 logFilename = argv[i];
never executed (the execution status of this line is deduced): logFilename = argv[i];
-
1413 } else {
never executed: }
0
1414 // New-style -
1415 if (strcmp(format, "txt") == 0)
never evaluated: strcmp(format, "txt") == 0
0
1416 logFormat = QTestLog::Plain;
never executed: logFormat = QTestLog::Plain;
0
1417 else if (strcmp(format, "lightxml") == 0)
never evaluated: strcmp(format, "lightxml") == 0
0
1418 logFormat = QTestLog::LightXML;
never executed: logFormat = QTestLog::LightXML;
0
1419 else if (strcmp(format, "xml") == 0)
never evaluated: strcmp(format, "xml") == 0
0
1420 logFormat = QTestLog::XML;
never executed: logFormat = QTestLog::XML;
0
1421 else if (strcmp(format, "xunitxml") == 0)
never evaluated: strcmp(format, "xunitxml") == 0
0
1422 logFormat = QTestLog::XunitXML;
never executed: logFormat = QTestLog::XunitXML;
0
1423 else { -
1424 fprintf(stderr, "output format must be one of txt, lightxml, xml or xunitxml\n");
never executed (the execution status of this line is deduced): fprintf(stderr, "output format must be one of txt, lightxml, xml or xunitxml\n");
-
1425 exit(1);
never executed: exit(1);
0
1426 } -
1427 if (strcmp(filename, "-") == 0 && QTestLog::loggerUsingStdout()) {
never evaluated: strcmp(filename, "-") == 0
never evaluated: QTestLog::loggerUsingStdout()
0
1428 fprintf(stderr, "only one logger can log to stdout\n");
never executed (the execution status of this line is deduced): fprintf(stderr, "only one logger can log to stdout\n");
-
1429 exit(1);
never executed: exit(1);
0
1430 } -
1431 QTestLog::addLogger(logFormat, filename);
never executed (the execution status of this line is deduced): QTestLog::addLogger(logFormat, filename);
-
1432 }
never executed: }
0
1433 delete [] filename;
never executed (the execution status of this line is deduced): delete [] filename;
-
1434 delete [] format;
never executed (the execution status of this line is deduced): delete [] format;
-
1435 } else if (strcmp(argv[i], "-eventdelay") == 0) {
never executed: }
never evaluated: strcmp(argv[i], "-eventdelay") == 0
0
1436 if (i + 1 >= argc) {
never evaluated: i + 1 >= argc
0
1437 fprintf(stderr, "-eventdelay needs an extra parameter to indicate the delay(ms)\n");
never executed (the execution status of this line is deduced): fprintf(stderr, "-eventdelay needs an extra parameter to indicate the delay(ms)\n");
-
1438 exit(1);
never executed: exit(1);
0
1439 } else { -
1440 QTest::eventDelay = qToInt(argv[++i]);
never executed (the execution status of this line is deduced): QTest::eventDelay = qToInt(argv[++i]);
-
1441 }
never executed: }
0
1442 } else if (strcmp(argv[i], "-keydelay") == 0) {
never evaluated: strcmp(argv[i], "-keydelay") == 0
0
1443 if (i + 1 >= argc) {
never evaluated: i + 1 >= argc
0
1444 fprintf(stderr, "-keydelay needs an extra parameter to indicate the delay(ms)\n");
never executed (the execution status of this line is deduced): fprintf(stderr, "-keydelay needs an extra parameter to indicate the delay(ms)\n");
-
1445 exit(1);
never executed: exit(1);
0
1446 } else { -
1447 QTest::keyDelay = qToInt(argv[++i]);
never executed (the execution status of this line is deduced): QTest::keyDelay = qToInt(argv[++i]);
-
1448 }
never executed: }
0
1449 } else if (strcmp(argv[i], "-mousedelay") == 0) {
never evaluated: strcmp(argv[i], "-mousedelay") == 0
0
1450 if (i + 1 >= argc) {
never evaluated: i + 1 >= argc
0
1451 fprintf(stderr, "-mousedelay needs an extra parameter to indicate the delay(ms)\n");
never executed (the execution status of this line is deduced): fprintf(stderr, "-mousedelay needs an extra parameter to indicate the delay(ms)\n");
-
1452 exit(1);
never executed: exit(1);
0
1453 } else { -
1454 QTest::mouseDelay = qToInt(argv[++i]);
never executed (the execution status of this line is deduced): QTest::mouseDelay = qToInt(argv[++i]);
-
1455 }
never executed: }
0
1456 } else if (strcmp(argv[i], "-maxwarnings") == 0) {
never evaluated: strcmp(argv[i], "-maxwarnings") == 0
0
1457 if (i + 1 >= argc) {
never evaluated: i + 1 >= argc
0
1458 fprintf(stderr, "-maxwarnings needs an extra parameter with the amount of warnings\n");
never executed (the execution status of this line is deduced): fprintf(stderr, "-maxwarnings needs an extra parameter with the amount of warnings\n");
-
1459 exit(1);
never executed: exit(1);
0
1460 } else { -
1461 QTestLog::setMaxWarnings(qToInt(argv[++i]));
never executed (the execution status of this line is deduced): QTestLog::setMaxWarnings(qToInt(argv[++i]));
-
1462 }
never executed: }
0
1463#if defined(Q_OS_UNIX) -
1464 } else if (strcmp(argv[i], "-nocrashhandler") == 0) {
never evaluated: strcmp(argv[i], "-nocrashhandler") == 0
0
1465 QTest::noCrashHandler = true;
never executed (the execution status of this line is deduced): QTest::noCrashHandler = true;
-
1466#endif -
1467#ifdef QTESTLIB_USE_VALGRIND -
1468 } else if (strcmp(argv[i], "-callgrind") == 0) {
never executed: }
never evaluated: strcmp(argv[i], "-callgrind") == 0
0
1469 if (QBenchmarkValgrindUtils::haveValgrind())
never evaluated: QBenchmarkValgrindUtils::haveValgrind()
0
1470 if (QFileInfo(QDir::currentPath()).isWritable()) {
never evaluated: QFileInfo(QDir::currentPath()).isWritable()
0
1471 QBenchmarkGlobalData::current->setMode(QBenchmarkGlobalData::CallgrindParentProcess);
never executed (the execution status of this line is deduced): QBenchmarkGlobalData::current->setMode(QBenchmarkGlobalData::CallgrindParentProcess);
-
1472 } else {
never executed: }
0
1473 fprintf(stderr, "WARNING: Current directory not writable. Using the walltime measurer.\n");
never executed (the execution status of this line is deduced): fprintf(stderr, "WARNING: Current directory not writable. Using the walltime measurer.\n");
-
1474 }
never executed: }
0
1475 else { -
1476 fprintf(stderr, "WARNING: Valgrind not found or too old. Make sure it is installed and in your path. "
never executed (the execution status of this line is deduced): fprintf(stderr, "WARNING: Valgrind not found or too old. Make sure it is installed and in your path. "
-
1477 "Using the walltime measurer.\n");
never executed (the execution status of this line is deduced): "Using the walltime measurer.\n");
-
1478 }
never executed: }
0
1479 } else if (strcmp(argv[i], "-callgrindchild") == 0) { // "private" option
never evaluated: strcmp(argv[i], "-callgrindchild") == 0
0
1480 QBenchmarkGlobalData::current->setMode(QBenchmarkGlobalData::CallgrindChildProcess);
never executed (the execution status of this line is deduced): QBenchmarkGlobalData::current->setMode(QBenchmarkGlobalData::CallgrindChildProcess);
-
1481 QBenchmarkGlobalData::current->callgrindOutFileBase =
never executed (the execution status of this line is deduced): QBenchmarkGlobalData::current->callgrindOutFileBase =
-
1482 QBenchmarkValgrindUtils::outFileBase();
never executed (the execution status of this line is deduced): QBenchmarkValgrindUtils::outFileBase();
-
1483#endif -
1484#ifdef HAVE_TICK_COUNTER -
1485 } else if (strcmp(argv[i], "-tickcounter") == 0) {
never executed: }
never evaluated: strcmp(argv[i], "-tickcounter") == 0
0
1486 QBenchmarkGlobalData::current->setMode(QBenchmarkGlobalData::TickCounter);
never executed (the execution status of this line is deduced): QBenchmarkGlobalData::current->setMode(QBenchmarkGlobalData::TickCounter);
-
1487#endif -
1488 } else if (strcmp(argv[i], "-eventcounter") == 0) {
never executed: }
never evaluated: strcmp(argv[i], "-eventcounter") == 0
0
1489 QBenchmarkGlobalData::current->setMode(QBenchmarkGlobalData::EventCounter);
never executed (the execution status of this line is deduced): QBenchmarkGlobalData::current->setMode(QBenchmarkGlobalData::EventCounter);
-
1490 } else if (strcmp(argv[i], "-minimumvalue") == 0) {
never executed: }
never evaluated: strcmp(argv[i], "-minimumvalue") == 0
0
1491 if (i + 1 >= argc) {
never evaluated: i + 1 >= argc
0
1492 fprintf(stderr, "-minimumvalue needs an extra parameter to indicate the minimum time(ms)\n");
never executed (the execution status of this line is deduced): fprintf(stderr, "-minimumvalue needs an extra parameter to indicate the minimum time(ms)\n");
-
1493 exit(1);
never executed: exit(1);
0
1494 } else { -
1495 QBenchmarkGlobalData::current->walltimeMinimum = qToInt(argv[++i]);
never executed (the execution status of this line is deduced): QBenchmarkGlobalData::current->walltimeMinimum = qToInt(argv[++i]);
-
1496 }
never executed: }
0
1497 } else if (strcmp(argv[i], "-iterations") == 0) {
never evaluated: strcmp(argv[i], "-iterations") == 0
0
1498 if (i + 1 >= argc) {
never evaluated: i + 1 >= argc
0
1499 fprintf(stderr, "-iterations needs an extra parameter to indicate the number of iterations\n");
never executed (the execution status of this line is deduced): fprintf(stderr, "-iterations needs an extra parameter to indicate the number of iterations\n");
-
1500 exit(1);
never executed: exit(1);
0
1501 } else { -
1502 QBenchmarkGlobalData::current->iterationCount = qToInt(argv[++i]);
never executed (the execution status of this line is deduced): QBenchmarkGlobalData::current->iterationCount = qToInt(argv[++i]);
-
1503 }
never executed: }
0
1504 } else if (strcmp(argv[i], "-median") == 0) {
never evaluated: strcmp(argv[i], "-median") == 0
0
1505 if (i + 1 >= argc) {
never evaluated: i + 1 >= argc
0
1506 fprintf(stderr, "-median needs an extra parameter to indicate the number of median iterations\n");
never executed (the execution status of this line is deduced): fprintf(stderr, "-median needs an extra parameter to indicate the number of median iterations\n");
-
1507 exit(1);
never executed: exit(1);
0
1508 } else { -
1509 QBenchmarkGlobalData::current->medianIterationCount = qToInt(argv[++i]);
never executed (the execution status of this line is deduced): QBenchmarkGlobalData::current->medianIterationCount = qToInt(argv[++i]);
-
1510 }
never executed: }
0
1511 -
1512 } else if (strcmp(argv[i], "-vb") == 0) {
never evaluated: strcmp(argv[i], "-vb") == 0
0
1513 QBenchmarkGlobalData::current->verboseOutput = true;
never executed (the execution status of this line is deduced): QBenchmarkGlobalData::current->verboseOutput = true;
-
1514 } else if (argv[i][0] == '-') {
never executed: }
never evaluated: argv[i][0] == '-'
0
1515 fprintf(stderr, "Unknown option: '%s'\n\n%s", argv[i], testOptions);
never executed (the execution status of this line is deduced): fprintf(stderr, "Unknown option: '%s'\n\n%s", argv[i], testOptions);
-
1516 if (qml) {
never evaluated: qml
0
1517 fprintf(stderr, "\nqmltest related options:\n"
never executed (the execution status of this line is deduced): fprintf(stderr, "\nqmltest related options:\n"
-
1518 " -import : Specify an import directory.\n"
never executed (the execution status of this line is deduced): " -import : Specify an import directory.\n"
-
1519 " -input : Specify the root directory for test cases.\n"
never executed (the execution status of this line is deduced): " -input : Specify the root directory for test cases.\n"
-
1520 " -qtquick1 : Run with QtQuick 1 rather than QtQuick 2.\n"
never executed (the execution status of this line is deduced): " -qtquick1 : Run with QtQuick 1 rather than QtQuick 2.\n"
-
1521 );
never executed (the execution status of this line is deduced): );
-
1522 }
never executed: }
0
1523 -
1524 fprintf(stderr, "\n"
never executed (the execution status of this line is deduced): fprintf(stderr, "\n"
-
1525 " -help : This help\n");
never executed (the execution status of this line is deduced): " -help : This help\n");
-
1526 exit(1);
never executed: exit(1);
0
1527 } else if (qml) {
never evaluated: qml
0
1528 // We can't check the availability of test functions until -
1529 // we load the QML files. So just store the data for now. -
1530 int colon = -1;
never executed (the execution status of this line is deduced): int colon = -1;
-
1531 int offset;
never executed (the execution status of this line is deduced): int offset;
-
1532 for (offset = 0; *(argv[i]+offset); ++offset) {
never evaluated: *(argv[i]+offset)
0
1533 if (*(argv[i]+offset) == ':') {
never evaluated: *(argv[i]+offset) == ':'
0
1534 if (*(argv[i]+offset+1) == ':') {
never evaluated: *(argv[i]+offset+1) == ':'
0
1535 // "::" is used as a test name separator. -
1536 // e.g. "ClickTests::test_click:row1". -
1537 ++offset;
never executed (the execution status of this line is deduced): ++offset;
-
1538 } else {
never executed: }
0
1539 colon = offset;
never executed (the execution status of this line is deduced): colon = offset;
-
1540 break;
never executed: break;
0
1541 } -
1542 } -
1543 }
never executed: }
0
1544 if (colon == -1) {
never evaluated: colon == -1
0
1545 QTest::testFunctions += QString::fromLatin1(argv[i]);
never executed (the execution status of this line is deduced): QTest::testFunctions += QString::fromLatin1(argv[i]);
-
1546 QTest::testTags += QString();
never executed (the execution status of this line is deduced): QTest::testTags += QString();
-
1547 } else {
never executed: }
0
1548 QTest::testFunctions +=
never executed (the execution status of this line is deduced): QTest::testFunctions +=
-
1549 QString::fromLatin1(argv[i], colon);
never executed (the execution status of this line is deduced): QString::fromLatin1(argv[i], colon);
-
1550 QTest::testTags +=
never executed (the execution status of this line is deduced): QTest::testTags +=
-
1551 QString::fromLatin1(argv[i] + colon + 1);
never executed (the execution status of this line is deduced): QString::fromLatin1(argv[i] + colon + 1);
-
1552 }
never executed: }
0
1553 } else { -
1554 if (!QTest::testFuncs) {
never evaluated: !QTest::testFuncs
0
1555 QTest::testFuncs = new QTest::TestFunction[512];
never executed (the execution status of this line is deduced): QTest::testFuncs = new QTest::TestFunction[512];
-
1556 }
never executed: }
0
1557 -
1558 int colon = -1;
never executed (the execution status of this line is deduced): int colon = -1;
-
1559 char buf[512], *data=0;
never executed (the execution status of this line is deduced): char buf[512], *data=0;
-
1560 int off;
never executed (the execution status of this line is deduced): int off;
-
1561 for (off = 0; *(argv[i]+off); ++off) {
never evaluated: *(argv[i]+off)
0
1562 if (*(argv[i]+off) == ':') {
never evaluated: *(argv[i]+off) == ':'
0
1563 colon = off;
never executed (the execution status of this line is deduced): colon = off;
-
1564 break;
never executed: break;
0
1565 } -
1566 }
never executed: }
0
1567 if (colon != -1) {
never evaluated: colon != -1
0
1568 data = qstrdup(argv[i]+colon+1);
never executed (the execution status of this line is deduced): data = qstrdup(argv[i]+colon+1);
-
1569 }
never executed: }
0
1570 qsnprintf(buf, qMin(512, off + 1), "%s", argv[i]); // copy text before the ':' into buf
never executed (the execution status of this line is deduced): qsnprintf(buf, qMin(512, off + 1), "%s", argv[i]);
-
1571 qsnprintf(buf + off, qMin(512 - off, 3), "()"); // append "()"
never executed (the execution status of this line is deduced): qsnprintf(buf + off, qMin(512 - off, 3), "()");
-
1572 int idx = QTest::currentTestObject->metaObject()->indexOfMethod(buf);
never executed (the execution status of this line is deduced): int idx = QTest::currentTestObject->metaObject()->indexOfMethod(buf);
-
1573 if (idx < 0 || !isValidSlot(QTest::currentTestObject->metaObject()->method(idx))) {
never evaluated: idx < 0
never evaluated: !isValidSlot(QTest::currentTestObject->metaObject()->method(idx))
0
1574 fprintf(stderr, "Unknown test function: '%s'. Possible matches:\n", buf);
never executed (the execution status of this line is deduced): fprintf(stderr, "Unknown test function: '%s'. Possible matches:\n", buf);
-
1575 buf[off] = 0;
never executed (the execution status of this line is deduced): buf[off] = 0;
-
1576 qPrintTestSlots(stderr, buf);
never executed (the execution status of this line is deduced): qPrintTestSlots(stderr, buf);
-
1577 fprintf(stderr, "\n%s -functions\nlists all available test functions.\n", argv[0]);
never executed (the execution status of this line is deduced): fprintf(stderr, "\n%s -functions\nlists all available test functions.\n", argv[0]);
-
1578 exit(1);
never executed: exit(1);
0
1579 } -
1580 testFuncs[testFuncCount].set(idx, data);
never executed (the execution status of this line is deduced): testFuncs[testFuncCount].set(idx, data);
-
1581 testFuncCount++;
never executed (the execution status of this line is deduced): testFuncCount++;
-
1582 QTEST_ASSERT(QTest::testFuncCount < 512);
never executed: qt_assert("QTest::testFuncCount < 512","qtestcase.cpp",1582);
never executed: }
never evaluated: !(QTest::testFuncCount < 512)
never evaluated: 0
0
1583 }
never executed: }
0
1584 } -
1585 -
1586 bool installedTestCoverage = installCoverageTool(QTestResult::currentAppname(), QTestResult::currentTestObjectName());
executed (the execution status of this line is deduced): bool installedTestCoverage = installCoverageTool(QTestResult::currentAppname(), QTestResult::currentTestObjectName());
-
1587 QTestLog::setInstalledTestCoverage(installedTestCoverage);
executed (the execution status of this line is deduced): QTestLog::setInstalledTestCoverage(installedTestCoverage);
-
1588 -
1589 // If no loggers were created by the long version of the -o command-line -
1590 // option, create a logger using whatever filename and format were -
1591 // set using the old-style command-line options. -
1592 if (QTestLog::loggerCount() == 0)
partially evaluated: QTestLog::loggerCount() == 0
TRUEFALSE
yes
Evaluation Count:399
no
Evaluation Count:0
0-399
1593 QTestLog::addLogger(logFormat, logFilename);
executed: QTestLog::addLogger(logFormat, logFilename);
Execution Count:399
399
1594}
executed: }
Execution Count:399
399
1595 -
1596QBenchmarkResult qMedian(const QList<QBenchmarkResult> &container) -
1597{ -
1598 const int count = container.count();
executed (the execution status of this line is deduced): const int count = container.count();
-
1599 if (count == 0)
partially evaluated: count == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
1600 return QBenchmarkResult();
never executed: return QBenchmarkResult();
0
1601 -
1602 if (count == 1)
partially evaluated: count == 1
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-8
1603 return container.at(0);
executed: return container.at(0);
Execution Count:8
8
1604 -
1605 QList<QBenchmarkResult> containerCopy = container;
never executed (the execution status of this line is deduced): QList<QBenchmarkResult> containerCopy = container;
-
1606 qSort(containerCopy);
never executed (the execution status of this line is deduced): qSort(containerCopy);
-
1607 -
1608 const int middle = count / 2;
never executed (the execution status of this line is deduced): const int middle = count / 2;
-
1609 -
1610 // ### handle even-sized containers here by doing an aritmetic mean of the two middle items. -
1611 return containerCopy.at(middle);
never executed: return containerCopy.at(middle);
0
1612} -
1613 -
1614struct QTestDataSetter -
1615{ -
1616 QTestDataSetter(QTestData *data) -
1617 { -
1618 QTestResult::setCurrentTestData(data);
executed (the execution status of this line is deduced): QTestResult::setCurrentTestData(data);
-
1619 }
executed: }
Execution Count:66438
66438
1620 ~QTestDataSetter() -
1621 { -
1622 QTestResult::setCurrentTestData(0);
executed (the execution status of this line is deduced): QTestResult::setCurrentTestData(0);
-
1623 }
executed: }
Execution Count:66432
66432
1624}; -
1625 -
1626static void qInvokeTestMethodDataEntry(char *slot) -
1627{ -
1628 /* Benchmarking: for each median iteration*/ -
1629 -
1630 bool isBenchmark = false;
executed (the execution status of this line is deduced): bool isBenchmark = false;
-
1631 int i = (QBenchmarkGlobalData::current->measurer->needsWarmupIteration()) ? -1 : 0;
partially evaluated: (QBenchmarkGlobalData::current->measurer->needsWarmupIteration())
TRUEFALSE
yes
Evaluation Count:66438
no
Evaluation Count:0
0-66438
1632 -
1633 QList<QBenchmarkResult> results;
executed (the execution status of this line is deduced): QList<QBenchmarkResult> results;
-
1634 do { -
1635 QBenchmarkTestMethodData::current->beginDataRun();
executed (the execution status of this line is deduced): QBenchmarkTestMethodData::current->beginDataRun();
-
1636 -
1637 /* Benchmarking: for each accumulation iteration*/ -
1638 bool invokeOk;
executed (the execution status of this line is deduced): bool invokeOk;
-
1639 do { -
1640 invokeMethod(QTest::currentTestObject, "init()");
executed (the execution status of this line is deduced): invokeMethod(QTest::currentTestObject, "init()");
-
1641 if (QTestResult::skipCurrentTest() || QTestResult::currentTestFailed())
partially evaluated: QTestResult::skipCurrentTest()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:66446
partially evaluated: QTestResult::currentTestFailed()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:66446
0-66446
1642 break;
never executed: break;
0
1643 -
1644 QBenchmarkTestMethodData::current->result = QBenchmarkResult();
executed (the execution status of this line is deduced): QBenchmarkTestMethodData::current->result = QBenchmarkResult();
-
1645 QBenchmarkTestMethodData::current->resultAccepted = false;
executed (the execution status of this line is deduced): QBenchmarkTestMethodData::current->resultAccepted = false;
-
1646 -
1647 QBenchmarkGlobalData::current->context.tag =
executed (the execution status of this line is deduced): QBenchmarkGlobalData::current->context.tag =
-
1648 QLatin1String(
executed (the execution status of this line is deduced): QLatin1String(
-
1649 QTestResult::currentDataTag()
executed (the execution status of this line is deduced): QTestResult::currentDataTag()
-
1650 ? QTestResult::currentDataTag() : "");
executed (the execution status of this line is deduced): ? QTestResult::currentDataTag() : "");
-
1651 -
1652 invokeOk = QMetaObject::invokeMethod(QTest::currentTestObject, slot,
executed (the execution status of this line is deduced): invokeOk = QMetaObject::invokeMethod(QTest::currentTestObject, slot,
-
1653 Qt::DirectConnection);
executed (the execution status of this line is deduced): Qt::DirectConnection);
-
1654 if (!invokeOk)
partially evaluated: !invokeOk
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:66440
0-66440
1655 QTestResult::addFailure("Unable to execute slot", __FILE__, __LINE__);
never executed: QTestResult::addFailure("Unable to execute slot", "qtestcase.cpp", 1655);
0
1656 -
1657 isBenchmark = QBenchmarkTestMethodData::current->isBenchmark();
executed (the execution status of this line is deduced): isBenchmark = QBenchmarkTestMethodData::current->isBenchmark();
-
1658 -
1659 QTestResult::finishedCurrentTestData();
executed (the execution status of this line is deduced): QTestResult::finishedCurrentTestData();
-
1660 -
1661 invokeMethod(QTest::currentTestObject, "cleanup()");
executed (the execution status of this line is deduced): invokeMethod(QTest::currentTestObject, "cleanup()");
-
1662 -
1663 // If the test isn't a benchmark, finalize the result after cleanup() has finished. -
1664 if (!isBenchmark)
evaluated: !isBenchmark
TRUEFALSE
yes
Evaluation Count:66424
yes
Evaluation Count:16
16-66424
1665 QTestResult::finishedCurrentTestDataCleanup();
executed: QTestResult::finishedCurrentTestDataCleanup();
Execution Count:66424
66424
1666 -
1667 // If this test method has a benchmark, repeat until all measurements are -
1668 // acceptable. -
1669 // The QBENCHMARK macro increases the number of iterations for each run until -
1670 // this happens. -
1671 } while (invokeOk && isBenchmark
executed: }
Execution Count:66440
partially evaluated: invokeOk
TRUEFALSE
yes
Evaluation Count:66440
no
Evaluation Count:0
evaluated: isBenchmark
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:66424
0-66440
1672 && QBenchmarkTestMethodData::current->resultsAccepted() == false
partially evaluated: QBenchmarkTestMethodData::current->resultsAccepted() == false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:16
0-16
1673 && !QTestResult::skipCurrentTest() && !QTestResult::currentTestFailed());
never evaluated: !QTestResult::skipCurrentTest()
never evaluated: !QTestResult::currentTestFailed()
0
1674 -
1675 QBenchmarkTestMethodData::current->endDataRun();
executed (the execution status of this line is deduced): QBenchmarkTestMethodData::current->endDataRun();
-
1676 if (!QTestResult::skipCurrentTest() && !QTestResult::currentTestFailed()) {
evaluated: !QTestResult::skipCurrentTest()
TRUEFALSE
yes
Evaluation Count:66198
yes
Evaluation Count:242
partially evaluated: !QTestResult::currentTestFailed()
TRUEFALSE
yes
Evaluation Count:66198
no
Evaluation Count:0
0-66198
1677 if (i > -1) // iteration -1 is the warmup iteration.
evaluated: i > -1
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:66190
8-66190
1678 results.append(QBenchmarkTestMethodData::current->result);
executed: results.append(QBenchmarkTestMethodData::current->result);
Execution Count:8
8
1679 -
1680 if (isBenchmark && QBenchmarkGlobalData::current->verboseOutput) {
evaluated: isBenchmark
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:66182
partially evaluated: QBenchmarkGlobalData::current->verboseOutput
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:16
0-66182
1681 if (i == -1) {
never evaluated: i == -1
0
1682 QTestLog::info(qPrintable(
never executed (the execution status of this line is deduced): QTestLog::info(QString(QString::fromLatin1("warmup stage result : %1") .arg(QBenchmarkTestMethodData::current->result.value)).toLocal8Bit().constData(), 0, 0);
-
1683 QString::fromLatin1("warmup stage result : %1") -
1684 .arg(QBenchmarkTestMethodData::current->result.value)), 0, 0); -
1685 } else {
never executed: }
0
1686 QTestLog::info(qPrintable(
never executed (the execution status of this line is deduced): QTestLog::info(QString(QString::fromLatin1("accumulation stage result: %1") .arg(QBenchmarkTestMethodData::current->result.value)).toLocal8Bit().constData(), 0, 0);
-
1687 QString::fromLatin1("accumulation stage result: %1") -
1688 .arg(QBenchmarkTestMethodData::current->result.value)), 0, 0); -
1689 }
never executed: }
0
1690 } -
1691 }
executed: }
Execution Count:66198
66198
1692 } while (isBenchmark
executed: }
Execution Count:66440
evaluated: isBenchmark
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:66424
16-66440
1693 && (++i < QBenchmarkGlobalData::current->adjustMedianIterationCount())
evaluated: (++i < QBenchmarkGlobalData::current->adjustMedianIterationCount())
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:8
8
1694 && !QTestResult::skipCurrentTest() && !QTestResult::currentTestFailed());
partially evaluated: !QTestResult::skipCurrentTest()
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
partially evaluated: !QTestResult::currentTestFailed()
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-8
1695 -
1696 // If the test is a benchmark, finalize the result after all iterations have finished. -
1697 if (isBenchmark) {
evaluated: isBenchmark
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:66424
8-66424
1698 bool testPassed = !QTestResult::skipCurrentTest() && !QTestResult::currentTestFailed();
partially evaluated: !QTestResult::skipCurrentTest()
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
partially evaluated: !QTestResult::currentTestFailed()
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-8
1699 QTestResult::finishedCurrentTestDataCleanup();
executed (the execution status of this line is deduced): QTestResult::finishedCurrentTestDataCleanup();
-
1700 // Only report benchmark figures if the test passed -
1701 if (testPassed && QBenchmarkTestMethodData::current->resultsAccepted())
partially evaluated: testPassed
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
partially evaluated: QBenchmarkTestMethodData::current->resultsAccepted()
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-8
1702 QTestLog::addBenchmarkResult(qMedian(results));
executed: QTestLog::addBenchmarkResult(qMedian(results));
Execution Count:8
8
1703 }
executed: }
Execution Count:8
8
1704}
executed: }
Execution Count:66432
66432
1705 -
1706/*! -
1707 \internal -
1708 -
1709 Call slot_data(), init(), slot(), cleanup(), init(), slot(), cleanup(), ... -
1710 If data is set then it is the only test that is performed -
1711 -
1712 If the function was successfully called, true is returned, otherwise -
1713 false. -
1714 */ -
1715static bool qInvokeTestMethod(const char *slotName, const char *data=0) -
1716{ -
1717 QTEST_ASSERT(slotName);
never executed: qt_assert("slotName","qtestcase.cpp",1717);
executed: }
Execution Count:6819
partially evaluated: !(slotName)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6819
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6819
0-6819
1718 -
1719 QBenchmarkTestMethodData benchmarkData;
executed (the execution status of this line is deduced): QBenchmarkTestMethodData benchmarkData;
-
1720 QBenchmarkTestMethodData::current = &benchmarkData;
executed (the execution status of this line is deduced): QBenchmarkTestMethodData::current = &benchmarkData;
-
1721 -
1722 QBenchmarkGlobalData::current->context.slotName = QLatin1String(slotName);
executed (the execution status of this line is deduced): QBenchmarkGlobalData::current->context.slotName = QLatin1String(slotName);
-
1723 -
1724 char member[512];
executed (the execution status of this line is deduced): char member[512];
-
1725 QTestTable table;
executed (the execution status of this line is deduced): QTestTable table;
-
1726 -
1727 char *slot = qstrdup(slotName);
executed (the execution status of this line is deduced): char *slot = qstrdup(slotName);
-
1728 slot[strlen(slot) - 2] = '\0';
executed (the execution status of this line is deduced): slot[strlen(slot) - 2] = '\0';
-
1729 QTestResult::setCurrentTestFunction(slot);
executed (the execution status of this line is deduced): QTestResult::setCurrentTestFunction(slot);
-
1730 -
1731 const QTestTable *gTable = QTestTable::globalTestTable();
executed (the execution status of this line is deduced): const QTestTable *gTable = QTestTable::globalTestTable();
-
1732 const int globalDataCount = gTable->dataCount();
executed (the execution status of this line is deduced): const int globalDataCount = gTable->dataCount();
-
1733 int curGlobalDataIndex = 0;
executed (the execution status of this line is deduced): int curGlobalDataIndex = 0;
-
1734 -
1735 /* For each test function that has a *_data() table/function, do: */ -
1736 do { -
1737 if (!gTable->isEmpty())
evaluated: !gTable->isEmpty()
TRUEFALSE
yes
Evaluation Count:143
yes
Evaluation Count:6736
143-6736
1738 QTestResult::setCurrentGlobalTestData(gTable->testData(curGlobalDataIndex));
executed: QTestResult::setCurrentGlobalTestData(gTable->testData(curGlobalDataIndex));
Execution Count:143
143
1739 -
1740 if (curGlobalDataIndex == 0) {
evaluated: curGlobalDataIndex == 0
TRUEFALSE
yes
Evaluation Count:6819
yes
Evaluation Count:60
60-6819
1741 qsnprintf(member, 512, "%s_data()", slot);
executed (the execution status of this line is deduced): qsnprintf(member, 512, "%s_data()", slot);
-
1742 invokeMethod(QTest::currentTestObject, member);
executed (the execution status of this line is deduced): invokeMethod(QTest::currentTestObject, member);
-
1743 }
executed: }
Execution Count:6819
6819
1744 -
1745 bool foundFunction = false;
executed (the execution status of this line is deduced): bool foundFunction = false;
-
1746 if (!QTestResult::skipCurrentTest()) {
evaluated: !QTestResult::skipCurrentTest()
TRUEFALSE
yes
Evaluation Count:6804
yes
Evaluation Count:75
75-6804
1747 int curDataIndex = 0;
executed (the execution status of this line is deduced): int curDataIndex = 0;
-
1748 const int dataCount = table.dataCount();
executed (the execution status of this line is deduced): const int dataCount = table.dataCount();
-
1749 -
1750 // Data tag requested but none available? -
1751 if (data && !dataCount) {
partially evaluated: data
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6804
never evaluated: !dataCount
0-6804
1752 // Let empty data tag through. -
1753 if (!*data)
never evaluated: !*data
0
1754 data = 0;
never executed: data = 0;
0
1755 else { -
1756 fprintf(stderr, "Unknown testdata for function %s: '%s'\n", slotName, data);
never executed (the execution status of this line is deduced): fprintf(stderr, "Unknown testdata for function %s: '%s'\n", slotName, data);
-
1757 fprintf(stderr, "Function has no testdata.\n");
never executed (the execution status of this line is deduced): fprintf(stderr, "Function has no testdata.\n");
-
1758 return false;
never executed: return false;
0
1759 } -
1760 } -
1761 -
1762 /* For each entry in the data table, do: */ -
1763 do { -
1764 QTestResult::setSkipCurrentTest(false);
executed (the execution status of this line is deduced): QTestResult::setSkipCurrentTest(false);
-
1765 if (!data || !qstrcmp(data, table.testData(curDataIndex)->dataTag())) {
partially evaluated: !data
TRUEFALSE
yes
Evaluation Count:66438
no
Evaluation Count:0
never evaluated: !qstrcmp(data, table.testData(curDataIndex)->dataTag())
0-66438
1766 foundFunction = true;
executed (the execution status of this line is deduced): foundFunction = true;
-
1767 QTestDataSetter s(curDataIndex >= dataCount ? static_cast<QTestData *>(0)
executed (the execution status of this line is deduced): QTestDataSetter s(curDataIndex >= dataCount ? static_cast<QTestData *>(0)
-
1768 : table.testData(curDataIndex));
executed (the execution status of this line is deduced): : table.testData(curDataIndex));
-
1769 -
1770 qInvokeTestMethodDataEntry(slot);
executed (the execution status of this line is deduced): qInvokeTestMethodDataEntry(slot);
-
1771 -
1772 if (data)
partially evaluated: data
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:66432
0-66432
1773 break;
never executed: break;
0
1774 }
executed: }
Execution Count:66432
66432
1775 ++curDataIndex;
executed (the execution status of this line is deduced): ++curDataIndex;
-
1776 } while (curDataIndex < dataCount);
executed: }
Execution Count:66432
evaluated: curDataIndex < dataCount
TRUEFALSE
yes
Evaluation Count:59634
yes
Evaluation Count:6798
6798-66432
1777 }
executed: }
Execution Count:6798
6798
1778 -
1779 if (data && !foundFunction) {
partially evaluated: data
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6873
never evaluated: !foundFunction
0-6873
1780 fprintf(stderr, "Unknown testdata for function %s: '%s'\n", slotName, data);
never executed (the execution status of this line is deduced): fprintf(stderr, "Unknown testdata for function %s: '%s'\n", slotName, data);
-
1781 fprintf(stderr, "Available testdata:\n");
never executed (the execution status of this line is deduced): fprintf(stderr, "Available testdata:\n");
-
1782 for (int i = 0; i < table.dataCount(); ++i)
never evaluated: i < table.dataCount()
0
1783 fprintf(stderr, "%s\n", table.testData(i)->dataTag());
never executed: fprintf(stderr, "%s\n", table.testData(i)->dataTag());
0
1784 return false;
never executed: return false;
0
1785 } -
1786 -
1787 QTestResult::setCurrentGlobalTestData(0);
executed (the execution status of this line is deduced): QTestResult::setCurrentGlobalTestData(0);
-
1788 ++curGlobalDataIndex;
executed (the execution status of this line is deduced): ++curGlobalDataIndex;
-
1789 } while (curGlobalDataIndex < globalDataCount);
executed: }
Execution Count:6873
evaluated: curGlobalDataIndex < globalDataCount
TRUEFALSE
yes
Evaluation Count:60
yes
Evaluation Count:6813
60-6873
1790 -
1791 QTestResult::finishedCurrentTestFunction();
executed (the execution status of this line is deduced): QTestResult::finishedCurrentTestFunction();
-
1792 QTestResult::setSkipCurrentTest(false);
executed (the execution status of this line is deduced): QTestResult::setSkipCurrentTest(false);
-
1793 QTestResult::setCurrentTestData(0);
executed (the execution status of this line is deduced): QTestResult::setCurrentTestData(0);
-
1794 delete[] slot;
executed (the execution status of this line is deduced): delete[] slot;
-
1795 -
1796 return true;
executed: return true;
Execution Count:6813
6813
1797} -
1798 -
1799void *fetchData(QTestData *data, const char *tagName, int typeId) -
1800{ -
1801 QTEST_ASSERT(typeId);
never executed: qt_assert("typeId","qtestcase.cpp",1801);
executed: }
Execution Count:177930
partially evaluated: !(typeId)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:177930
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:177930
0-177930
1802 QTEST_ASSERT_X(data, "QTest::fetchData()", "Test data requested, but no testdata available.");
never executed: qt_assert_x("QTest::fetchData()", "Test data requested, but no testdata available.","qtestcase.cpp",1802);
executed: }
Execution Count:177930
partially evaluated: !(data)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:177930
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:177930
0-177930
1803 QTEST_ASSERT(data->parent());
never executed: qt_assert("data->parent()","qtestcase.cpp",1803);
executed: }
Execution Count:177930
partially evaluated: !(data->parent())
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:177930
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:177930
0-177930
1804 -
1805 int idx = data->parent()->indexOf(tagName);
executed (the execution status of this line is deduced): int idx = data->parent()->indexOf(tagName);
-
1806 -
1807 if (idx == -1 || idx >= data->dataCount()) {
partially evaluated: idx == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:177930
partially evaluated: idx >= data->dataCount()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:177930
0-177930
1808 qFatal("QFETCH: Requested testdata '%s' not available, check your _data function.",
never executed (the execution status of this line is deduced): QMessageLogger("qtestcase.cpp", 1808, __PRETTY_FUNCTION__).fatal("QFETCH: Requested testdata '%s' not available, check your _data function.",
-
1809 tagName);
never executed (the execution status of this line is deduced): tagName);
-
1810 }
never executed: }
0
1811 -
1812 if (typeId != data->parent()->elementTypeId(idx)) {
partially evaluated: typeId != data->parent()->elementTypeId(idx)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:177930
0-177930
1813 qFatal("Requested type '%s' does not match available type '%s'.",
never executed (the execution status of this line is deduced): QMessageLogger("qtestcase.cpp", 1813, __PRETTY_FUNCTION__).fatal("Requested type '%s' does not match available type '%s'.",
-
1814 QMetaType::typeName(typeId),
never executed (the execution status of this line is deduced): QMetaType::typeName(typeId),
-
1815 QMetaType::typeName(data->parent()->elementTypeId(idx)));
never executed (the execution status of this line is deduced): QMetaType::typeName(data->parent()->elementTypeId(idx)));
-
1816 }
never executed: }
0
1817 -
1818 return data->data(idx);
executed: return data->data(idx);
Execution Count:177930
177930
1819} -
1820 -
1821/*! -
1822 \fn char* QTest::toHexRepresentation(const char *ba, int length) -
1823 -
1824 Returns a pointer to a string that is the string \a ba represented -
1825 as a space-separated sequence of hex characters. If the input is -
1826 considered too long, it is truncated. A trucation is indicated in -
1827 the returned string as an ellipsis at the end. -
1828 -
1829 \a length is the length of the string \a ba. -
1830 */ -
1831char *toHexRepresentation(const char *ba, int length) -
1832{ -
1833 if (length == 0)
evaluated: length == 0
TRUEFALSE
yes
Evaluation Count:6180
yes
Evaluation Count:23152
6180-23152
1834 return qstrdup("");
executed: return qstrdup("");
Execution Count:6180
6180
1835 -
1836 /* We output at maximum about maxLen characters in order to avoid -
1837 * running out of memory and flooding things when the byte array -
1838 * is large. -
1839 * -
1840 * maxLen can't be for example 200 because Qt Test is sprinkled with fixed -
1841 * size char arrays. -
1842 * */ -
1843 const int maxLen = 50;
executed (the execution status of this line is deduced): const int maxLen = 50;
-
1844 const int len = qMin(maxLen, length);
executed (the execution status of this line is deduced): const int len = qMin(maxLen, length);
-
1845 char *result = 0;
executed (the execution status of this line is deduced): char *result = 0;
-
1846 -
1847 if (length > maxLen) {
evaluated: length > maxLen
TRUEFALSE
yes
Evaluation Count:1684
yes
Evaluation Count:21468
1684-21468
1848 const int size = len * 3 + 4;
executed (the execution status of this line is deduced): const int size = len * 3 + 4;
-
1849 result = new char[size];
executed (the execution status of this line is deduced): result = new char[size];
-
1850 -
1851 char *const forElipsis = result + size - 5;
executed (the execution status of this line is deduced): char *const forElipsis = result + size - 5;
-
1852 forElipsis[0] = ' ';
executed (the execution status of this line is deduced): forElipsis[0] = ' ';
-
1853 forElipsis[1] = '.';
executed (the execution status of this line is deduced): forElipsis[1] = '.';
-
1854 forElipsis[2] = '.';
executed (the execution status of this line is deduced): forElipsis[2] = '.';
-
1855 forElipsis[3] = '.';
executed (the execution status of this line is deduced): forElipsis[3] = '.';
-
1856 result[size - 1] = '\0';
executed (the execution status of this line is deduced): result[size - 1] = '\0';
-
1857 }
executed: }
Execution Count:1684
1684
1858 else { -
1859 const int size = len * 3;
executed (the execution status of this line is deduced): const int size = len * 3;
-
1860 result = new char[size];
executed (the execution status of this line is deduced): result = new char[size];
-
1861 result[size - 1] = '\0';
executed (the execution status of this line is deduced): result[size - 1] = '\0';
-
1862 }
executed: }
Execution Count:21468
21468
1863 -
1864 const char toHex[] = "0123456789ABCDEF";
executed (the execution status of this line is deduced): const char toHex[] = "0123456789ABCDEF";
-
1865 int i = 0;
executed (the execution status of this line is deduced): int i = 0;
-
1866 int o = 0;
executed (the execution status of this line is deduced): int o = 0;
-
1867 -
1868 while (true) {
partially evaluated: true
TRUEFALSE
yes
Evaluation Count:221572
no
Evaluation Count:0
0-221572
1869 const char at = ba[i];
executed (the execution status of this line is deduced): const char at = ba[i];
-
1870 -
1871 result[o] = toHex[(at >> 4) & 0x0F];
executed (the execution status of this line is deduced): result[o] = toHex[(at >> 4) & 0x0F];
-
1872 ++o;
executed (the execution status of this line is deduced): ++o;
-
1873 result[o] = toHex[at & 0x0F];
executed (the execution status of this line is deduced): result[o] = toHex[at & 0x0F];
-
1874 -
1875 ++i;
executed (the execution status of this line is deduced): ++i;
-
1876 ++o;
executed (the execution status of this line is deduced): ++o;
-
1877 if (i == len)
evaluated: i == len
TRUEFALSE
yes
Evaluation Count:23152
yes
Evaluation Count:198420
23152-198420
1878 break;
executed: break;
Execution Count:23152
23152
1879 else { -
1880 result[o] = ' ';
executed (the execution status of this line is deduced): result[o] = ' ';
-
1881 ++o;
executed (the execution status of this line is deduced): ++o;
-
1882 }
executed: }
Execution Count:198420
198420
1883 } -
1884 -
1885 return result;
executed: return result;
Execution Count:23152
23152
1886} -
1887 -
1888static void qInvokeTestMethods(QObject *testObject) -
1889{ -
1890 const QMetaObject *metaObject = testObject->metaObject();
executed (the execution status of this line is deduced): const QMetaObject *metaObject = testObject->metaObject();
-
1891 QTEST_ASSERT(metaObject);
never executed: qt_assert("metaObject","qtestcase.cpp",1891);
executed: }
Execution Count:399
partially evaluated: !(metaObject)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:399
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:399
0-399
1892 QTestLog::startLogging();
executed (the execution status of this line is deduced): QTestLog::startLogging();
-
1893 QTestResult::setCurrentTestFunction("initTestCase");
executed (the execution status of this line is deduced): QTestResult::setCurrentTestFunction("initTestCase");
-
1894 QTestTable::globalTestTable();
executed (the execution status of this line is deduced): QTestTable::globalTestTable();
-
1895 invokeMethod(testObject, "initTestCase_data()");
executed (the execution status of this line is deduced): invokeMethod(testObject, "initTestCase_data()");
-
1896 -
1897 if (!QTestResult::skipCurrentTest() && !QTest::currentTestFailed()) {
partially evaluated: !QTestResult::skipCurrentTest()
TRUEFALSE
yes
Evaluation Count:399
no
Evaluation Count:0
partially evaluated: !QTest::currentTestFailed()
TRUEFALSE
yes
Evaluation Count:399
no
Evaluation Count:0
0-399
1898 invokeMethod(testObject, "initTestCase()");
executed (the execution status of this line is deduced): invokeMethod(testObject, "initTestCase()");
-
1899 -
1900 // finishedCurrentTestDataCleanup() resets QTestResult::currentTestFailed(), so use a local copy. -
1901 const bool previousFailed = QTestResult::currentTestFailed();
executed (the execution status of this line is deduced): const bool previousFailed = QTestResult::currentTestFailed();
-
1902 QTestResult::finishedCurrentTestData();
executed (the execution status of this line is deduced): QTestResult::finishedCurrentTestData();
-
1903 QTestResult::finishedCurrentTestDataCleanup();
executed (the execution status of this line is deduced): QTestResult::finishedCurrentTestDataCleanup();
-
1904 QTestResult::finishedCurrentTestFunction();
executed (the execution status of this line is deduced): QTestResult::finishedCurrentTestFunction();
-
1905 -
1906 if (!QTestResult::skipCurrentTest() && !previousFailed) {
evaluated: !QTestResult::skipCurrentTest()
TRUEFALSE
yes
Evaluation Count:397
yes
Evaluation Count:1
evaluated: !previousFailed
TRUEFALSE
yes
Evaluation Count:395
yes
Evaluation Count:2
1-397
1907 -
1908 if (QTest::testFuncs) {
partially evaluated: QTest::testFuncs
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:395
0-395
1909 for (int i = 0; i != QTest::testFuncCount; i++) {
never evaluated: i != QTest::testFuncCount
0
1910 if (!qInvokeTestMethod(metaObject->method(QTest::testFuncs[i].function()).methodSignature().constData(),
never evaluated: !qInvokeTestMethod(metaObject->method(QTest::testFuncs[i].function()).methodSignature().constData(), QTest::testFuncs[i].data())
0
1911 QTest::testFuncs[i].data())) {
never evaluated: !qInvokeTestMethod(metaObject->method(QTest::testFuncs[i].function()).methodSignature().constData(), QTest::testFuncs[i].data())
0
1912 break;
never executed: break;
0
1913 } -
1914 }
never executed: }
0
1915 testFuncCleaner.cleanup();
never executed (the execution status of this line is deduced): testFuncCleaner.cleanup();
-
1916 } else {
never executed: }
0
1917 int methodCount = metaObject->methodCount();
executed (the execution status of this line is deduced): int methodCount = metaObject->methodCount();
-
1918 QMetaMethod *testMethods = new QMetaMethod[methodCount];
executed (the execution status of this line is deduced): QMetaMethod *testMethods = new QMetaMethod[methodCount];
-
1919 for (int i = 0; i != methodCount; i++)
evaluated: i != methodCount
TRUEFALSE
yes
Evaluation Count:11388
yes
Evaluation Count:395
395-11388
1920 testMethods[i] = metaObject->method(i);
executed: testMethods[i] = metaObject->method(i);
Execution Count:11388
11388
1921 for (int i = 0; i != methodCount; i++) {
evaluated: i != methodCount
TRUEFALSE
yes
Evaluation Count:11364
yes
Evaluation Count:389
389-11364
1922 if (!isValidSlot(testMethods[i]))
evaluated: !isValidSlot(testMethods[i])
TRUEFALSE
yes
Evaluation Count:4545
yes
Evaluation Count:6819
4545-6819
1923 continue;
executed: continue;
Execution Count:4545
4545
1924 if (!qInvokeTestMethod(testMethods[i].methodSignature().constData()))
partially evaluated: !qInvokeTestMethod(testMethods[i].methodSignature().constData())
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6813
0-6813
1925 break;
never executed: break;
0
1926 }
executed: }
Execution Count:6813
6813
1927 delete[] testMethods;
executed (the execution status of this line is deduced): delete[] testMethods;
-
1928 testMethods = 0;
executed (the execution status of this line is deduced): testMethods = 0;
-
1929 }
executed: }
Execution Count:389
389
1930 } -
1931 -
1932 QTestResult::setSkipCurrentTest(false);
executed (the execution status of this line is deduced): QTestResult::setSkipCurrentTest(false);
-
1933 QTestResult::setCurrentTestFunction("cleanupTestCase");
executed (the execution status of this line is deduced): QTestResult::setCurrentTestFunction("cleanupTestCase");
-
1934 invokeMethod(testObject, "cleanupTestCase()");
executed (the execution status of this line is deduced): invokeMethod(testObject, "cleanupTestCase()");
-
1935 QTestResult::finishedCurrentTestData();
executed (the execution status of this line is deduced): QTestResult::finishedCurrentTestData();
-
1936 QTestResult::finishedCurrentTestDataCleanup();
executed (the execution status of this line is deduced): QTestResult::finishedCurrentTestDataCleanup();
-
1937 }
executed: }
Execution Count:391
391
1938 QTestResult::finishedCurrentTestFunction();
executed (the execution status of this line is deduced): QTestResult::finishedCurrentTestFunction();
-
1939 QTestResult::setCurrentTestFunction(0);
executed (the execution status of this line is deduced): QTestResult::setCurrentTestFunction(0);
-
1940 QTestTable::clearGlobalTestTable();
executed (the execution status of this line is deduced): QTestTable::clearGlobalTestTable();
-
1941 -
1942 QTestLog::stopLogging();
executed (the execution status of this line is deduced): QTestLog::stopLogging();
-
1943}
executed: }
Execution Count:394
394
1944 -
1945#if defined(Q_OS_UNIX) -
1946class FatalSignalHandler -
1947{ -
1948public: -
1949 FatalSignalHandler(); -
1950 ~FatalSignalHandler(); -
1951 -
1952private: -
1953 static void signal(int); -
1954 sigset_t handledSignals; -
1955}; -
1956 -
1957void FatalSignalHandler::signal(int signum) -
1958{ -
1959 qFatal("Received signal %d", signum);
never executed (the execution status of this line is deduced): QMessageLogger("qtestcase.cpp", 1959, __PRETTY_FUNCTION__).fatal("Received signal %d", signum);
-
1960#if defined(Q_OS_INTEGRITY) -
1961 { -
1962 struct sigaction act; -
1963 memset(&act, 0, sizeof(struct sigaction)); -
1964 act.sa_handler = SIG_DFL; -
1965 sigaction(signum, &act, NULL); -
1966 } -
1967#endif -
1968}
never executed: }
0
1969 -
1970FatalSignalHandler::FatalSignalHandler() -
1971{ -
1972 sigemptyset(&handledSignals);
executed (the execution status of this line is deduced): sigemptyset(&handledSignals);
-
1973 -
1974 const int fatalSignals[] = {
executed (the execution status of this line is deduced): const int fatalSignals[] = {
-
1975 SIGHUP, SIGINT, SIGQUIT, SIGILL, SIGFPE, SIGSEGV, SIGPIPE, SIGTERM, 0 };
executed (the execution status of this line is deduced): 1, 2, 3, 4, 8, 11, 13, 15, 0 };
-
1976 -
1977 struct sigaction act;
executed (the execution status of this line is deduced): struct sigaction act;
-
1978 memset(&act, 0, sizeof(act));
executed (the execution status of this line is deduced): memset(&act, 0, sizeof(act));
-
1979 act.sa_handler = FatalSignalHandler::signal;
executed (the execution status of this line is deduced): act.__sigaction_handler.sa_handler = FatalSignalHandler::signal;
-
1980 -
1981 // Remove the handler after it is invoked. -
1982#if !defined(Q_OS_INTEGRITY) -
1983 act.sa_flags = SA_RESETHAND;
executed (the execution status of this line is deduced): act.sa_flags = 0x80000000;
-
1984#endif -
1985 // Block all fatal signals in our signal handler so we don't try to close -
1986 // the testlog twice. -
1987 sigemptyset(&act.sa_mask);
executed (the execution status of this line is deduced): sigemptyset(&act.sa_mask);
-
1988 for (int i = 0; fatalSignals[i]; ++i)
evaluated: fatalSignals[i]
TRUEFALSE
yes
Evaluation Count:3192
yes
Evaluation Count:399
399-3192
1989 sigaddset(&act.sa_mask, fatalSignals[i]);
executed: sigaddset(&act.sa_mask, fatalSignals[i]);
Execution Count:3192
3192
1990 -
1991 struct sigaction oldact;
executed (the execution status of this line is deduced): struct sigaction oldact;
-
1992 -
1993 for (int i = 0; fatalSignals[i]; ++i) {
evaluated: fatalSignals[i]
TRUEFALSE
yes
Evaluation Count:3192
yes
Evaluation Count:399
399-3192
1994 sigaction(fatalSignals[i], &act, &oldact);
executed (the execution status of this line is deduced): sigaction(fatalSignals[i], &act, &oldact);
-
1995 if ( -
1996#ifdef SA_SIGINFO -
1997 oldact.sa_flags & SA_SIGINFO ||
partially evaluated: oldact.sa_flags & 4
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3192
0-3192
1998#endif
executed (the execution status of this line is deduced):
-
1999 oldact.sa_handler != SIG_DFL) {
evaluated: oldact.__sigaction_handler.sa_handler != ((__sighandler_t) 0)
TRUEFALSE
yes
Evaluation Count:2188
yes
Evaluation Count:1004
1004-2188
2000 sigaction(fatalSignals[i], &oldact, 0);
executed (the execution status of this line is deduced): sigaction(fatalSignals[i], &oldact, 0);
-
2001 } else
executed: }
Execution Count:2188
2188
2002 { -
2003 sigaddset(&handledSignals, fatalSignals[i]);
executed (the execution status of this line is deduced): sigaddset(&handledSignals, fatalSignals[i]);
-
2004 }
executed: }
Execution Count:1004
1004
2005 } -
2006}
executed: }
Execution Count:399
399
2007 -
2008 -
2009FatalSignalHandler::~FatalSignalHandler() -
2010{ -
2011 // Unregister any of our remaining signal handlers -
2012 struct sigaction act;
executed (the execution status of this line is deduced): struct sigaction act;
-
2013 memset(&act, 0, sizeof(act));
executed (the execution status of this line is deduced): memset(&act, 0, sizeof(act));
-
2014 act.sa_handler = SIG_DFL;
executed (the execution status of this line is deduced): act.__sigaction_handler.sa_handler = ((__sighandler_t) 0);
-
2015 -
2016 struct sigaction oldact;
executed (the execution status of this line is deduced): struct sigaction oldact;
-
2017 -
2018 for (int i = 1; i < 32; ++i) {
evaluated: i < 32
TRUEFALSE
yes
Evaluation Count:12214
yes
Evaluation Count:394
394-12214
2019 if (!sigismember(&handledSignals, i))
evaluated: !sigismember(&handledSignals, i)
TRUEFALSE
yes
Evaluation Count:11219
yes
Evaluation Count:995
995-11219
2020 continue;
executed: continue;
Execution Count:11219
11219
2021 sigaction(i, &act, &oldact);
executed (the execution status of this line is deduced): sigaction(i, &act, &oldact);
-
2022 -
2023 // If someone overwrote it in the mean time, put it back -
2024 if (oldact.sa_handler != FatalSignalHandler::signal)
evaluated: oldact.__sigaction_handler.sa_handler != FatalSignalHandler::signal
TRUEFALSE
yes
Evaluation Count:29
yes
Evaluation Count:966
29-966
2025 sigaction(i, &oldact, 0);
executed: sigaction(i, &oldact, 0);
Execution Count:29
29
2026 }
executed: }
Execution Count:995
995
2027}
executed: }
Execution Count:394
394
2028 -
2029#endif -
2030 -
2031 -
2032} // namespace -
2033 -
2034/*! -
2035 Executes tests declared in \a testObject. In addition, the private slots -
2036 \c{initTestCase()}, \c{cleanupTestCase()}, \c{init()} and \c{cleanup()} -
2037 are executed if they exist. See \l{Creating a Test} for more details. -
2038 -
2039 Optionally, the command line arguments \a argc and \a argv can be provided. -
2040 For a list of recognized arguments, read \l {Qt Test Command Line Arguments}. -
2041 -
2042 The following example will run all tests in \c MyTestObject: -
2043 -
2044 \snippet code/src_qtestlib_qtestcase.cpp 18 -
2045 -
2046 This function returns 0 if no tests failed, or a value other than 0 if one -
2047 or more tests failed or in case of unhandled exceptions. (Skipped tests do -
2048 not influence the return value.) -
2049 -
2050 For stand-alone test applications, the convenience macro \l QTEST_MAIN() can -
2051 be used to declare a main() function that parses the command line arguments -
2052 and executes the tests, avoiding the need to call this function explicitly. -
2053 -
2054 The return value from this function is also the exit code of the test -
2055 application when the \l QTEST_MAIN() macro is used. -
2056 -
2057 For stand-alone test applications, this function should not be called more -
2058 than once, as command-line options for logging test output to files and -
2059 executing individual test functions will not behave correctly. -
2060 -
2061 Note: This function is not reentrant, only one test can run at a time. A -
2062 test that was executed with qExec() can't run another test via qExec() and -
2063 threads are not allowed to call qExec() simultaneously. -
2064 -
2065 If you have programatically created the arguments, as opposed to getting them -
2066 from the arguments in \c main(), it is likely of interest to use -
2067 QTest::qExec(QObject *, const QStringList &) since it is Unicode safe. -
2068 -
2069 \sa QTEST_MAIN() -
2070*/ -
2071 -
2072int QTest::qExec(QObject *testObject, int argc, char **argv) -
2073{ -
2074 QBenchmarkGlobalData benchmarkData;
executed (the execution status of this line is deduced): QBenchmarkGlobalData benchmarkData;
-
2075 QBenchmarkGlobalData::current = &benchmarkData;
executed (the execution status of this line is deduced): QBenchmarkGlobalData::current = &benchmarkData;
-
2076 -
2077#ifdef QTESTLIB_USE_VALGRIND -
2078 int callgrindChildExitCode = 0;
executed (the execution status of this line is deduced): int callgrindChildExitCode = 0;
-
2079#endif -
2080 -
2081#ifdef Q_OS_MAC -
2082 bool macNeedsActivate = qApp && (qstrcmp(qApp->metaObject()->className(), "QApplication") == 0); -
2083 IOPMAssertionID powerID; -
2084#endif -
2085#ifndef QT_NO_EXCEPTIONS -
2086 try { -
2087#endif -
2088 -
2089#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) -
2090# if !defined(Q_CC_MINGW) -
2091 _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG); -
2092# endif -
2093 SetErrorMode(SetErrorMode(0) | SEM_NOGPFAULTERRORBOX); -
2094#endif -
2095 -
2096#ifdef Q_OS_MAC -
2097 if (macNeedsActivate) { -
2098 CFStringRef reasonForActivity= CFSTR("No Display Sleep"); -
2099 IOReturn ok = IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, reasonForActivity, &powerID); -
2100 -
2101 if (ok != kIOReturnSuccess) -
2102 macNeedsActivate = false; // no need to release the assertion on exit. -
2103 } -
2104#endif -
2105 -
2106 QTestResult::reset();
never executed (the execution status of this line is deduced): QTestResult::reset();
-
2107 -
2108 QTEST_ASSERT(testObject);
never executed: qt_assert("testObject","qtestcase.cpp",2108);
never executed: }
never evaluated: !(testObject)
never evaluated: 0
0
2109 QTEST_ASSERT(!currentTestObject);
never executed: qt_assert("!currentTestObject","qtestcase.cpp",2109);
never executed: }
never evaluated: !(!currentTestObject)
never evaluated: 0
0
2110 currentTestObject = testObject;
never executed (the execution status of this line is deduced): currentTestObject = testObject;
-
2111 -
2112 const QMetaObject *metaObject = testObject->metaObject();
never executed (the execution status of this line is deduced): const QMetaObject *metaObject = testObject->metaObject();
-
2113 QTEST_ASSERT(metaObject);
never executed: qt_assert("metaObject","qtestcase.cpp",2113);
never executed: }
never evaluated: !(metaObject)
never evaluated: 0
0
2114 -
2115 QTestResult::setCurrentTestObject(metaObject->className());
never executed (the execution status of this line is deduced): QTestResult::setCurrentTestObject(metaObject->className());
-
2116 if (argc > 0)
never evaluated: argc > 0
0
2117 QTestResult::setCurrentAppname(argv[0]);
never executed: QTestResult::setCurrentAppname(argv[0]);
0
2118 -
2119 qtest_qParseArgs(argc, argv, false);
executed (the execution status of this line is deduced): qtest_qParseArgs(argc, argv, false);
-
2120 -
2121#ifdef QTESTLIB_USE_VALGRIND -
2122 if (QBenchmarkGlobalData::current->mode() == QBenchmarkGlobalData::CallgrindParentProcess) {
partially evaluated: QBenchmarkGlobalData::current->mode() == QBenchmarkGlobalData::CallgrindParentProcess
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:399
0-399
2123 const QStringList origAppArgs(QCoreApplication::arguments());
never executed (the execution status of this line is deduced): const QStringList origAppArgs(QCoreApplication::arguments());
-
2124 if (!QBenchmarkValgrindUtils::rerunThroughCallgrind(origAppArgs, callgrindChildExitCode))
never evaluated: !QBenchmarkValgrindUtils::rerunThroughCallgrind(origAppArgs, callgrindChildExitCode)
0
2125 return -1;
never executed: return -1;
0
2126 -
2127 QBenchmarkValgrindUtils::cleanup();
never executed (the execution status of this line is deduced): QBenchmarkValgrindUtils::cleanup();
-
2128 -
2129 } else
never executed: }
0
2130#endif -
2131 { -
2132#if defined(Q_OS_UNIX) -
2133 QScopedPointer<FatalSignalHandler> handler;
executed (the execution status of this line is deduced): QScopedPointer<FatalSignalHandler> handler;
-
2134 if (!noCrashHandler)
partially evaluated: !noCrashHandler
TRUEFALSE
yes
Evaluation Count:399
no
Evaluation Count:0
0-399
2135 handler.reset(new FatalSignalHandler);
executed: handler.reset(new FatalSignalHandler);
Execution Count:399
399
2136#endif -
2137 qInvokeTestMethods(testObject);
executed (the execution status of this line is deduced): qInvokeTestMethods(testObject);
-
2138 }
executed: }
Execution Count:394
394
2139 -
2140#ifndef QT_NO_EXCEPTIONS -
2141 } catch (...) { -
2142 QTestResult::addFailure("Caught unhandled exception", __FILE__, __LINE__);
never executed (the execution status of this line is deduced): QTestResult::addFailure("Caught unhandled exception", "qtestcase.cpp", 2142);
-
2143 if (QTestResult::currentTestFunction()) {
never evaluated: QTestResult::currentTestFunction()
0
2144 QTestResult::finishedCurrentTestFunction();
never executed (the execution status of this line is deduced): QTestResult::finishedCurrentTestFunction();
-
2145 QTestResult::setCurrentTestFunction(0);
never executed (the execution status of this line is deduced): QTestResult::setCurrentTestFunction(0);
-
2146 }
never executed: }
0
2147 -
2148 QTestLog::stopLogging();
never executed (the execution status of this line is deduced): QTestLog::stopLogging();
-
2149#ifdef Q_OS_MAC -
2150 if (macNeedsActivate) { -
2151 IOPMAssertionRelease(powerID); -
2152 } -
2153#endif -
2154 currentTestObject = 0;
never executed (the execution status of this line is deduced): currentTestObject = 0;
-
2155 -
2156 // Rethrow exception to make debugging easier. -
2157 throw;
never executed: throw;
0
2158 return 1;
dead code: return 1;
-
2159 } -
2160#endif -
2161 -
2162 currentTestObject = 0;
executed (the execution status of this line is deduced): currentTestObject = 0;
-
2163 -
2164 QSignalDumper::endDump();
executed (the execution status of this line is deduced): QSignalDumper::endDump();
-
2165 -
2166#ifdef Q_OS_MAC -
2167 if (macNeedsActivate) { -
2168 IOPMAssertionRelease(powerID); -
2169 } -
2170#endif -
2171 -
2172#ifdef QTESTLIB_USE_VALGRIND -
2173 if (QBenchmarkGlobalData::current->mode() == QBenchmarkGlobalData::CallgrindParentProcess)
partially evaluated: QBenchmarkGlobalData::current->mode() == QBenchmarkGlobalData::CallgrindParentProcess
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:394
0-394
2174 return callgrindChildExitCode;
never executed: return callgrindChildExitCode;
0
2175#endif -
2176 // make sure our exit code is never going above 127 -
2177 // since that could wrap and indicate 0 test fails -
2178 return qMin(QTestLog::failCount(), 127);
executed: return qMin(QTestLog::failCount(), 127);
Execution Count:394
394
2179} -
2180 -
2181/*! -
2182 \overload -
2183 \since 4.4 -
2184 -
2185 Behaves identically to qExec(QObject *, int, char**) but takes a -
2186 QStringList of \a arguments instead of a \c char** list. -
2187 */ -
2188int QTest::qExec(QObject *testObject, const QStringList &arguments) -
2189{ -
2190 const int argc = arguments.count();
never executed (the execution status of this line is deduced): const int argc = arguments.count();
-
2191 QVarLengthArray<char *> argv(argc);
never executed (the execution status of this line is deduced): QVarLengthArray<char *> argv(argc);
-
2192 -
2193 QVector<QByteArray> args;
never executed (the execution status of this line is deduced): QVector<QByteArray> args;
-
2194 args.reserve(argc);
never executed (the execution status of this line is deduced): args.reserve(argc);
-
2195 -
2196 for (int i = 0; i < argc; ++i)
never evaluated: i < argc
0
2197 { -
2198 args.append(arguments.at(i).toLocal8Bit().constData());
never executed (the execution status of this line is deduced): args.append(arguments.at(i).toLocal8Bit().constData());
-
2199 argv[i] = args.last().data();
never executed (the execution status of this line is deduced): argv[i] = args.last().data();
-
2200 }
never executed: }
0
2201 -
2202 return qExec(testObject, argc, argv.data());
never executed: return qExec(testObject, argc, argv.data());
0
2203} -
2204 -
2205/*! \internal -
2206 */ -
2207void QTest::qFail(const char *statementStr, const char *file, int line) -
2208{ -
2209 QTestResult::addFailure(statementStr, file, line);
executed (the execution status of this line is deduced): QTestResult::addFailure(statementStr, file, line);
-
2210}
executed: }
Execution Count:79
79
2211 -
2212/*! \internal -
2213 */ -
2214bool QTest::qVerify(bool statement, const char *statementStr, const char *description, -
2215 const char *file, int line) -
2216{ -
2217 return QTestResult::verify(statement, statementStr, description, file, line);
executed: return QTestResult::verify(statement, statementStr, description, file, line);
Execution Count:12563038
12563038
2218} -
2219 -
2220/*! \fn void QTest::qSkip(const char *message, const char *file, int line) -
2221\internal -
2222 */ -
2223void QTest::qSkip(const char *message, const char *file, int line) -
2224{ -
2225 QTestResult::addSkip(message, file, line);
executed (the execution status of this line is deduced): QTestResult::addSkip(message, file, line);
-
2226 QTestResult::setSkipCurrentTest(true);
executed (the execution status of this line is deduced): QTestResult::setSkipCurrentTest(true);
-
2227}
executed: }
Execution Count:315
315
2228 -
2229/*! \fn bool QTest::qExpectFail(const char *dataIndex, const char *comment, TestFailMode mode, const char *file, int line) -
2230\internal -
2231 */ -
2232bool QTest::qExpectFail(const char *dataIndex, const char *comment, -
2233 QTest::TestFailMode mode, const char *file, int line) -
2234{ -
2235 return QTestResult::expectFail(dataIndex, qstrdup(comment), mode, file, line);
executed: return QTestResult::expectFail(dataIndex, qstrdup(comment), mode, file, line);
Execution Count:10963
10963
2236} -
2237 -
2238/*! \internal -
2239 */ -
2240void QTest::qWarn(const char *message, const char *file, int line) -
2241{ -
2242 QTestLog::warn(message, file, line);
executed (the execution status of this line is deduced): QTestLog::warn(message, file, line);
-
2243}
executed: }
Execution Count:8
8
2244 -
2245/*! -
2246 Ignores messages created by qDebug() or qWarning(). If the \a message -
2247 with the corresponding \a type is outputted, it will be removed from the -
2248 test log. If the test finished and the \a message was not outputted, -
2249 a test failure is appended to the test log. -
2250 -
2251 \b {Note:} Invoking this function will only ignore one message. -
2252 If the message you want to ignore is outputted twice, you have to -
2253 call ignoreMessage() twice, too. -
2254 -
2255 Example: -
2256 \snippet code/src_qtestlib_qtestcase.cpp 19 -
2257 -
2258 The example above tests that QDir::mkdir() outputs the right warning when invoked -
2259 with an invalid file name. -
2260*/ -
2261void QTest::ignoreMessage(QtMsgType type, const char *message) -
2262{ -
2263 QTestLog::ignoreMessage(type, message);
executed (the execution status of this line is deduced): QTestLog::ignoreMessage(type, message);
-
2264}
executed: }
Execution Count:469
469
2265 -
2266/*! \internal -
2267 */ -
2268 -
2269#ifdef Q_OS_WIN -
2270static inline bool isWindowsBuildDirectory(const QString &dirName) -
2271{ -
2272 return dirName.compare(QStringLiteral("Debug"), Qt::CaseInsensitive) == 0 -
2273 || dirName.compare(QStringLiteral("Release"), Qt::CaseInsensitive) == 0; -
2274} -
2275#endif -
2276 -
2277QString QTest::qFindTestData(const QString& base, const char *file, int line, const char *builddir) -
2278{ -
2279 QString found;
executed (the execution status of this line is deduced): QString found;
-
2280 -
2281 // Testdata priorities: -
2282 -
2283 // 1. relative to test binary. -
2284 if (qApp) {
evaluated: QCoreApplication::instance()
TRUEFALSE
yes
Evaluation Count:477
yes
Evaluation Count:83
83-477
2285 QDir binDirectory(QCoreApplication::applicationDirPath());
executed (the execution status of this line is deduced): QDir binDirectory(QCoreApplication::applicationDirPath());
-
2286 if (binDirectory.exists(base)) {
evaluated: binDirectory.exists(base)
TRUEFALSE
yes
Evaluation Count:472
yes
Evaluation Count:5
5-472
2287 found = binDirectory.absoluteFilePath(base);
executed (the execution status of this line is deduced): found = binDirectory.absoluteFilePath(base);
-
2288 }
executed: }
Execution Count:472
472
2289#ifdef Q_OS_WIN -
2290 // Windows: The executable is typically located in one of the -
2291 // 'Release' or 'Debug' directories. -
2292 else if (isWindowsBuildDirectory(binDirectory.dirName()) -
2293 && binDirectory.cdUp() && binDirectory.exists(base)) { -
2294 found = binDirectory.absoluteFilePath(base); -
2295 } -
2296#endif // Q_OS_WIN -
2297 else if (QTestLog::verboseLevel() >= 2) {
partially evaluated: QTestLog::verboseLevel() >= 2
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-5
2298 const QString candidate = QDir::toNativeSeparators(QCoreApplication::applicationDirPath() + QLatin1Char('/') + base);
never executed (the execution status of this line is deduced): const QString candidate = QDir::toNativeSeparators(QCoreApplication::applicationDirPath() + QLatin1Char('/') + base);
-
2299 QTestLog::info(qPrintable(
never executed (the execution status of this line is deduced): QTestLog::info(QString(QString::fromLatin1("testdata %1 not found relative to test binary [%2]; " "checking next location").arg(base, candidate)).toLocal8Bit().constData(),
-
2300 QString::fromLatin1("testdata %1 not found relative to test binary [%2]; "
never executed (the execution status of this line is deduced):
-
2301 "checking next location").arg(base, candidate)),
never executed (the execution status of this line is deduced):
-
2302 file, line);
never executed (the execution status of this line is deduced): file, line);
-
2303 }
never executed: }
0
2304 } -
2305 -
2306 // 2. installed path. -
2307 if (found.isEmpty()) {
evaluated: found.isEmpty()
TRUEFALSE
yes
Evaluation Count:88
yes
Evaluation Count:472
88-472
2308 const char *testObjectName = QTestResult::currentTestObjectName();
executed (the execution status of this line is deduced): const char *testObjectName = QTestResult::currentTestObjectName();
-
2309 if (testObjectName) {
partially evaluated: testObjectName
TRUEFALSE
yes
Evaluation Count:88
no
Evaluation Count:0
0-88
2310 QString testsPath = QLibraryInfo::location(QLibraryInfo::TestsPath);
executed (the execution status of this line is deduced): QString testsPath = QLibraryInfo::location(QLibraryInfo::TestsPath);
-
2311 QString candidate = QString::fromLatin1("%1/%2/%3")
executed (the execution status of this line is deduced): QString candidate = QString::fromLatin1("%1/%2/%3")
-
2312 .arg(testsPath, QFile::decodeName(testObjectName).toLower(), base);
executed (the execution status of this line is deduced): .arg(testsPath, QFile::decodeName(testObjectName).toLower(), base);
-
2313 if (QFileInfo(candidate).exists()) {
partially evaluated: QFileInfo(candidate).exists()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:88
0-88
2314 found = candidate;
never executed (the execution status of this line is deduced): found = candidate;
-
2315 }
never executed: }
0
2316 else if (QTestLog::verboseLevel() >= 2) {
partially evaluated: QTestLog::verboseLevel() >= 2
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:88
0-88
2317 QTestLog::info(qPrintable(
never executed (the execution status of this line is deduced): QTestLog::info(QString(QString::fromLatin1("testdata %1 not found in tests install path [%2]; " "checking next location") .arg(base, QDir::toNativeSeparators(candidate))).toLocal8Bit().constData(),
-
2318 QString::fromLatin1("testdata %1 not found in tests install path [%2]; "
never executed (the execution status of this line is deduced):
-
2319 "checking next location")
never executed (the execution status of this line is deduced):
-
2320 .arg(base, QDir::toNativeSeparators(candidate))),
never executed (the execution status of this line is deduced):
-
2321 file, line);
never executed (the execution status of this line is deduced): file, line);
-
2322 }
never executed: }
0
2323 } -
2324 }
executed: }
Execution Count:88
88
2325 -
2326 // 3. relative to test source. -
2327 if (found.isEmpty()) {
evaluated: found.isEmpty()
TRUEFALSE
yes
Evaluation Count:88
yes
Evaluation Count:472
88-472
2328 // srcdir is the directory containing the calling source file. -
2329 QFileInfo srcdir = QFileInfo(QFile::decodeName(file)).path();
executed (the execution status of this line is deduced): QFileInfo srcdir = QFileInfo(QFile::decodeName(file)).path();
-
2330 -
2331 // If the srcdir is relative, that means it is relative to the current working -
2332 // directory of the compiler at compile time, which should be passed in as `builddir'. -
2333 if (!srcdir.isAbsolute() && builddir) {
partially evaluated: !srcdir.isAbsolute()
TRUEFALSE
yes
Evaluation Count:88
no
Evaluation Count:0
partially evaluated: builddir
TRUEFALSE
yes
Evaluation Count:88
no
Evaluation Count:0
0-88
2334 srcdir.setFile(QFile::decodeName(builddir) + QLatin1String("/") + srcdir.filePath());
executed (the execution status of this line is deduced): srcdir.setFile(QFile::decodeName(builddir) + QLatin1String("/") + srcdir.filePath());
-
2335 }
executed: }
Execution Count:88
88
2336 -
2337 QString candidate = QString::fromLatin1("%1/%2").arg(srcdir.canonicalFilePath(), base);
executed (the execution status of this line is deduced): QString candidate = QString::fromLatin1("%1/%2").arg(srcdir.canonicalFilePath(), base);
-
2338 if (QFileInfo(candidate).exists()) {
evaluated: QFileInfo(candidate).exists()
TRUEFALSE
yes
Evaluation Count:86
yes
Evaluation Count:2
2-86
2339 found = candidate;
executed (the execution status of this line is deduced): found = candidate;
-
2340 }
executed: }
Execution Count:86
86
2341 else if (QTestLog::verboseLevel() >= 2) {
partially evaluated: QTestLog::verboseLevel() >= 2
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
2342 QTestLog::info(qPrintable(
never executed (the execution status of this line is deduced): QTestLog::info(QString(QString::fromLatin1("testdata %1 not found relative to source path [%2]") .arg(base, QDir::toNativeSeparators(candidate))).toLocal8Bit().constData(),
-
2343 QString::fromLatin1("testdata %1 not found relative to source path [%2]")
never executed (the execution status of this line is deduced):
-
2344 .arg(base, QDir::toNativeSeparators(candidate))),
never executed (the execution status of this line is deduced):
-
2345 file, line);
never executed (the execution status of this line is deduced): file, line);
-
2346 }
never executed: }
0
2347 } -
2348 -
2349 if (found.isEmpty()) {
evaluated: found.isEmpty()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:558
2-558
2350 QTest::qWarn(qPrintable(
executed (the execution status of this line is deduced): QTest::qWarn(QString(QString::fromLatin1("testdata %1 could not be located!").arg(base)).toLocal8Bit().constData(),
-
2351 QString::fromLatin1("testdata %1 could not be located!").arg(base)),
executed (the execution status of this line is deduced):
-
2352 file, line);
executed (the execution status of this line is deduced): file, line);
-
2353 }
executed: }
Execution Count:2
2
2354 else if (QTestLog::verboseLevel() >= 1) {
partially evaluated: QTestLog::verboseLevel() >= 1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:558
0-558
2355 QTestLog::info(qPrintable(
never executed (the execution status of this line is deduced): QTestLog::info(QString(QString::fromLatin1("testdata %1 was located at %2").arg(base, QDir::toNativeSeparators(found))).toLocal8Bit().constData(),
-
2356 QString::fromLatin1("testdata %1 was located at %2").arg(base, QDir::toNativeSeparators(found))),
never executed (the execution status of this line is deduced):
-
2357 file, line);
never executed (the execution status of this line is deduced): file, line);
-
2358 }
never executed: }
0
2359 -
2360 return found;
executed: return found;
Execution Count:560
560
2361} -
2362 -
2363/*! \internal -
2364 */ -
2365QString QTest::qFindTestData(const char *base, const char *file, int line, const char *builddir) -
2366{ -
2367 return qFindTestData(QFile::decodeName(base), file, line, builddir);
executed: return qFindTestData(QFile::decodeName(base), file, line, builddir);
Execution Count:381
381
2368} -
2369 -
2370/*! \internal -
2371 */ -
2372void *QTest::qData(const char *tagName, int typeId) -
2373{ -
2374 return fetchData(QTestResult::currentTestData(), tagName, typeId);
executed: return fetchData(QTestResult::currentTestData(), tagName, typeId);
Execution Count:176467
176467
2375} -
2376 -
2377/*! \internal -
2378 */ -
2379void *QTest::qGlobalData(const char *tagName, int typeId) -
2380{ -
2381 return fetchData(QTestResult::currentGlobalTestData(), tagName, typeId);
executed: return fetchData(QTestResult::currentGlobalTestData(), tagName, typeId);
Execution Count:1463
1463
2382} -
2383 -
2384/*! \internal -
2385 */ -
2386void *QTest::qElementData(const char *tagName, int metaTypeId) -
2387{ -
2388 QTEST_ASSERT(tagName);
never executed: qt_assert("tagName","qtestcase.cpp",2388);
executed: }
Execution Count:2191
partially evaluated: !(tagName)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2191
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2191
0-2191
2389 QTestData *data = QTestResult::currentTestData();
executed (the execution status of this line is deduced): QTestData *data = QTestResult::currentTestData();
-
2390 QTEST_ASSERT(data);
never executed: qt_assert("data","qtestcase.cpp",2390);
executed: }
Execution Count:2191
partially evaluated: !(data)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2191
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2191
0-2191
2391 QTEST_ASSERT(data->parent());
never executed: qt_assert("data->parent()","qtestcase.cpp",2391);
executed: }
Execution Count:2191
partially evaluated: !(data->parent())
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2191
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2191
0-2191
2392 -
2393 int idx = data->parent()->indexOf(tagName);
executed (the execution status of this line is deduced): int idx = data->parent()->indexOf(tagName);
-
2394 QTEST_ASSERT(idx != -1);
never executed: qt_assert("idx != -1","qtestcase.cpp",2394);
executed: }
Execution Count:2191
partially evaluated: !(idx != -1)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2191
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2191
0-2191
2395 QTEST_ASSERT(data->parent()->elementTypeId(idx) == metaTypeId);
never executed: qt_assert("data->parent()->elementTypeId(idx) == metaTypeId","qtestcase.cpp",2395);
executed: }
Execution Count:2191
partially evaluated: !(data->parent()->elementTypeId(idx) == metaTypeId)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2191
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2191
0-2191
2396 -
2397 return data->data(data->parent()->indexOf(tagName));
executed: return data->data(data->parent()->indexOf(tagName));
Execution Count:2191
2191
2398} -
2399 -
2400/*! \internal -
2401 */ -
2402void QTest::addColumnInternal(int id, const char *name) -
2403{ -
2404 QTestTable *tbl = QTestTable::currentTestTable();
executed (the execution status of this line is deduced): QTestTable *tbl = QTestTable::currentTestTable();
-
2405 QTEST_ASSERT_X(tbl, "QTest::addColumn()", "Cannot add testdata outside of a _data slot.");
never executed: qt_assert_x("QTest::addColumn()", "Cannot add testdata outside of a _data slot.","qtestcase.cpp",2405);
executed: }
Execution Count:5550
partially evaluated: !(tbl)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5550
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5550
0-5550
2406 -
2407 tbl->addColumn(id, name);
executed (the execution status of this line is deduced): tbl->addColumn(id, name);
-
2408}
executed: }
Execution Count:5550
5550
2409 -
2410/*! -
2411 Appends a new row to the current test data. \a dataTag is the name of -
2412 the testdata that will appear in the test output. Returns a QTestData reference -
2413 that can be used to stream in data. -
2414 -
2415 Example: -
2416 \snippet code/src_qtestlib_qtestcase.cpp 20 -
2417 -
2418 \b {Note:} This macro can only be used in a test's data function -
2419 that is invoked by the test framework. -
2420 -
2421 See \l {Chapter 2: Data Driven Testing}{Data Driven Testing} for -
2422 a more extensive example. -
2423 -
2424 \sa addColumn(), QFETCH() -
2425*/ -
2426QTestData &QTest::newRow(const char *dataTag) -
2427{ -
2428 QTEST_ASSERT_X(dataTag, "QTest::newRow()", "Data tag can not be null");
never executed: qt_assert_x("QTest::newRow()", "Data tag can not be null","qtestcase.cpp",2428);
executed: }
Execution Count:61136
partially evaluated: !(dataTag)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:61136
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:61136
0-61136
2429 QTestTable *tbl = QTestTable::currentTestTable();
executed (the execution status of this line is deduced): QTestTable *tbl = QTestTable::currentTestTable();
-
2430 QTEST_ASSERT_X(tbl, "QTest::newRow()", "Cannot add testdata outside of a _data slot.");
never executed: qt_assert_x("QTest::newRow()", "Cannot add testdata outside of a _data slot.","qtestcase.cpp",2430);
executed: }
Execution Count:61136
partially evaluated: !(tbl)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:61136
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:61136
0-61136
2431 QTEST_ASSERT_X(tbl->elementCount(), "QTest::newRow()", "Must add columns before attempting to add rows.");
never executed: qt_assert_x("QTest::newRow()", "Must add columns before attempting to add rows.","qtestcase.cpp",2431);
executed: }
Execution Count:61136
partially evaluated: !(tbl->elementCount())
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:61136
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:61136
0-61136
2432 -
2433 return *tbl->newData(dataTag);
executed: return *tbl->newData(dataTag);
Execution Count:61136
61136
2434} -
2435 -
2436/*! \fn void QTest::addColumn(const char *name, T *dummy = 0) -
2437 -
2438 Adds a column with type \c{T} to the current test data. -
2439 \a name is the name of the column. \a dummy is a workaround -
2440 for buggy compilers and can be ignored. -
2441 -
2442 To populate the column with values, newRow() can be used. Use -
2443 \l QFETCH() to fetch the data in the actual test. -
2444 -
2445 Example: -
2446 \snippet code/src_qtestlib_qtestcase.cpp 21 -
2447 -
2448 To add custom types to the testdata, the type must be registered with -
2449 QMetaType via \l Q_DECLARE_METATYPE(). -
2450 -
2451 \b {Note:} This macro can only be used in a test's data function -
2452 that is invoked by the test framework. -
2453 -
2454 See \l {Chapter 2: Data Driven Testing}{Data Driven Testing} for -
2455 a more extensive example. -
2456 -
2457 \sa QTest::newRow(), QFETCH(), QMetaType -
2458*/ -
2459 -
2460/*! -
2461 Returns the name of the test function that is currently executed. -
2462 -
2463 Example: -
2464 -
2465 \snippet code/src_qtestlib_qtestcase.cpp 22 -
2466*/ -
2467const char *QTest::currentTestFunction() -
2468{ -
2469 return QTestResult::currentTestFunction();
executed: return QTestResult::currentTestFunction();
Execution Count:357
357
2470} -
2471 -
2472/*! -
2473 Returns the name of the current test data. If the test doesn't -
2474 have any assigned testdata, the function returns 0. -
2475*/ -
2476const char *QTest::currentDataTag() -
2477{ -
2478 return QTestResult::currentDataTag();
executed: return QTestResult::currentDataTag();
Execution Count:3918
3918
2479} -
2480 -
2481/*! -
2482 Returns true if the current test function failed, otherwise false. -
2483*/ -
2484bool QTest::currentTestFailed() -
2485{ -
2486 return QTestResult::currentTestFailed();
executed: return QTestResult::currentTestFailed();
Execution Count:546
546
2487} -
2488 -
2489/*! -
2490 Sleeps for \a ms milliseconds, blocking execution of the -
2491 test. qSleep() will not do any event processing and leave your test -
2492 unresponsive. Network communication might time out while -
2493 sleeping. Use \l qWait() to do non-blocking sleeping. -
2494 -
2495 \a ms must be greater than 0. -
2496 -
2497 \b {Note:} The qSleep() function calls either \c nanosleep() on -
2498 unix or \c Sleep() on windows, so the accuracy of time spent in -
2499 qSleep() depends on the operating system. -
2500 -
2501 Example: -
2502 \snippet code/src_qtestlib_qtestcase.cpp 23 -
2503 -
2504 \sa qWait() -
2505*/ -
2506void QTest::qSleep(int ms) -
2507{ -
2508 QTEST_ASSERT(ms > 0);
never executed: qt_assert("ms > 0","qtestcase.cpp",2508);
executed: }
Execution Count:76695
partially evaluated: !(ms > 0)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:76696
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:76691
0-76696
2509 -
2510#ifdef Q_OS_WIN -
2511 Sleep(uint(ms)); -
2512#else -
2513 struct timespec ts = { ms / 1000, (ms % 1000) * 1000 * 1000 };
executed (the execution status of this line is deduced): struct timespec ts = { ms / 1000, (ms % 1000) * 1000 * 1000 };
-
2514 nanosleep(&ts, NULL);
executed (the execution status of this line is deduced): nanosleep(&ts, __null);
-
2515#endif -
2516}
executed: }
Execution Count:76816
76816
2517 -
2518/*! \internal -
2519 */ -
2520QObject *QTest::testObject() -
2521{ -
2522 return currentTestObject;
executed: return currentTestObject;
Execution Count:3
3
2523} -
2524 -
2525/*! \internal -
2526 This function is called by various specializations of QTest::qCompare -
2527 to decide whether to report a failure and to produce verbose test output. -
2528 -
2529 The failureMsg parameter can be null, in which case a default message -
2530 will be output if the compare fails. If the compare succeeds, failureMsg -
2531 will not be output. -
2532 -
2533 If the caller has already passed a failure message showing the compared -
2534 values, or if those values cannot be stringified, val1 and val2 can be null. -
2535 */ -
2536bool QTest::compare_helper(bool success, const char *failureMsg, -
2537 char *val1, char *val2, -
2538 const char *actual, const char *expected, -
2539 const char *file, int line) -
2540{ -
2541 return QTestResult::compare(success, failureMsg, val1, val2, actual, expected, file, line);
executed: return QTestResult::compare(success, failureMsg, val1, val2, actual, expected, file, line);
Execution Count:24379010
24379010
2542} -
2543 -
2544/*! \fn bool QTest::qCompare(float const &t1, float const &t2, const char *actual, const char *expected, const char *file, int line) -
2545\internal -
2546 */ -
2547bool QTest::qCompare(float const &t1, float const &t2, const char *actual, const char *expected, -
2548 const char *file, int line) -
2549{ -
2550 return compare_helper(qFuzzyCompare(t1, t2), "Compared floats are not the same (fuzzy compare)",
executed: return compare_helper(qFuzzyCompare(t1, t2), "Compared floats are not the same (fuzzy compare)", toString(t1), toString(t2), actual, expected, file, line);
Execution Count:1168
1168
2551 toString(t1), toString(t2), actual, expected, file, line);
executed: return compare_helper(qFuzzyCompare(t1, t2), "Compared floats are not the same (fuzzy compare)", toString(t1), toString(t2), actual, expected, file, line);
Execution Count:1168
1168
2552} -
2553 -
2554/*! \fn bool QTest::qCompare(double const &t1, double const &t2, const char *actual, const char *expected, const char *file, int line) -
2555\internal -
2556 */ -
2557bool QTest::qCompare(double const &t1, double const &t2, const char *actual, const char *expected, -
2558 const char *file, int line) -
2559{ -
2560 return compare_helper(qFuzzyCompare(t1, t2), "Compared doubles are not the same (fuzzy compare)",
executed: return compare_helper(qFuzzyCompare(t1, t2), "Compared doubles are not the same (fuzzy compare)", toString(t1), toString(t2), actual, expected, file, line);
Execution Count:2180502
2180502
2561 toString(t1), toString(t2), actual, expected, file, line);
executed: return compare_helper(qFuzzyCompare(t1, t2), "Compared doubles are not the same (fuzzy compare)", toString(t1), toString(t2), actual, expected, file, line);
Execution Count:2180502
2180502
2562} -
2563 -
2564#define TO_STRING_IMPL(TYPE, FORMAT) \ -
2565template <> Q_TESTLIB_EXPORT char *QTest::toString<TYPE >(const TYPE &t) \ -
2566{ \ -
2567 char *msg = new char[128]; \ -
2568 qsnprintf(msg, 128, #FORMAT, t); \ -
2569 return msg; \ -
2570} -
2571 -
2572TO_STRING_IMPL(short, %hd)
executed: return msg;
Execution Count:318
318
2573TO_STRING_IMPL(ushort, %hu)
executed: return msg;
Execution Count:862
862
2574TO_STRING_IMPL(int, %d)
executed: return msg;
Execution Count:30037538
30037538
2575TO_STRING_IMPL(uint, %u)
executed: return msg;
Execution Count:2314488
2314488
2576TO_STRING_IMPL(long, %ld)
executed: return msg;
Execution Count:142
142
2577TO_STRING_IMPL(ulong, %lu)
executed: return msg;
Execution Count:1726
1726
2578#if defined(Q_OS_WIN) -
2579TO_STRING_IMPL(qint64, %I64d) -
2580TO_STRING_IMPL(quint64, %I64u) -
2581#else -
2582TO_STRING_IMPL(qint64, %lld)
executed: return msg;
Execution Count:1569282
1569282
2583TO_STRING_IMPL(quint64, %llu)
executed: return msg;
Execution Count:9994
9994
2584#endif -
2585TO_STRING_IMPL(bool, %d)
executed: return msg;
Execution Count:191648
191648
2586TO_STRING_IMPL(char, %c)
executed: return msg;
Execution Count:3534234
3534234
2587TO_STRING_IMPL(float, %g)
executed: return msg;
Execution Count:2336
2336
2588TO_STRING_IMPL(double, %lg)
executed: return msg;
Execution Count:4361004
4361004
2589 -
2590/*! \internal -
2591 */ -
2592char *QTest::toString(const char *str) -
2593{ -
2594 if (!str)
evaluated: !str
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:1208
16-1208
2595 return 0;
executed: return 0;
Execution Count:16
16
2596 char *msg = new char[strlen(str) + 1];
executed (the execution status of this line is deduced): char *msg = new char[strlen(str) + 1];
-
2597 return qstrcpy(msg, str);
executed: return qstrcpy(msg, str);
Execution Count:1208
1208
2598} -
2599 -
2600/*! \internal -
2601 */ -
2602char *QTest::toString(const void *p) -
2603{ -
2604 char *msg = new char[128];
executed (the execution status of this line is deduced): char *msg = new char[128];
-
2605 qsnprintf(msg, 128, "%p", p);
executed (the execution status of this line is deduced): qsnprintf(msg, 128, "%p", p);
-
2606 return msg;
executed: return msg;
Execution Count:1916364
1916364
2607} -
2608 -
2609/*! \internal -
2610 */ -
2611bool QTest::compare_string_helper(const char *t1, const char *t2, const char *actual, -
2612 const char *expected, const char *file, int line) -
2613{ -
2614 return compare_helper(qstrcmp(t1, t2) == 0, "Compared strings are not the same",
executed: return compare_helper(qstrcmp(t1, t2) == 0, "Compared strings are not the same", toString(t1), toString(t2), actual, expected, file, line);
Execution Count:612
612
2615 toString(t1), toString(t2), actual, expected, file, line);
executed: return compare_helper(qstrcmp(t1, t2) == 0, "Compared strings are not the same", toString(t1), toString(t2), actual, expected, file, line);
Execution Count:612
612
2616} -
2617 -
2618/*! \fn bool QTest::compare_ptr_helper(const void *t1, const void *t2, const char *actual, const char *expected, const char *file, int line); -
2619 \internal -
2620*/ -
2621 -
2622/*! \fn bool QTest::qCompare(T1 const &, T2 const &, const char *, const char *, const char *, int); -
2623 \internal -
2624*/ -
2625 -
2626 -
2627/*! \fn void QTest::mouseEvent(MouseAction action, QWidget *widget, Qt::MouseButton button, Qt::KeyboardModifiers stateKey, QPoint pos, int delay=-1) -
2628 \internal -
2629*/ -
2630 -
2631/*! \fn bool QTest::qCompare(QIcon const &t1, QIcon const &t2, const char *actual, const char *expected, const char *file, int line) -
2632 \internal -
2633*/ -
2634 -
2635/*! \fn bool QTest::qCompare(QPixmap const &t1, QPixmap const &t2, const char *actual, const char *expected, const char *file, int line) -
2636 \internal -
2637*/ -
2638 -
2639/*! \fn bool QTest::qCompare(T const &t1, T const &t2, const char *actual, const char *expected, const char *file, int line) -
2640 \internal -
2641*/ -
2642 -
2643/*! \fn bool QTest::qCompare(const T *t1, const T *t2, const char *actual, const char *expected, const char *file, int line) -
2644 \internal -
2645*/ -
2646 -
2647/*! \fn bool QTest::qCompare(T *t1, T *t2, const char *actual, const char *expected, const char *file, int line) -
2648 \internal -
2649*/ -
2650 -
2651/*! \fn bool QTest::qCompare(const T1 *t1, const T2 *t2, const char *actual, const char *expected, const char *file, int line) -
2652 \internal -
2653*/ -
2654 -
2655/*! \fn bool QTest::qCompare(T1 *t1, T2 *t2, const char *actual, const char *expected, const char *file, int line) -
2656 \internal -
2657*/ -
2658 -
2659/*! \fn bool QTest::qCompare(const char *t1, const char *t2, const char *actual, const char *expected, const char *file, int line) -
2660 \internal -
2661*/ -
2662 -
2663/*! \fn bool QTest::qCompare(char *t1, char *t2, const char *actual, const char *expected, const char *file, int line) -
2664 \internal -
2665*/ -
2666 -
2667/*! \fn bool QTest::qCompare(char *t1, const char *t2, const char *actual, const char *expected, const char *file, int line) -
2668 \internal -
2669*/ -
2670 -
2671/*! \fn bool QTest::qCompare(const char *t1, char *t2, const char *actual, const char *expected, const char *file, int line) -
2672 \internal -
2673*/ -
2674 -
2675/*! \fn bool QTest::qCompare(QString const &t1, QLatin1String const &t2, const char *actual, const char *expected, const char *file, int line) -
2676 \internal -
2677*/ -
2678 -
2679/*! \fn bool QTest::qCompare(QLatin1String const &t1, QString const &t2, const char *actual, const char *expected, const char *file, int line) -
2680 \internal -
2681*/ -
2682 -
2683/*! \fn bool QTest::qCompare(QStringList const &t1, QStringList const &t2, const char *actual, const char *expected, const char *file, int line) -
2684 \internal -
2685*/ -
2686 -
2687/*! \fn bool QTest::qCompare(QFlags<T> const &t1, T const &t2, const char *actual, const char *expected, const char *file, int line) -
2688 \internal -
2689*/ -
2690 -
2691/*! \fn bool QTest::qCompare(QFlags<T> const &t1, int const &t2, const char *actual, const char *expected, const char *file, int line) -
2692 \internal -
2693*/ -
2694 -
2695/*! \fn bool QTest::qCompare(bool const &t1, int const &t2, const char *actual, const char *expected, const char *file, int line) -
2696 \internal -
2697 */ -
2698 -
2699/*! \fn bool QTest::qTest(const T& actual, const char *elementName, const char *actualStr, const char *expected, const char *file, int line) -
2700 \internal -
2701*/ -
2702 -
2703/*! \fn void QTest::sendKeyEvent(KeyAction action, QWidget *widget, Qt::Key code, QString text, Qt::KeyboardModifiers modifier, int delay=-1) -
2704 \internal -
2705*/ -
2706 -
2707/*! \fn void QTest::sendKeyEvent(KeyAction action, QWidget *widget, Qt::Key code, char ascii, Qt::KeyboardModifiers modifier, int delay=-1) -
2708 \internal -
2709*/ -
2710 -
2711/*! \fn void QTest::simulateEvent(QWidget *widget, bool press, int code, Qt::KeyboardModifiers modifier, QString text, bool repeat, int delay=-1) -
2712 \internal -
2713*/ -
2714 -
2715QT_END_NAMESPACE -
2716 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial