Commit Graph

132 Commits

Author SHA1 Message Date
Ulf Hermann c225e23e00 QtQml: Move ResolvedTypeReference into base CU
Change-Id: I25063457aad3a6d29a8c2a5b236f9a51b56a2f51
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2024-01-13 16:03:58 +01:00
Ulf Hermann 7a9a778604 QtQml: Remove QQmlTypeLoader from QQmlImport
The type loader belongs to the engine and we must not store it in
engine-independent data structures. We do want the import cache to be
stored in the type registry, though (in a separate change).

Change-Id: I2828f5098b27bf1fc96852fc2bd160db44b109e7
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2024-01-11 00:42:17 +01:00
Mårten Nordheim 80532bcd26 Rewrite QuickTests's qWaitForSignal
It doesn't use any of the features of QSignalSpy, so
it hasn't done it any favors. On top of that QSignalSpy
connects with DirectConnection which means that frequently
emitted signals on another thread may end up trying to
append another signal emission to its internal list during
destruction of the signal spy, leading to use-after-free.

The new implementation uses a small class with a slot that just sets
a boolean. We use AutoConnection so it is thread safe, and pending
emissions go away when the object is destroyed.

Fixes: QTBUG-118744
Fixes: QTBUG-118163
Pick-to: 6.6 6.5
Change-Id: Ib2ccce2369a681bfe9a2e04d2c091f9690edee49
Reviewed-by: Dimitrios Apostolou <jimis@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-11-06 15:05:30 +00:00
Volker Hilsheimer 9c2ecfc6c0 Document that running a Quick Test always show a window
After 47490648b1, test functions are
executed asynchronously through a scheduler. This makes the entire logic
for detecting whether a test case completed during setSource() obsolete,
and always results in a window being shown.

That is as such fine, Qt Quick Test always required the GUI and Quick
specific Qt modules and platform plugins to be available (so it wasn't
easily possible to run those tests on a server without any display
infrastructure). But we can now remove the logic from the startup
function.

Add a note to the documentation that running tests always shows a UI,
and how to avoid it using the offscreen platform plugin.

Pick-to: 6.5
Fixes: QTBUG-110592
Change-Id: Ie69b04e3fd4044db2fc7f0fc3ca44947a3dddfce
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-04-18 05:44:55 +02:00
Friedemann Kleint a07d3fb9bd QmlTest: Move declaration of helper qWaitForSignal() to a header
Otherwise, the default parameter declaration causes a clash in CMake
Unity (Jumbo) builds.

Pick-to: 6.5
Task-number: QTBUG-109394
Change-Id: Ida72b30debfa97b6fc2e523b19ef219425c2a0c2
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-02-10 18:57:11 +01:00
Marc Mutz c2d490a238 Port from qAsConst() to std::as_const()
We've been requiring C++17 since Qt 6.0, and our qAsConst use finally
starts to bother us (QTBUG-99313), so time to port away from it
now.

Since qAsConst has exactly the same semantics as std::as_const (down
to rvalue treatment, constexpr'ness and noexcept'ness), there's really
nothing more to it than a global search-and-replace.

Task-number: QTBUG-99313
Change-Id: I601bf70f020f511019ed28731ba53b14b765dbf0
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-10-07 23:38:56 +02:00
Marc Mutz 958cd3ee10 Port from container::count() and length() to size()
This is a semantic patch using ClangTidyTransformator as in
qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8:

  auto QtContainerClass = anyOf(
      expr(hasType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))))).bind(o),
      expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o));
  makeRule(cxxMemberCallExpr(on(QtContainerClass),
                             callee(cxxMethodDecl(hasAnyName({"count", "length"),
                                                  parameterCountIs(0))))),
           changeTo(cat(access(o, cat("size"), "()"))),
           cat("use 'size()' instead of 'count()/length()'"))

a.k.a qt-port-to-std-compatible-api with config Scope: 'Container',
with the extended set of container classes recognized.

Change-Id: Idb1f75dfe2323bd1d9e8b4d58d54f1b4b80c7ed7
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-10-07 23:38:48 +02:00
Thiago Macieira febbd38532 qmltest: use variadic templates instead of QGenericArgument
Change-Id: I36b24183fbd041179f2ffffd170267647be37c52
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-07-18 08:54:08 -07:00
Lucie Gérard 0dc4fd240a Use SPDX license identifiers
Replace the current license disclaimer in files by
a SPDX-License-Identifier.
Files that have to be modified by hand are modified.
License files are organized under LICENSES directory.

Pick-to: 6.4
Task-number: QTBUG-67283
Change-Id: I63563bbeb6f60f89d2c99660400dca7fab78a294
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-06-11 08:05:15 +02:00
Mitch Curtis a72b4cd733 TestCase: add API for checking for polish at window level
These were introduced to the C++ QQuickTest namespace in
36c6c1ea57.
QML-only tests should also have access to them.

[ChangeLog][QtQuickTest][TestCase] Added waitForPolish()
and made isPolishScheduled() also take a Window, making it possible
to verify that updatePolish() was called on one or more items
managed by a window.

[ChangeLog][QtQuickTest][TestCase] Deprecated waitForItemPolished().
Use the new waitForPolish() function instead.

Task-number: QTBUG-93757
Change-Id: Ie53389c2d49e096ebf382b902714c9dd4c8d5685
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-06-06 09:18:17 +08:00
Mitch Curtis 36c6c1ea57 QtQuickTest: add API for checking for polish at window level
This adds a qIsPolishScheduled(QQuickWindow *) overload of
qIsPolishScheduled(QQuickItem *) (added in
40d6072bc8) and deprecates
qWaitForItemPolished() (added in
7a3cad0619) in favor of qWaitForPolish(),
which has QQuickItem* and QQuickWindow* overloads.

The existing functions that take QQuickItem are useful, but testing
Qt Quick applications can be made even easier by allowing users to
check if a window has any items that need to be polished. This
information is already present (in QQuickWindowPrivate::itemsToPolish),
so it's very efficient to check for.

This is especially useful now that Qt Quick Layouts using polishing for
their layouting, for example, as it's no longer necessary to find
individual polishable items in complex hierarchies before proceeding
to interact with child items.

[ChangeLog][QtQuickTest][QQuickTest] Added
QQuickTest::qIsPolishScheduled(QQuickWindow *) and
QQuickTest::qWaitForPolish(QQuickWindow *) functions for verifying that
updatePolish() was called on one or more items managed by a window.

[ChangeLog][QtQuickTest][QQuickTest] Deprecated
QQuickTest::qWaitForItemPolished(QQuickItem *). Use the new
QQuickTest::qWaitForPolish(QQuickItem *) function instead.

Fixes: QTBUG-93757
Change-Id: I95b6e051b3c9fd2fa93604f4d9ccda486bb29f9d
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-06-02 12:46:11 +08:00
Ulf Hermann 36ebee4e69 QML: Port QV4::CompiledData::Binding to new special integer bitfield
Pick-to: 5.15 6.2 6.3
Task-number: QTBUG-99545
Change-Id: I9f8bc5fa45c61f77ee95b055a3d8de001da8f8c5
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-05-11 12:56:22 +02:00
Ulf Hermann 893b6ae6e8 QML: Port QV4::CompiledData::Location to new special integer bitfield
Pick-to: 5.15 6.2 6.3
Task-number: QTBUG-99545
Change-Id: If0d6f893f2351a4146ddf125be4079b5e312f308
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2022-05-11 12:56:21 +02:00
Ulf Hermann 745cce4391 QML: Port QV4::CompiledData::Object to new special integer bitfield
Pick-to: 5.15 6.2 6.3
Task-number: QTBUG-99545
Change-Id: Ia57a16313e883a8d4dab15c971181440ed1d2214
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2022-05-11 12:56:21 +02:00
Marc Mutz cdca7e8c10 QuickTest: includemocs
Including moc files directly into their classes' TU tends to improve
codegen and enables extended compiler warnings, e.g. about unused
private functions or fields.

Pick-to: 6.3 6.2 5.15
Task-number: QTBUG-102948
Change-Id: Ic8d138526724734169ff7f0686ad19d30c729307
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-04-29 06:39:59 +02:00
Kimmo Ollila 0fc8a511ba INTEGRITY: Fix some test cases from core/qml folders
-Add dummy_imports.qml to TESTDATA
-Let qmlimportscanner handle plugin import
-Skip cases that depend on mounted filesystem

Task-number: QTBUG-99123
Pick-to: 6.3 6.2
Change-Id: I99e21e423f2114c4c4ee1e24bdf9bb85af51baf7
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-03-03 08:26:06 +02:00
Ulf Hermann c84c7a31a5 QuickTest: Do not leak when returning an error
Avoid exit(), and wrap the application into a QScopedPointer.
Also, handle errors while enumerating test cases the
same way as errors while creating the QQuickView.

Change-Id: I0dd147a16d3ea60147e15627295d7eb82630e59d
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-11-09 00:03:09 +01:00
Fabian Kosmale edca9f3d60 QuickTest: Do not recurse forever on inline components in enumerateTestCases
In TestCaseCollector::enumerateTestCases, we visit the super compilation
unit of QML tpyes to check if they might be instances of TestCase.
However, in the case of inline components, the super unit is the current
compilation unit, and we would recurse endlessly.

This does not address the issue that an inline component might actually
inherit TestCase. However, as this only affects the enumeration output
and does not actually affect test execution, this is not that much of an
issue. It should also be noted that the enumeration also fails in any
case where TestCases are loaded dynamically (with a loader), so the
method is not 100% accurate even in the absence of inline components.

Fixes: QTBUG-90740
Task-number: QTBUG-90762
Pick-to: 5.15 6.0
Change-Id: I7e133d62c4f62fc46e9bd3999ff755f7ded3c386
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-02-01 18:19:24 +01:00
Ulf Hermann 4e36c03112 Drop widgets dependency from quicktest
It was introduced for QtQuick.Controls 1 back when it was still called
QtDesktopComponents. QtQuick.Controls 1 is deprecated and also doesn't
use the widgets mode anymore. I can't think of any other use for it, but
loading QtWidgets produces a number of unwelcome side effects in the
tests.

Change-Id: I4b7e53a9b906c428d84926302bf629b826d900c4
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-02-01 14:01:25 +01:00
Ulf Hermann 843be43f18 Merge the QtTest and Qt.test.qtestroot QML modules
There is no point in having them separate and this way the plugin can be
optional.

Fixes: QTBUG-89804
Change-Id: Ic7de35f6ee7abde4840841e17d21c2b709f6db7d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-01-12 20:58:41 +01:00
Assam Boudjelthia 66285fd495 [Fix] Use the sourceDir if specified
Android is passing the test path via QUICK_TEST_SOURCE_DIR but it was
set
to ":/" no matter what.

Pick-to: 5.15
Change-Id: If0e6615999019cf1869a237056d41e35b5be12f1
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2020-08-26 09:17:34 +03:00
Michal Klocek 1a3738dfa8 Read tests from qmltest file
Change-Id: I3550d20aac165539b97247d71e488fb3da30e48c
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2020-08-13 10:49:22 +02:00
Karsten Heimrich 1b10ce6a08 Port QtDeclarative from QStringRef to QStringView
Task-number: QTBUG-84319
Change-Id: I2dcfb8a2db98282c7a1acdad1e6f4f949f26df15
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2020-06-16 22:46:16 +02:00
Oliver Wolff 9cefaca1ea Remove winrt
Task-number: QTBUG-84434
Change-Id: If8f57f00726868a3540c877d07fca761618e4f08
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-06-04 15:51:51 +02:00
Qt Forward Merge Bot 2812184e1b Merge remote-tracking branch 'origin/5.15' into dev
Conflicts:
	src/qml/jsruntime/qv4executablecompilationunit.cpp
	src/qml/jsruntime/qv4executablecompilationunit_p.h
	src/qml/qml/qqmlobjectcreator.cpp
	src/qml/qml/qqmlpropertycachecreator_p.h
	src/qml/qml/qqmltypecompiler.cpp
	src/qml/qml/qqmltypedata.cpp
	tests/auto/qml/qmlformat/tst_qmlformat.cpp
	tools/qmllint/scopetree.cpp
	src/qml/qml/qqmlapplicationengine_p.h

Adjusted tools/qmllint/findunqualified.cpp to use newer API

Change-Id: Ibfb4678ca39d626d47527265e3c96e43313873d4
2020-04-09 10:08:41 +02:00
Ulf Hermann d552cd3f50 Add qmltypes for Qt.test.qtestroot
Somehow this was missed when moving to static type registration.

Change-Id: I33f0567449f7bce62b0cb71b9d4f0862ed801e59
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-04-06 13:38:03 +02:00
Ulf Hermann 3f0c9122c5 Encapsulate QV4::ResolvedTypeReference
It's used all over the place. We need a proper interface.

Change-Id: Iebe254ef3bf35503bf3fdd3639979a5db2b3449e
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-03-25 10:51:47 +01:00
Ulf Hermann b1f53bf6ea QML: Avoid cyclic references between ResolvedTypeRefence and CU
The compilation unit keeps a list of references to used types. Usually
those are references to types in other compilation units. However, in
the case of inline components they can be references to the same
compilation unit. In that case we should not addref() the compilation
unit, as that forms a cyclic reference.

Fixes: QTBUG-82768
Change-Id: I29d28f3a4780aad4fabd4aa2ed02ca0d0108987e
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2020-03-25 10:42:41 +01:00
Johan Klokkhammer Helsing 872dc18e65 Quick: Don't qualify OpenGL includes (part two)
406f15ce0e only removed the "QtGui" prefix from some includes, but we are
trying to move (almost) everything OpenGL related from QtGui.

This removes prefixes for additional QOpenGL includes (QOpenGLShaderProgram,
versioned opengl functions etc.).

Task-number: QTBUG-74409
Change-Id: I91e1feac0676859f11de9b75301a0a4e81db50d9
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2020-02-18 09:51:27 +01:00
Giuseppe D'Angelo 05dd00087c Port from QLatin1Literal to QLatin1String
QLatin1Literal is an undocumented and deprecated typedef
for QLatin1String, just use the original.

Change-Id: Ib6e2b7ac369be12aed0e455c91cf31b807eae4ed
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-06-11 19:35:19 +02:00
Friedemann Kleint 0f035c0ad7 Fix deprecation warnings in 5.14
Libraries:
scenegraph/util/qsgdepthstencilbuffer.cpp:186:57: warning: 'T* QWeakPointer<T>::data() const [with T = QSGDepthStencilBuffer]' is deprecated: Use toStrongRef() instead, and data() on the returned QSharedPointer [-Wdeprecated-declarations]
scenegraph/qsgdefaultcontext.cpp:163:89: warning: 'QList<T> QSet<T>::toList() const [with T = QByteArray]' is deprecated: Use values() instead. [-Wdeprecated-declarations]
util/qquickpath.cpp:573:40: warning: 'QList<T> QSet<T>::toList() const [with T = QString]' is deprecated: Use values() instead. [-Wdeprecated-declarations]
util/qquickpath.cpp:606:29: warning: 'QList<T> QSet<T>::toList() const [with T = QString]' is deprecated: Use values() instead. [-Wdeprecated-declarations]
quicktest.cpp:562:73: warning: 'QSet<T> QList<T>::toSet() const [with T = QString]' is deprecated: Use QSet<T>(list.begin(), list.end()) instead. [-Wdeprecated-declarations]
quicktest.cpp:604:77: warning: 'QSet<T> QList<T>::toSet() const [with T = QString]' is deprecated: Use QSet<T>(list.begin(), list.end()) instead. [-Wdeprecated-declarations]
qquickitemparticle.cpp:233:49: warning: 'static QSet<T> QSet<T>::fromList(const QList<T>&) [with T = QQuickItem*]' is deprecated: Use QSet<T>(list.begin(), list.end()) instead. [-Wdeprecated-declarations]
qquickitemparticle.cpp:239:37: warning: 'QList<T> QSet<T>::toList() const [with T = QQuickItem*]' is deprecated: Use values() instead. [-Wdeprecated-declarations]

Tests:
tst_propertyrequirements.cpp:123:58: warning: 'QList<T> QSet<T>::toList() const [with T = QString]' is deprecated: Use values() instead. [-Wdeprecated-declarations]
tst_propertyrequirements.cpp:161:40: warning: 'static QSet<T> QSet<T>::fromList(const QList<T>&) [with T = QString]' is deprecated: Use QSet<T>(list.begin(), list.end()) instead. [-Wdeprecated-declarations]
tst_propertyrequirements.cpp:161:77: warning: 'static QSet<T> QSet<T>::fromList(const QList<T>&) [with T = QString]' is deprecated: Use QSet<T>(list.begin(), list.end()) instead. [-Wdeprecated-declarations]
/data1/frkleint/qt-dev/qtbase/include/QtCore/../../src/corelib/tools/qset.h:400:23: warning: 'QSet<T> QList<T>::toSet() const [with T = QString]' is deprecated: Use QSet<T>(list.begin(), list.end()) instead. [-Wdeprecated-declarations]
../shared/viewtestutil.cpp:331:26: warning: 'QSet<T> QList<T>::toSet() const [with T = int]' is deprecated: Use QSet<T>(list.begin(), list.end()) instead. [-Wdeprecated-declarations]
...
tst_qmldiskcache.cpp:651:81: warning: 'QSet<T> QList<T>::toSet() const [with T = QString]' is deprecated: Use QSet<T>(list.begin(), list.end()) instead. [-Wdeprecated-declarations]
tst_qmldiskcache.cpp:663:81: warning: 'QSet<T> QList<T>::toSet() const [with T = QString]' is deprecated: Use QSet<T>(list.begin(), list.end()) instead. [-Wdeprecated-declarations]
tst_qmldiskcache.cpp:693:85: warning: 'QSet<T> QList<T>::toSet() const [with T = QString]' is deprecated: Use QSet<T>(list.begin(), list.end()) instead. [-Wdeprecated-declarations]
tst_qmldiskcache.cpp:918:81: warning: 'QSet<T> QList<T>::toSet() const [with T = QString]' is deprecated: Use QSet<T>(list.begin(), list.end()) instead. [-Wdeprecated-declarations]
tst_qmldiskcache.cpp:940:69: warning: 'QSet<T> QList<T>::toSet() const [with T = QString]' is deprecated: Use QSet<T>(list.begin(), list.end()) instead. [-Wdeprecated-declarations]
tst_qquickgridview.cpp:6437:70: warning: 'QSet<T> QList<T>::toSet() const [with T = int]' is deprecated: Use QSet<T>(list.begin(), list.end()) instead. [-Wdeprecated-declarations]
tst_qquickgridview.cpp:6438:46: warning: 'QSet<T> QList<T>::toSet() const [with T = int]' is deprecated: Use QSet<T>(list.begin(), list.end()) instead. [-Wdeprecated-declarations]
tst_qquickgridview.cpp:6440:66: warning: 'QSet<T> QList<T>::toSet() const [with T = int]' is deprecated: Use QSet<T>(list.begin(), list.end()) instead. [-Wdeprecated-declarations]
tst_qquicktableview.cpp:53:20: warning: 'kTableViewPropName' defined but not used [-Wunused-variable]
tst_qquicklistview.cpp:7269:70: warning: 'QSet<T> QList<T>::toSet() const [with T = int]' is deprecated: Use QSet<T>(list.begin(), list.end()) instead. [-Wdeprecated-declarations]
tst_qquicklistview.cpp:7270:46: warning: 'QSet<T> QList<T>::toSet() const [with T = int]' is deprecated: Use QSet<T>(list.begin(), list.end()) instead. [-Wdeprecated-declarations]
tst_qquicklistview.cpp:7272:66: warning: 'QSet<T> QList<T>::toSet() const [with T = int]' is deprecated: Use QSet<T>(list.begin(), list.end()) instead. [-Wdeprecated-declarations]
tst_qquickpositioners.cpp:4033:70: warning: 'QSet<T> QList<T>::toSet() const [with T = int]' is deprecated: Use QSet<T>(list.begin(), list.end()) instead. [-Wdeprecated-declarations]
tst_qquickpositioners.cpp:4034:46: warning: 'QSet<T> QList<T>::toSet() const [with T = int]' is deprecated: Use QSet<T>(list.begin(), list.end()) instead. [-Wdeprecated-declarations]
tst_qquickpositioners.cpp:4036:66: warning: 'QSet<T> QList<T>::toSet() const [with T = int]' is deprecated: Use QSet<T>(list.begin(), list.end()) instead. [-Wdeprecated-declarations]

Change-Id: I9a177f83f07ae5162f7cc231a8c164ba32ffa5bc
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-05-29 23:47:31 +02:00
Ulf Hermann 7f7d87c68d Split CompiledData::CompilationUnit in two
We need a CompilationUnit that only holds the data needed for
compilation and another one that is executable by the runtime.

Change-Id: I704d859ba028576a18460f5e3a59f210f64535d3
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-05-16 12:09:23 +00:00
Qt Forward Merge Bot a1e38651ce Merge remote-tracking branch 'origin/5.12' into 5.13
Conflicts:
	.qmake.conf
	src/qmltest/quicktest.cpp
	tests/auto/qml/qmlcachegen/qmlcachegen.pro

Change-Id: I70e96e8817d59647f876b8b77b30cdeede8f0662
2019-03-25 10:13:23 +01:00
Mitch Curtis 2fcbb80e33 Don't warn if invokable test setup function doesn't exist
This was never the intention (as the code comments imply), but
it was never tested.

This is a cherry-pick of 50f234df50
because it went to dev (5.13) when it should have originally went
to 5.12.

Change-Id: I8df0b3702129b1f1d086df73117d3ddb721317cb
Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
(cherry picked from commit 50f234df50)
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2019-03-21 09:07:33 +00:00
Mitch Curtis 52ac0ea8cb QUICK_TEST_MAIN_WITH_SETUP: fix qmlEngineAvailable() being called too late
When I added the macro, I wasn't aware that TestCaseCollector was a
thing. TestCaseCollector loads each QML file without running the tests
(i.e. creates a QQmlComponent from the file without creating an object
from that component). Since it still executes imports, the test can
fail if types are registered or import paths added in
qmlEngineAvailable(), since it's called too late.

So, call it earlier. This should have no adverse effect on user code,
as nothing of importance to the user will be skipped, and the
documentation already details what can be expected by the time
qmlEngineAvailable() is called.

Change-Id: Ibd3a4b728bc87b90f89cc310fddf668c5879ad83
Fixes: QTBUG-74160
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2019-03-21 09:07:14 +00:00
Qt Forward Merge Bot e6199a8357 Merge remote-tracking branch 'origin/5.12' into 5.13
Change-Id: I2842f4a8096c4555e29f08e65b88b77b841441cb
2019-02-14 01:00:09 +01:00
Tor Arne Vestbø 91a71bce9c Defer QML testing until event loop has started
Executing the event loop means we get various things set up properly, such
as runloop auto-release pools on macOS.

If not, the whole test suite will be run as a result of the setWindowShown
call.

Change-Id: Ie217d803208134c5be7db0ee04fbfab86702b521
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2019-02-12 15:06:28 +00:00
Qt Forward Merge Bot 3b67ec7abd Merge remote-tracking branch 'origin/5.12' into dev
Conflicts:
	.qmake.conf

Change-Id: I6b2539bf17d3e9bc66d96b53c1bce95680113ed8
2019-01-10 21:37:31 +01:00
Oliver Wolff bcc55604d9 quicktest: winrt: Use qml files from resource system by default
Similar to how it is done for Android, winrt should use qml files from qrc
by default.

Change-Id: I4cd0def2467f764155302fccc393c355907be744
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-01-10 06:55:38 +00:00
Mitch Curtis ab26e8add8 Doc: Fix Qt Quick Test documentation
- Add qtquicktest-cppapi.qdoc for the C++ API landing page.
- Add qtquicktest.qdoc for the QQuickTest namespace.
- Add qtquicktest-qmltypes.qdoc for the QML types landing page.
- Add ../../imports/testlib to the sourcedirs variable so that
  the QML files can be found.
- Add a "Reference" section to qtquicktest-index.qdoc that
  has links to the QML and C++ pages.
- Add more targets so that we can reliably link to them
  while keeping the nice short section names.
- Fix minor issues in existing documentation.
- Link to the QML API docs from the C++ API docs.

Change-Id: I5fc3c90105b095d9ea84c3f76e6c7ba0a47c2695
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2018-12-14 09:53:41 +00:00
Mitch Curtis 50f234df50 Don't warn if invokable test setup function doesn't exist
This was never the intention (as the code comments imply), but
it was never tested.

Change-Id: I8df0b3702129b1f1d086df73117d3ddb721317cb
Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
2018-12-10 10:45:19 +00:00
Mitch Curtis 7efca5aeae Doc: fix \relates command for qIsPolishScheduled()
Change-Id: Ifa59cae9fd682e9884b40cd0be0da59f5e725ffd
Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2018-12-07 12:43:06 +00:00
Mitch Curtis ecbe1c83d2 Doc: explain why QQuickTest::qIsPolishScheduled() is useful
Change-Id: I2df4b18b46f9b532e956a64e4be656a338de7a22
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2018-10-31 08:54:34 +00:00
Mitch Curtis 7a3cad0619 Add QQuickTest::qWaitForItemPolished()
Verifying that an item was polished is quite common in Qt's auto tests:

- The Qt Quick auto tests have a util function for it in
  visualtestutil.h (line 103).
- "git grep polishScheduled -- tests/auto | wc -l" says that there are
  269 usages of polishScheduled in Qt Quick auto tests, almost all of
  which look like this:

  QTRY_COMPARE(QQuickItemPrivate::get(item)->polishScheduled, false);
- QQuickTableView's auto tests have their own function:

  #define WAIT_UNTIL_POLISHED \
      QVERIFY(tableViewPrivate->polishScheduled); \
      QTRY_VERIFY(!tableViewPrivate->polishScheduled)
- More recently, QQuickMenu started requiring it (see menuutil.h).

QQuickItem::polish() and QQuickItem::updatePolish() are both public
functions, so the notion of polishing in Qt Quick is not new or hidden.
This means that any user applications that have custom items that make
use of the polish() => updatePolish() system will benefit from having
a reliable method of testing their behavior. In addition, anyone
wanting to simulate interaction with items in e.g. QQuickMenu will
need this API if they don't want to use unreliable qWait() calls.

With this in mind, this and the previous patch aim to standardise/
simplify the various private API checks and utility functions, and
provide public API for users so that they can benefit from more
reliable tests. When used together, the code will look like this:

    QVERIFY(QQuickTest::qIsPolishScheduled(item));
    QVERIFY(QQuickTest::qWaitForItemPolished(item));

[ChangeLog][QtQuickTest][QQuickTest] Added
QQuickTest::qWaitForItemPolished() for verifying that updatePolish()
was called on an item.

Fixes: QTBUG-71224
Change-Id: I8841910212e7f1a431ba845cae8a1ba7b4f4da67
Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
2018-10-31 08:54:02 +00:00
Mitch Curtis 40d6072bc8 Add QQuickTest::qIsPolishScheduled()
Verifying that an item was polished is quite common in Qt's auto tests:

- The Qt Quick auto tests have a util function for it in
  visualtestutil.h (line 103).
- "git grep polishScheduled -- tests/auto | wc -l" says that there are
  269 usages of polishScheduled in Qt Quick auto tests, almost all of
  which look like this:

  QTRY_COMPARE(QQuickItemPrivate::get(item)->polishScheduled, false);
- QQuickTableView's auto tests have their own function:

  #define WAIT_UNTIL_POLISHED \
      QVERIFY(tableViewPrivate->polishScheduled); \
      QTRY_VERIFY(!tableViewPrivate->polishScheduled)
- More recently, QQuickMenu started requiring it (see menuutil.h).

QQuickItem::polish() and QQuickItem::updatePolish() are both public
functions, so the notion of polishing in Qt Quick is not new or hidden.
This means that any user applications that have custom items that make
use of the polish() => updatePolish() system will benefit from having
a reliable method of testing their behavior. In addition, anyone
wanting to simulate interaction with items in e.g. QQuickMenu will
need this API if they don't want to use unreliable qWait() calls.

With this in mind, this and the follow-up patch aim to standardise/
simplify the various private API checks and utility functions, and
provide public API for users so that they can benefit from more
reliable tests. When used together, the code will look like this:

    QVERIFY(QQuickTest::qIsPolishScheduled(item));
    QVERIFY(QQuickTest::qWaitForItemPolished(item));

The follow up patch adds auto tests.

[ChangeLog][QtQuickTest][QQuickTest] Added qIsPolishScheduled()
function to allow checking if updatePolish() has been called on
an item since the last call to its polish() function.
This is useful to verify that a polish has been scheduled.

Task-number: QTBUG-71224
Change-Id: I856a40321945c0070e4679e11e4812e0d7adc1f9
Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2018-10-31 08:53:58 +00:00
Rainer Keller 7bf8d4d377 Add test cleanup function for C++ parts
This allows to do cleanup in C++ before other parts being destructed.

It QtOpcUa we need to destruct a subprocess. Until now it was done in the
destructor of the setup class. When the destructor is called the eventloop
already died but the process is still sending output when being terminated.
In the windows event handling a nullptr is being dereferenced in this case,
see QTBUG-70641. When terminating this process somewhat earlier, when the
eventloop is still available, the event dispatcher is able to handle those
events without crashing.
Another reason to have this function is because there is applicationAvailable()
being called to initialize C++ code and there should be an equivalent function
for cleaning up.

[ChangeLog][QtQml][QtTest] Add cleanupTestCase() to be called before starting destruction

Change-Id: I24f7a51ec5276a449892609f5b2cfe7957c27668
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2018-09-24 06:10:27 +00:00
Simon Hausmann 77449db6e0 Encapsulate access to CompiledData::Object and CompiledData::Import
This will make it easier to move the data out of CompiledData::Unit and
into a separate data structure.

Change-Id: I32e6233a66f2279b44cc06ef7c3505db4a565f98
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2018-07-31 17:08:57 +00:00
Simon Hausmann e56eeee990 Encapsulate the unit data in CompilationUnit
This allows updating the constants table when the unit data is set /
changes and removes the tie to the engine.

Change-Id: Ice553650390589e30e18421c4e55422a55d0df89
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2018-07-31 05:13:48 +00:00
Rainer Keller ef06a6ba7b Add test init function for C++ parts
This allows to start other processes as counterparts using QProcess.
In the constructor of the setup class it is not possible because no
QApplication object has been instantiated yet.

[ChangeLog][QtQml] Add test init function to be called when application
object is available.

Change-Id: Id24395eca41921c743062522a4aeb6231f9bdf09
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2018-06-25 10:39:21 +00:00
Kari Oikarinen 27fe56d3e7 Exit test executable with failure if specified test functions are not found
If QtQuickTest test executable was given filters that didn't match in any of the
qml files run, it exited successfully.

In combination with a Coin bug when the test function name contains a space,
this allowed failing tests to pass the CI. If the test function fails, the
repeat attempts would pass two arguments to the executable. Neither of those
hit, but that wasn't considered a problem.

Check that all of the test functions named on the command line are actually
executed during the whole run and otherwise exit with a non-zero exit code.

I assume there's no duplicates in the whole names of test functions scoped with
testcase names.

Task-number: QTBUG-68197
Change-Id: Icf7fe263945403f02920522dfd187aeb76b7cb3c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Kalle Viironen <kalle.viironen@qt.io>
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
2018-06-21 13:01:26 +00:00