summaryrefslogtreecommitdiffstats
path: root/src/testlib
diff options
context:
space:
mode:
Diffstat (limited to 'src/testlib')
-rw-r--r--src/testlib/3rdparty/CALLGRIND_LICENSE.txt35
-rw-r--r--src/testlib/3rdparty/CYCLE_LICENSE.txt18
-rw-r--r--src/testlib/3rdparty/LINUX_LICENSE.txt351
-rw-r--r--src/testlib/3rdparty/qt_attribution.json45
-rw-r--r--src/testlib/doc/snippets/code/src_qtestlib_qtestcase.cpp9
-rw-r--r--src/testlib/doc/src/qttest-index.qdoc13
-rw-r--r--src/testlib/qabstracttestlogger.cpp2
-rw-r--r--src/testlib/qbenchmark.cpp1
-rw-r--r--src/testlib/qbenchmarkmeasurement.cpp2
-rw-r--r--src/testlib/qbenchmarkmeasurement_p.h36
-rw-r--r--src/testlib/qbenchmarkmetric.cpp5
-rw-r--r--src/testlib/qbenchmarkmetric.h3
-rw-r--r--src/testlib/qbenchmarkperfevents.cpp9
-rw-r--r--src/testlib/qbenchmarktimemeasurers_p.h96
-rw-r--r--src/testlib/qplaintestlogger.cpp15
-rw-r--r--src/testlib/qteamcitylogger.cpp12
-rw-r--r--src/testlib/qtest.h27
-rw-r--r--src/testlib/qtest_network.h126
-rw-r--r--src/testlib/qtestblacklist.cpp11
-rw-r--r--src/testlib/qtestcase.cpp87
-rw-r--r--src/testlib/qtestcase.h44
-rw-r--r--src/testlib/qtestcase.qdoc22
-rw-r--r--src/testlib/qtestmouse.h4
-rw-r--r--src/testlib/qtesttouch.h1
-rw-r--r--src/testlib/qxctestlogger.mm2
-rw-r--r--src/testlib/qxunittestlogger.cpp2
-rw-r--r--src/testlib/testlib.pro9
27 files changed, 838 insertions, 149 deletions
diff --git a/src/testlib/3rdparty/CALLGRIND_LICENSE.txt b/src/testlib/3rdparty/CALLGRIND_LICENSE.txt
new file mode 100644
index 0000000000..0a6a793422
--- /dev/null
+++ b/src/testlib/3rdparty/CALLGRIND_LICENSE.txt
@@ -0,0 +1,35 @@
+ This file is part of callgrind, a valgrind tool for cache simulation
+ and call tree tracing.
+
+ Copyright (C) 2003-2007 Josef Weidendorfer. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. The origin of this software must not be misrepresented; you must
+ not claim that you wrote the original software. If you use this
+ software in a product, an acknowledgment in the product
+ documentation would be appreciated but is not required.
+
+ 3. Altered source versions must be plainly marked as such, and must
+ not be misrepresented as being the original software.
+
+ 4. The name of the author may not be used to endorse or promote
+ products derived from this software without specific prior written
+ permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/src/testlib/3rdparty/CYCLE_LICENSE.txt b/src/testlib/3rdparty/CYCLE_LICENSE.txt
new file mode 100644
index 0000000000..c9b44cb8aa
--- /dev/null
+++ b/src/testlib/3rdparty/CYCLE_LICENSE.txt
@@ -0,0 +1,18 @@
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/src/testlib/3rdparty/LINUX_LICENSE.txt b/src/testlib/3rdparty/LINUX_LICENSE.txt
new file mode 100644
index 0000000000..c0ff68a2b2
--- /dev/null
+++ b/src/testlib/3rdparty/LINUX_LICENSE.txt
@@ -0,0 +1,351 @@
+
+ NOTE! This copyright does *not* cover user programs that use kernel
+ services by normal system calls - this is merely considered normal use
+ of the kernel, and does *not* fall under the heading of "derived work".
+ Also note that the GPL below is copyrighted by the Free Software
+ Foundation, but the instance of code that it refers to (the linux
+ kernel) is copyrighted by me and others who actually wrote it.
+
+ Linus Torvalds
+
+----------------------------------------
+
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 675 Mass Ave, Cambridge, MA 02139, USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ Appendix: How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) 19yy <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) 19yy name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/src/testlib/3rdparty/qt_attribution.json b/src/testlib/3rdparty/qt_attribution.json
new file mode 100644
index 0000000000..d8b0ad1fc7
--- /dev/null
+++ b/src/testlib/3rdparty/qt_attribution.json
@@ -0,0 +1,45 @@
+[
+ {
+ "Id": "callgrind",
+ "Name": "Callgrind",
+ "QDocModule": "qttestlib",
+ "QtUsage": "Used on Linux ond MacOS in the Qt Test module.",
+ "Files": "valgrind_p.h callgrind_p.h",
+
+ "Description": "Part of Valgrind: an instrumentation framework for building dynamic analysis tools.",
+ "Homepage": "http://valgrind.org/",
+ "License": "BSD 4-clause \"Original\" or \"Old\" License",
+ "LicenseId": "BSD-4-Clause",
+ "LicenseFile": "CALLGRIND_LICENSE.txt",
+ "Copyright": "Copyright (C) 2003-2007 Josef Weidendorfer. All rights reserved."
+ },
+ {
+ "Id": "cycle",
+ "Name": "Cycle",
+ "QDocModule": "qttestlib",
+ "QtUsage": "Used in the Qt Test module.",
+ "Files": "cycle_p.h",
+
+ "Description": "Allows to access the CPU's cycle counters.",
+ "License": "MIT License",
+ "LicenseId": "MIT",
+ "LicenseFile": "CYCLE_LICENSE.txt",
+ "Copyright": "Copyright (c) 2003, 2006 Matteo Frigo
+Copyright (c) 2003, 2006 Massachusetts Institute of Technology"
+ },
+ {
+ "Id": "linuxperf",
+ "Name": "Linux Performance Events",
+ "QDocModule": "qttestlib",
+ "QtUsage": "Used on Linux and Android in the Qt Test module.",
+ "Files": "linux_perf_event_p.h",
+
+ "Description": "Allows access to the Linux kernel's performance events.",
+ "License": "GNU General Public License v2.0 only",
+ "LicenseId": "GPL-2.0",
+ "LicenseFile": "LINUX_LICENSE.txt",
+ "Copyright": "Copyright (C) 2008-2009, Thomas Gleixner <tglx@linutronix.de>
+Copyright (C) 2008-2011, Red Hat, Inc., Ingo Molnar
+Copyright (C) 2008-2011, Red Hat, Inc., Peter Zijlstra"
+ }
+]
diff --git a/src/testlib/doc/snippets/code/src_qtestlib_qtestcase.cpp b/src/testlib/doc/snippets/code/src_qtestlib_qtestcase.cpp
index 2cb174022d..2c57550c3d 100644
--- a/src/testlib/doc/snippets/code/src_qtestlib_qtestcase.cpp
+++ b/src/testlib/doc/snippets/code/src_qtestlib_qtestcase.cpp
@@ -241,17 +241,18 @@ QTest::qWaitForWindowShown(&widget);
//! [24]
//! [25]
+QTouchDevice *dev = QTest::createTouchDevice();
QWidget widget;
-QTest::touchEvent(&widget)
+QTest::touchEvent(&widget, dev)
.press(0, QPoint(10, 10));
-QTest::touchEvent(&widget)
+QTest::touchEvent(&widget, dev)
.stationary(0)
.press(1, QPoint(40, 10));
-QTest::touchEvent(&widget)
+QTest::touchEvent(&widget, dev)
.move(0, QPoint(12, 12))
.move(1, QPoint(45, 5));
-QTest::touchEvent(&widget)
+QTest::touchEvent(&widget, dev)
.release(0, QPoint(12, 12))
.release(1, QPoint(45, 5));
//! [25]
diff --git a/src/testlib/doc/src/qttest-index.qdoc b/src/testlib/doc/src/qttest-index.qdoc
index b16ab7944a..36ebfee463 100644
--- a/src/testlib/doc/src/qttest-index.qdoc
+++ b/src/testlib/doc/src/qttest-index.qdoc
@@ -50,6 +50,19 @@
\li \l{Qt Test Tutorial}
\endlist
+ \section1 Licenses and Attributions
+
+ Qt Test is available under commercial licenses from \l{The Qt Company}.
+ In addition, it is available under the
+ \l{GNU Lesser General Public License, version 3}, or
+ the \l{GNU General Public License, version 2}.
+ See \l{Qt Licensing} for further details.
+
+ Furthermore Qt Test potentially contains third party
+ modules under following permissive licenses:
+
+ \generatelist{groupsbymodule attributions-qttestlib}
+
\section1 Reference
These are links to the API reference materials.
diff --git a/src/testlib/qabstracttestlogger.cpp b/src/testlib/qabstracttestlogger.cpp
index 72b5eb3ed7..8337600fa1 100644
--- a/src/testlib/qabstracttestlogger.cpp
+++ b/src/testlib/qabstracttestlogger.cpp
@@ -62,7 +62,7 @@ QAbstractTestLogger::QAbstractTestLogger(const char *filename)
stream = stdout;
return;
}
-#if defined(_MSC_VER) && _MSC_VER >= 1400 && !defined(Q_OS_WINCE)
+#if defined(_MSC_VER)
if (::fopen_s(&stream, filename, "wt")) {
#else
stream = ::fopen(filename, "wt");
diff --git a/src/testlib/qbenchmark.cpp b/src/testlib/qbenchmark.cpp
index c884d5d740..c933a16c35 100644
--- a/src/testlib/qbenchmark.cpp
+++ b/src/testlib/qbenchmark.cpp
@@ -40,6 +40,7 @@
#include <QtTest/qbenchmark.h>
#include <QtTest/private/qbenchmark_p.h>
#include <QtTest/private/qbenchmarkmetric_p.h>
+#include <QtTest/private/qbenchmarktimemeasurers_p.h>
#include <QtCore/qprocess.h>
#include <QtCore/qdir.h>
diff --git a/src/testlib/qbenchmarkmeasurement.cpp b/src/testlib/qbenchmarkmeasurement.cpp
index ac4d75ce3b..228ab15f99 100644
--- a/src/testlib/qbenchmarkmeasurement.cpp
+++ b/src/testlib/qbenchmarkmeasurement.cpp
@@ -37,7 +37,7 @@
**
****************************************************************************/
-#include <QtTest/private/qbenchmarkmeasurement_p.h>
+#include <QtTest/private/qbenchmarktimemeasurers_p.h>
#include <QtTest/private/qbenchmark_p.h>
#include <QtTest/private/qbenchmarkmetric_p.h>
#include <QtTest/qbenchmark.h>
diff --git a/src/testlib/qbenchmarkmeasurement_p.h b/src/testlib/qbenchmarkmeasurement_p.h
index 1444439e11..8dbfd4b618 100644
--- a/src/testlib/qbenchmarkmeasurement_p.h
+++ b/src/testlib/qbenchmarkmeasurement_p.h
@@ -51,8 +51,6 @@
// We mean it.
//
-#include <QtCore/qelapsedtimer.h>
-#include <QtTest/private/cycle_p.h>
#include <QtTest/qbenchmark.h>
QT_BEGIN_NAMESPACE
@@ -73,40 +71,6 @@ public:
virtual QTest::QBenchmarkMetric metricType() = 0;
};
-class QBenchmarkTimeMeasurer : public QBenchmarkMeasurerBase
-{
-public:
- void start();
- qint64 checkpoint();
- qint64 stop();
- bool isMeasurementAccepted(qint64 measurement);
- int adjustIterationCount(int sugestion);
- int adjustMedianCount(int suggestion);
- bool needsWarmupIteration();
- QTest::QBenchmarkMetric metricType();
-private:
- QElapsedTimer time;
-};
-
-#ifdef HAVE_TICK_COUNTER // defined in 3rdparty/cycle_p.h
-
-class QBenchmarkTickMeasurer : public QBenchmarkMeasurerBase
-{
-public:
- void start();
- qint64 checkpoint();
- qint64 stop();
- bool isMeasurementAccepted(qint64 measurement);
- int adjustIterationCount(int);
- int adjustMedianCount(int suggestion);
- bool needsWarmupIteration();
- QTest::QBenchmarkMetric metricType();
-private:
- CycleCounterTicks startTicks;
-};
-
-#endif
-
QT_END_NAMESPACE
#endif // QBENCHMARKMEASUREMENT_P_H
diff --git a/src/testlib/qbenchmarkmetric.cpp b/src/testlib/qbenchmarkmetric.cpp
index 0a9072907f..0ba55dbeb7 100644
--- a/src/testlib/qbenchmarkmetric.cpp
+++ b/src/testlib/qbenchmarkmetric.cpp
@@ -56,6 +56,7 @@
\value CPUTicks CPU time
\value CPUMigrations Process migrations between CPUs
\value CPUCycles CPU cycles
+ \value RefCPUCycles Reference CPU cycles
\value BusCycles Bus cycles
\value StalledCycles Cycles stalled
\value InstructionReads Instruction reads
@@ -108,6 +109,8 @@ const char * QTest::benchmarkMetricName(QBenchmarkMetric metric)
return "CPUMigrations";
case CPUCycles:
return "CPUCycles";
+ case RefCPUCycles:
+ return "RefCPUCycles";
case BusCycles:
return "BusCycles";
case StalledCycles:
@@ -180,6 +183,8 @@ const char * QTest::benchmarkMetricUnit(QBenchmarkMetric metric)
return "CPU migrations";
case CPUCycles:
return "CPU cycles";
+ case RefCPUCycles:
+ return "Reference CPU cycles";
case BusCycles:
return "bus cycles";
case StalledCycles:
diff --git a/src/testlib/qbenchmarkmetric.h b/src/testlib/qbenchmarkmetric.h
index 44bf14b9b6..6e423473b1 100644
--- a/src/testlib/qbenchmarkmetric.h
+++ b/src/testlib/qbenchmarkmetric.h
@@ -78,7 +78,8 @@ enum QBenchmarkMetric {
MinorPageFaults,
MajorPageFaults,
AlignmentFaults,
- EmulationFaults
+ EmulationFaults,
+ RefCPUCycles,
};
}
diff --git a/src/testlib/qbenchmarkperfevents.cpp b/src/testlib/qbenchmarkperfevents.cpp
index 587d3e0124..d6db40ce52 100644
--- a/src/testlib/qbenchmarkperfevents.cpp
+++ b/src/testlib/qbenchmarkperfevents.cpp
@@ -153,6 +153,7 @@ bool QBenchmarkPerfEventsMeasurer::isAvailable()
Event type Event counter Unit Name and aliases
HARDWARE CPU_CYCLES CPUCycles cycles cpu-cycles
+ HARDWARE REF_CPU_CYCLES RefCPUCycles ref-cycles
HARDWARE INSTRUCTIONS Instructions instructions
HARDWARE CACHE_REFERENCES CacheReferences cache-references
HARDWARE CACHE_MISSES CacheMisses cache-misses
@@ -321,6 +322,7 @@ static const char eventlist_strings[] =
"migrations\0"
"minor-faults\0"
"page-faults\0"
+ "ref-cycles\0"
"stalled-cycles-backend\0"
"stalled-cycles-frontend\0"
"task-clock\0"
@@ -407,9 +409,10 @@ static const Events eventlist[] = {
{ 1256, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CPU_MIGRATIONS, QTest::CPUMigrations },
{ 1267, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS_MIN, QTest::MinorPageFaults },
{ 1280, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS, QTest::PageFaults },
- { 1292, PERF_TYPE_HARDWARE, PERF_COUNT_HW_STALLED_CYCLES_BACKEND, QTest::StalledCycles },
- { 1315, PERF_TYPE_HARDWARE, PERF_COUNT_HW_STALLED_CYCLES_FRONTEND, QTest::StalledCycles },
- { 1339, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_TASK_CLOCK, QTest::WalltimeMilliseconds },
+ { 1292, PERF_TYPE_HARDWARE, PERF_COUNT_HW_REF_CPU_CYCLES, QTest::RefCPUCycles },
+ { 1303, PERF_TYPE_HARDWARE, PERF_COUNT_HW_STALLED_CYCLES_BACKEND, QTest::StalledCycles },
+ { 1326, PERF_TYPE_HARDWARE, PERF_COUNT_HW_STALLED_CYCLES_FRONTEND, QTest::StalledCycles },
+ { 1350, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_TASK_CLOCK, QTest::WalltimeMilliseconds },
{ 0, PERF_TYPE_MAX, 0, QTest::Events }
};
/* -- END GENERATED CODE -- */
diff --git a/src/testlib/qbenchmarktimemeasurers_p.h b/src/testlib/qbenchmarktimemeasurers_p.h
new file mode 100644
index 0000000000..e5ffb1157d
--- /dev/null
+++ b/src/testlib/qbenchmarktimemeasurers_p.h
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtTest module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QBENCHMARKTIMEMEASURERS_P_H
+#define QBENCHMARKTIMEMEASURERS_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtTest/private/qbenchmarkmeasurement_p.h>
+#include <QtCore/qelapsedtimer.h>
+#include <QtTest/private/cycle_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QBenchmarkTimeMeasurer : public QBenchmarkMeasurerBase
+{
+public:
+ void start();
+ qint64 checkpoint();
+ qint64 stop();
+ bool isMeasurementAccepted(qint64 measurement);
+ int adjustIterationCount(int sugestion);
+ int adjustMedianCount(int suggestion);
+ bool needsWarmupIteration();
+ QTest::QBenchmarkMetric metricType();
+private:
+ QElapsedTimer time;
+};
+
+#ifdef HAVE_TICK_COUNTER // defined in 3rdparty/cycle_p.h
+
+class QBenchmarkTickMeasurer : public QBenchmarkMeasurerBase
+{
+public:
+ void start();
+ qint64 checkpoint();
+ qint64 stop();
+ bool isMeasurementAccepted(qint64 measurement);
+ int adjustIterationCount(int);
+ int adjustMedianCount(int suggestion);
+ bool needsWarmupIteration();
+ QTest::QBenchmarkMetric metricType();
+private:
+ CycleCounterTicks startTicks;
+};
+
+#endif // HAVE_TICK_COUNTER
+
+QT_END_NAMESPACE
+
+#endif // QBENCHMARKTIMEMEASURERS_P_H
diff --git a/src/testlib/qplaintestlogger.cpp b/src/testlib/qplaintestlogger.cpp
index a286246acd..dc20d922e5 100644
--- a/src/testlib/qplaintestlogger.cpp
+++ b/src/testlib/qplaintestlogger.cpp
@@ -49,10 +49,6 @@
#include <stdlib.h>
#include <string.h>
-#ifdef Q_OS_WINCE
-#include <QtCore/QString>
-#endif
-
#ifdef min // windows.h without NOMINMAX is included by the benchmark headers.
# undef min
#endif
@@ -215,16 +211,7 @@ Q_CORE_EXPORT bool qt_logging_to_console(); // defined in qlogging.cpp
void QPlainTestLogger::outputMessage(const char *str)
{
-#if defined(Q_OS_WINCE)
- QString strUtf16 = QString::fromLocal8Bit(str);
- const int maxOutputLength = 255;
- do {
- QString tmp = strUtf16.left(maxOutputLength);
- OutputDebugString((wchar_t*)tmp.utf16());
- strUtf16.remove(0, maxOutputLength);
- } while (!strUtf16.isEmpty());
- if (stream != stdout)
-#elif defined(Q_OS_WIN)
+#if defined(Q_OS_WIN)
// log to system log only if output is not redirected, and no console is attached
if (!qt_logging_to_console() && stream == stdout) {
OutputDebugStringA(str);
diff --git a/src/testlib/qteamcitylogger.cpp b/src/testlib/qteamcitylogger.cpp
index 4773ea937f..1d700d8201 100644
--- a/src/testlib/qteamcitylogger.cpp
+++ b/src/testlib/qteamcitylogger.cpp
@@ -228,22 +228,22 @@ QString QTeamCityLogger::tcEscapedString(const QString &str) const
switch (ch.toLatin1()) {
case '\n':
- formattedString.append(QLatin1Literal("|n"));
+ formattedString.append(QLatin1String("|n"));
break;
case '\r':
- formattedString.append(QLatin1Literal("|r"));
+ formattedString.append(QLatin1String("|r"));
break;
case '|':
- formattedString.append(QLatin1Literal("||"));
+ formattedString.append(QLatin1String("||"));
break;
case '[':
- formattedString.append(QLatin1Literal("|["));
+ formattedString.append(QLatin1String("|["));
break;
case ']':
- formattedString.append(QLatin1Literal("|]"));
+ formattedString.append(QLatin1String("|]"));
break;
case '\'':
- formattedString.append(QLatin1Literal("|'"));
+ formattedString.append(QLatin1String("|'"));
break;
default:
formattedString.append(ch);
diff --git a/src/testlib/qtest.h b/src/testlib/qtest.h
index cf8dee4646..b9bb10818e 100644
--- a/src/testlib/qtest.h
+++ b/src/testlib/qtest.h
@@ -58,10 +58,6 @@
#include <QtCore/qsize.h>
#include <QtCore/qrect.h>
-#ifdef QT_NETWORK_LIB
-# include <QtNetwork/qhostaddress.h>
-#endif
-
QT_BEGIN_NAMESPACE
@@ -192,25 +188,10 @@ template<> inline char *toString(const QVariant &v)
return qstrdup(vstring.constData());
}
-#ifdef QT_NETWORK_LIB
-/*!
- \internal
- */
-template<> inline char *toString(const QHostAddress &addr)
+inline char *toString(std::nullptr_t)
{
- switch (addr.protocol()) {
- case QAbstractSocket::UnknownNetworkLayerProtocol:
- return qstrdup("<unknown address (parse error)>");
- case QAbstractSocket::AnyIPProtocol:
- return qstrdup("QHostAddress::Any");
- case QAbstractSocket::IPv4Protocol:
- case QAbstractSocket::IPv6Protocol:
- break;
- }
-
- return qstrdup(addr.toString().toLatin1().constData());
+ return toString(QLatin1String("nullptr"));
}
-#endif
template<>
inline bool qCompare(QString const &t1, QLatin1String const &t2, const char *actual,
@@ -352,6 +333,10 @@ int main(int argc, char *argv[]) \
# define QTEST_ADD_GPU_BLACKLIST_SUPPORT
#endif
+#if defined(QT_NETWORK_LIB)
+# include <QtTest/qtest_network.h>
+#endif
+
#if defined(QT_WIDGETS_LIB)
#include <QtTest/qtest_widgets.h>
diff --git a/src/testlib/qtest_network.h b/src/testlib/qtest_network.h
new file mode 100644
index 0000000000..6f6b4c1b8e
--- /dev/null
+++ b/src/testlib/qtest_network.h
@@ -0,0 +1,126 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtTest module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTEST_NETWORK_H
+#define QTEST_NETWORK_H
+
+#include <QtTest/qtest.h>
+
+// enable NETWORK features
+#ifndef QT_NETWORK_LIB
+#define QT_NETWORK_LIB
+#endif
+
+#if 0
+#pragma qt_class(QtTestNetwork)
+#endif
+
+#include <QtNetwork/QHostAddress>
+#include <QtNetwork/QNetworkCookie>
+#include <QtNetwork/QNetworkReply>
+
+#if 0
+// inform syncqt
+#pragma qt_no_master_include
+#endif
+
+QT_BEGIN_NAMESPACE
+
+namespace QTest
+{
+/*!
+ \internal
+ */
+inline char *toString(const QHostAddress &addr)
+{
+ switch (addr.protocol()) {
+ case QAbstractSocket::UnknownNetworkLayerProtocol:
+ return qstrdup("<unknown address (parse error)>");
+ case QAbstractSocket::AnyIPProtocol:
+ return qstrdup("QHostAddress::Any");
+ case QAbstractSocket::IPv4Protocol:
+ case QAbstractSocket::IPv6Protocol:
+ break;
+ }
+
+ return toString(addr.toString());
+}
+
+/*!
+ \internal
+ */
+inline char *toString(QNetworkReply::NetworkError code)
+{
+ const QMetaObject *mo = &QNetworkReply::staticMetaObject;
+ int index = mo->indexOfEnumerator("NetworkError");
+ if (index == -1)
+ return qstrdup("");
+
+ QMetaEnum qme = mo->enumerator(index);
+ return qstrdup(qme.valueToKey(code));
+}
+
+/*!
+ \internal
+ */
+inline char *toString(const QNetworkCookie &cookie)
+{
+ return toString(cookie.toRawForm());
+}
+
+/*!
+ \internal
+ */
+inline char *toString(const QList<QNetworkCookie> &list)
+{
+ QByteArray result = "QList(";
+ if (!list.isEmpty()) {
+ for (const QNetworkCookie &cookie : list)
+ result += "QNetworkCookie(" + cookie.toRawForm() + "), ";
+ result.chop(2); // remove trailing ", "
+ }
+ result.append(')');
+ return toString(result);
+}
+
+} // namespace QTest
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/testlib/qtestblacklist.cpp b/src/testlib/qtestblacklist.cpp
index 05ad5cef5b..587930ca73 100644
--- a/src/testlib/qtestblacklist.cpp
+++ b/src/testlib/qtestblacklist.cpp
@@ -97,12 +97,18 @@ static QSet<QByteArray> keywords()
#ifdef Q_OS_OSX
<< "osx"
#endif
-#ifdef Q_OS_WIN
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
<< "windows"
#endif
#ifdef Q_OS_IOS
<< "ios"
#endif
+#ifdef Q_OS_TVOS
+ << "tvos"
+#endif
+#ifdef Q_OS_WATCHOS
+ << "watchos"
+#endif
#ifdef Q_OS_ANDROID
<< "android"
#endif
@@ -112,9 +118,6 @@ static QSet<QByteArray> keywords()
#ifdef Q_OS_WINRT
<< "winrt"
#endif
-#ifdef Q_OS_WINCE
- << "wince"
-#endif
#if QT_POINTER_SIZE == 8
<< "64bit"
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index f3aaa7c89d..1c13f8edc2 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -90,11 +90,9 @@
#endif
#ifdef Q_OS_WIN
-#ifndef Q_OS_WINCE
# if !defined(Q_CC_MINGW) || (defined(Q_CC_MINGW) && defined(__MINGW64_VERSION_MAJOR))
# include <crtdbg.h>
# endif
-#endif
#include <windows.h> // for Sleep
#endif
#ifdef Q_OS_UNIX
@@ -114,6 +112,36 @@ QT_BEGIN_NAMESPACE
using QtMiscUtils::toHexUpper;
using QtMiscUtils::fromHex;
+static bool debuggerPresent()
+{
+#if defined(Q_OS_LINUX)
+ int fd = open("/proc/self/status", O_RDONLY);
+ if (fd == -1)
+ return false;
+ char buffer[2048];
+ ssize_t size = read(fd, buffer, sizeof(buffer) - 1);
+ if (size == -1) {
+ close(fd);
+ return false;
+ }
+ buffer[size] = 0;
+ const char tracerPidToken[] = "\nTracerPid:";
+ char *tracerPid = strstr(buffer, tracerPidToken);
+ if (!tracerPid) {
+ close(fd);
+ return false;
+ }
+ tracerPid += sizeof(tracerPidToken);
+ long int pid = strtol(tracerPid, &tracerPid, 10);
+ close(fd);
+ return pid != 0;
+#elif defined(Q_OS_WIN)
+ return IsDebuggerPresent();
+#else
+ // TODO
+ return false;
+#endif
+}
static void stackTrace()
{
@@ -121,6 +149,10 @@ static void stackTrace()
const int disableStackDump = qEnvironmentVariableIntValue("QTEST_DISABLE_STACK_DUMP", &ok);
if (ok && disableStackDump == 1)
return;
+
+ if (debuggerPresent())
+ return;
+
#ifdef Q_OS_LINUX
fprintf(stderr, "\n========= Received signal, dumping stack ==============\n");
char cmd[512];
@@ -1254,37 +1286,6 @@ char *toPrettyUnicode(const ushort *p, int length)
return buffer.take();
}
-static bool debuggerPresent()
-{
-#if defined(Q_OS_LINUX)
- int fd = open("/proc/self/status", O_RDONLY);
- if (fd == -1)
- return false;
- char buffer[2048];
- ssize_t size = read(fd, buffer, sizeof(buffer) - 1);
- if (size == -1) {
- close(fd);
- return false;
- }
- buffer[size] = 0;
- const char tracerPidToken[] = "\nTracerPid:";
- char *tracerPid = strstr(buffer, tracerPidToken);
- if (!tracerPid) {
- close(fd);
- return false;
- }
- tracerPid += sizeof(tracerPidToken);
- long int pid = strtol(tracerPid, &tracerPid, 10);
- close(fd);
- return pid != 0;
-#elif defined(Q_OS_WIN)
- return IsDebuggerPresent();
-#else
- // TODO
- return false;
-#endif
-}
-
void TestMethods::invokeTests(QObject *testObject) const
{
const QMetaObject *metaObject = testObject->metaObject();
@@ -1388,7 +1389,9 @@ FatalSignalHandler::FatalSignalHandler()
act.sa_flags = SA_RESETHAND;
#endif
-#ifdef SA_ONSTACK
+// tvOS/watchOS both define SA_ONSTACK (in sys/signal.h) but mark sigaltstack() as
+// unavailable (__WATCHOS_PROHIBITED __TVOS_PROHIBITED in signal.h)
+#if defined(SA_ONSTACK) && !defined(Q_OS_TVOS) && !defined(Q_OS_WATCHOS)
// Let the signal handlers use an alternate stack
// This is necessary if SIGSEGV is to catch a stack overflow
# if defined(Q_CC_GNU) && defined(Q_OF_ELF)
@@ -1454,7 +1457,7 @@ FatalSignalHandler::~FatalSignalHandler()
} // namespace
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
// Helper class for resolving symbol names by dynamically loading "dbghelp.dll".
class DebugSymbolResolver
@@ -1592,7 +1595,7 @@ static LONG WINAPI windowsFaultHandler(struct _EXCEPTION_POINTERS *exInfo)
return EXCEPTION_EXECUTE_HANDLER;
}
-#endif // Q_OS_WIN) && !Q_OS_WINCE && !Q_OS_WINRT
+#endif // Q_OS_WIN) && !Q_OS_WINRT
static void initEnvironment()
{
@@ -1687,7 +1690,7 @@ int QTest::qExec(QObject *testObject, int argc, char **argv)
qtest_qParseArgs(argc, argv, false);
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN)
if (!noCrashHandler) {
# ifndef Q_CC_MINGW
_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG);
@@ -1697,7 +1700,7 @@ int QTest::qExec(QObject *testObject, int argc, char **argv)
SetUnhandledExceptionFilter(windowsFaultHandler);
# endif
} // !noCrashHandler
-#endif // Q_OS_WIN) && !Q_OS_WINCE && !Q_OS_WINRT
+#endif // Q_OS_WIN
#ifdef QTESTLIB_USE_VALGRIND
if (QBenchmarkGlobalData::current->mode() == QBenchmarkGlobalData::CallgrindParentProcess) {
@@ -2432,6 +2435,14 @@ bool QTest::compare_string_helper(const char *t1, const char *t2, const char *ac
\internal
*/
+/*! \fn bool QTest::qCompare(T *t, std::nullptr_t, const char *actual, const char *expected, const char *file, int line)
+ \internal
+*/
+
+/*! \fn bool QTest::qCompare(std::nullptr_t, T *t, const char *actual, const char *expected, const char *file, int line)
+ \internal
+*/
+
/*! \fn bool QTest::qCompare(T *t1, T *t2, const char *actual, const char *expected, const char *file, int line)
\internal
*/
diff --git a/src/testlib/qtestcase.h b/src/testlib/qtestcase.h
index fe74268481..c3ccfc3f8c 100644
--- a/src/testlib/qtestcase.h
+++ b/src/testlib/qtestcase.h
@@ -46,24 +46,23 @@
#include <QtCore/qnamespace.h>
#include <QtCore/qmetatype.h>
#include <QtCore/qmetaobject.h>
-#include <QtCore/qtypetraits.h>
#include <QtCore/qsharedpointer.h>
#include <QtCore/qtemporarydir.h>
#include <string.h>
+#include <type_traits>
#ifndef QT_NO_EXCEPTIONS
# include <exception>
#endif // QT_NO_EXCEPTIONS
-
QT_BEGIN_NAMESPACE
class QRegularExpression;
#define QVERIFY(statement) \
do {\
- if (!QTest::qVerify((statement), #statement, "", __FILE__, __LINE__))\
+ if (!QTest::qVerify(static_cast<bool>(statement), #statement, "", __FILE__, __LINE__))\
return;\
} while (0)
@@ -204,11 +203,11 @@ do {\
return;\
} while (0)
-#define QFETCH(type, name)\
- type name = *static_cast<type *>(QTest::qData(#name, ::qMetaTypeId<type >()))
+#define QFETCH(Type, name)\
+ Type name = *static_cast<Type *>(QTest::qData(#name, ::qMetaTypeId<typename std::remove_cv<Type >::type>()))
-#define QFETCH_GLOBAL(type, name)\
- type name = *static_cast<type *>(QTest::qGlobalData(#name, ::qMetaTypeId<type >()))
+#define QFETCH_GLOBAL(Type, name)\
+ Type name = *static_cast<Type *>(QTest::qGlobalData(#name, ::qMetaTypeId<typename std::remove_cv<Type >::type>()))
#define QTEST(actual, testElement)\
do {\
@@ -312,7 +311,7 @@ namespace QTest
template <typename T>
inline void addColumn(const char *name, T * = 0)
{
- typedef QtPrivate::is_same<T, const char*> QIsSameTConstChar;
+ typedef std::is_same<T, const char*> QIsSameTConstChar;
Q_STATIC_ASSERT_X(!QIsSameTConstChar::value, "const char* is not allowed as a test data format.");
addColumnInternal(qMetaTypeId<T>(), name);
}
@@ -332,13 +331,27 @@ namespace QTest
Q_TESTLIB_EXPORT bool qCompare(double const &t1, double const &t2,
const char *actual, const char *expected, const char *file, int line);
- inline bool compare_ptr_helper(const void *t1, const void *t2, const char *actual,
+ inline bool compare_ptr_helper(const volatile void *t1, const volatile void *t2, const char *actual,
const char *expected, const char *file, int line)
{
return compare_helper(t1 == t2, "Compared pointers are not the same",
toString(t1), toString(t2), actual, expected, file, line);
}
+ inline bool compare_ptr_helper(const volatile void *t1, std::nullptr_t, const char *actual,
+ const char *expected, const char *file, int line)
+ {
+ return compare_helper(t1 == nullptr, "Compared pointers are not the same",
+ toString(t1), toString(nullptr), actual, expected, file, line);
+ }
+
+ inline bool compare_ptr_helper(std::nullptr_t, const volatile void *t2, const char *actual,
+ const char *expected, const char *file, int line)
+ {
+ return compare_helper(nullptr == t2, "Compared pointers are not the same",
+ toString(nullptr), toString(t2), actual, expected, file, line);
+ }
+
Q_TESTLIB_EXPORT bool compare_string_helper(const char *t1, const char *t2, const char *actual,
const char *expected, const char *file, int line);
@@ -388,6 +401,19 @@ namespace QTest
return compare_ptr_helper(t1, t2, actual, expected, file, line);
}
+ template <typename T>
+ inline bool qCompare(T *t1, std::nullptr_t, const char *actual, const char *expected,
+ const char *file, int line)
+ {
+ return compare_ptr_helper(t1, nullptr, actual, expected, file, line);
+ }
+ template <typename T>
+ inline bool qCompare(std::nullptr_t, T *t2, const char *actual, const char *expected,
+ const char *file, int line)
+ {
+ return compare_ptr_helper(nullptr, t2, actual, expected, file, line);
+ }
+
template <typename T1, typename T2>
inline bool qCompare(const T1 *t1, const T2 *t2, const char *actual, const char *expected,
const char *file, int line)
diff --git a/src/testlib/qtestcase.qdoc b/src/testlib/qtestcase.qdoc
index f34c84708f..8f3d140add 100644
--- a/src/testlib/qtestcase.qdoc
+++ b/src/testlib/qtestcase.qdoc
@@ -907,6 +907,14 @@
*/
/*!
+ \fn char *QTest::toString(std::nullptr_t)
+ \overload
+ \since 5.8
+
+ Returns a string containing \c{nullptr}.
+*/
+
+/*!
\fn char *QTest::toString(const QString &string)
\overload
@@ -1114,6 +1122,20 @@
*/
/*!
+ \fn QTouchDevice *QTest::createTouchDevice(QTouchDevice::DeviceType devType = QTouchDevice::TouchScreen)
+ \since 5.8
+
+ Creates a dummy touch device of type \a devType for simulation of touch events.
+
+ The touch device will be registered with the QPA window system interface,
+ and deleted automatically when the QCoreApplication is deleted. So you
+ should typically use createTouchDevice() to initialize a QTouchDevice
+ member variable in your test case class, and use the same instance for all tests.
+
+ \sa QTest::QTouchEventSequence
+*/
+
+/*!
\class QTest::QTouchEventSequence
\inmodule QtTest
\since 4.6
diff --git a/src/testlib/qtestmouse.h b/src/testlib/qtestmouse.h
index 632b801221..1143361323 100644
--- a/src/testlib/qtestmouse.h
+++ b/src/testlib/qtestmouse.h
@@ -115,14 +115,14 @@ namespace QTest
case MouseDClick:
qt_handleMouseEvent(w, pos, global, button, stateKey, ++lastMouseTimestamp);
qt_handleMouseEvent(w, pos, global, Qt::NoButton, stateKey, ++lastMouseTimestamp);
- // fall through
+ Q_FALLTHROUGH();
case MousePress:
case MouseClick:
qt_handleMouseEvent(w, pos, global, button, stateKey, ++lastMouseTimestamp);
lastMouseButton = button;
if (action == MousePress)
break;
- // fall through
+ Q_FALLTHROUGH();
case MouseRelease:
qt_handleMouseEvent(w, pos, global, Qt::NoButton, stateKey, ++lastMouseTimestamp);
lastMouseTimestamp += 500; // avoid double clicks being generated
diff --git a/src/testlib/qtesttouch.h b/src/testlib/qtesttouch.h
index 2c57bf0420..bda185bfee 100644
--- a/src/testlib/qtesttouch.h
+++ b/src/testlib/qtesttouch.h
@@ -65,6 +65,7 @@ Q_GUI_EXPORT void qt_handleTouchEvent(QWindow *w, QTouchDevice *device,
namespace QTest
{
+ Q_GUI_EXPORT QTouchDevice * createTouchDevice(QTouchDevice::DeviceType devType = QTouchDevice::TouchScreen);
class QTouchEventSequence
{
diff --git a/src/testlib/qxctestlogger.mm b/src/testlib/qxctestlogger.mm
index c50b50eb06..ffabe88db2 100644
--- a/src/testlib/qxctestlogger.mm
+++ b/src/testlib/qxctestlogger.mm
@@ -191,7 +191,7 @@ private:
name:[NSString stringWithFormat:@"%@DidFinishLaunchingNotification",
#if defined(Q_OS_OSX)
@"NSApplication"
- #elif defined(Q_OS_IOS)
+ #else
@"UIApplication"
#endif
]
diff --git a/src/testlib/qxunittestlogger.cpp b/src/testlib/qxunittestlogger.cpp
index 72faaeb9b1..ec33c29ae5 100644
--- a/src/testlib/qxunittestlogger.cpp
+++ b/src/testlib/qxunittestlogger.cpp
@@ -256,7 +256,7 @@ void QXunitTestLogger::addBenchmarkResult(const QBenchmarkResult &result)
benchmarkElement->addAttribute(
QTest::AI_Metric,
- QTest::benchmarkMetricName(QBenchmarkTestMethodData::current->result.metric));
+ QTest::benchmarkMetricName(result.metric));
benchmarkElement->addAttribute(QTest::AI_Tag, result.context.tag.toUtf8().data());
const qreal valuePerIteration = qreal(result.value) / qreal(result.iterations);
diff --git a/src/testlib/testlib.pro b/src/testlib/testlib.pro
index b4ac077e86..5b2205e875 100644
--- a/src/testlib/testlib.pro
+++ b/src/testlib/testlib.pro
@@ -14,6 +14,7 @@ QMAKE_DOCS = $$PWD/doc/qttestlib.qdocconf
HEADERS = qbenchmark.h \
qbenchmark_p.h \
qbenchmarkmeasurement_p.h \
+ qbenchmarktimemeasurers_p.h \
qbenchmarkvalgrind_p.h \
qbenchmarkevent_p.h \
qbenchmarkperfevents_p.h \
@@ -28,6 +29,7 @@ HEADERS = qbenchmark.h \
qtesteventloop.h \
qtest_global.h \
qtest_gui.h \
+ qtest_network.h \
qtest_widgets.h \
qtest.h \
qtestkeyboard.h \
@@ -67,13 +69,6 @@ DEFINES *= QT_NO_CAST_TO_ASCII \
QT_NO_FOREACH \
QT_NO_DATASTREAM
embedded:QMAKE_CXXFLAGS += -fno-rtti
-wince: LIBS += \
- ole32.lib \
- oleaut32.lib \
- uuid.lib \
- commctrl.lib \
- coredll.lib \
- winsock.lib
mac {
LIBS += -framework Security