Commit Graph

255 Commits

Author SHA1 Message Date
Santhosh Kumar 5a664f0836 Release section item when the corresponding view item removed
The section item has not been removed or added to the section cache
in all cases when the corresponding delegate item has been moved out
of the visible area, either during flick or scroll. This happens in
a case where the delegate item has been requested to be removed (as
it goes out of the visible area) from the list view, but it's not
released from the delegate model due to its caching mechanism. When
an item is outside the visible area, releaseItem() is triggered,
intended to free the item and its sections. The problem arises when
releaseItem() calls QQmlInstanceModel::release(), which caches the
item in the delegate model, but does not free the section. This
prevents the section item from being released properly.

This patch releases the section item whenever removeItem is
triggered from the list view, which happens when the delegate item
is moved out of the visible area.

Fixes: QTBUG-137172
Pick-to: 6.10 6.9 6.8 6.5
Change-Id: Ib7e78309e076e76750b03f3238a7501563a3962a
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2025-09-12 22:26:19 +02:00
Mitch Curtis e7b90cfc31 QQmlDataTest: drop default try timeout from 5 seconds to 1
Make debugging of failing tests less painful.

The tests that had to be changed as a result are listed
in the comments of the linked task.

Fixes: QTBUG-138662
Task-number: QTBUG-81979
Change-Id: Iee50f2d4f2160e3e9bc2c7985925583fad810811
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2025-08-07 10:45:29 +08:00
Shawn Rutledge f09eb295c3 tests: do not leak QPointingDevice instances
QTest::createTouchDevice() passes ownership of the device to the caller,
so make sure it gets deleted.

Pick-to: 6.8 6.9
Change-Id: I1289def6b40bf688a7334b9997f7e4319516d018
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-05-10 20:03:44 +02:00
Mitch Curtis 386e085114 QQuickTest: add and use active focus macros
Also add support for popups (when controlstestutils_p.h is included).

[ChangeLog][Qt Quick Test] Added QVERIFY_ACTIVE_FOCUS and
QTRY_VERIFY_ACTIVE_FOCUS macros that can be used to get detailed
failure messages for when QQuickItem::hasActiveFocus should be true but
isn't.

Task-number: QTBUG-133858
Change-Id: I30c67a84ccc16e3969bac5661648d0062bc3d62c
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2025-04-25 08:36:08 +08:00
Giuseppe D'Angelo fb4abf95c1 Tests: include QTest, not QtTest
Never use module-wide inclusions. They blow up build times. For QtTest
this is usually just a typo (QTest was meant instead). Add missing
includes as needed.
In the diffs I've spotted other huge inclusions (QtQuick, QtQml), but
those need more attention.

Task-number: QTQAINFRA-7110
Pick-to: 6.9 6.8
Change-Id: I74bf3fe212f50a7a3a6af2b1c80bbcaabc2516d7
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2025-04-15 19:27:07 +02:00
Zhao Yuhang 60297d4d1e Port away from QPair
QPair is just an alias of std::pair anyway.

Task-number: QTBUG-115841
Change-Id: I26fc90adcc775aac9955ad57304af914dc4ed48f
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2025-04-12 05:39:59 +00:00
Frédéric Lefebvre 6c4d8f3bea Fix flakiness tst_QQuickListView::enforceRange_withoutHighlight
tst_QQuickListView::enforceRange_withoutHighlight is flaky where a key
press is not received when the window is not active yet and fails.

Verify that the window is active before sending the keypress event.

Unblacklist tst_QQuickListView::enforceRange_withoutHighlight on
Opensuse as it is no longer flaky.

Pick-to: 6.9 6.8 6.5
Change-Id: Ib1013a73d9267354f7d045345bac74125366ff03
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-25 22:54:41 +01:00
Ahmad Samir baa774f1c0 tests/: more const containers instead of std::as_const()
- Where the data is known at compile time, use C arrays
- Initialize QStringList with initializer_list instead of the
  operator<<() style
- Make QPoint/F for-loop variables values, their sizes are two ints and
  two doubles, respectively
- std::array isn't a Qt container, so std::as_const is redundant, no
  detach possible

Task-number: QTBUG-115808
Change-Id: I995c98bc4f35907704b6e64786a90cf8375575f0
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-01-07 01:47:40 +02:00
Shawn Rutledge 99c6706b92 Replace mouse-only flick, moveAndPress, moveAndRelease in tests
Since d7623d79ef Flickable has worked
directly with touch events; and we are expected to have stylus devices
(QTabletEvents) working well too. So we need to be able to expand the
test coverage to more types of devices. This is the first step.

Pick-to: 6.8
Change-Id: I93a3a4b84424eb69e0cd7c9f4ebe58b9f27082d9
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2024-07-02 08:43:08 -07:00
Shawn Rutledge 5b560981de Avoid infinite loop in ListView/GridView snapOne/snapTo tests
I'm not sure if any actual CI failures resulted from failure to
terminate the do..while loops, but it seems likely, since a recent patch
seems to provoke that. It's better to fail after a reasonable number of
loops, rather than letting it go and hoping for a timeout. In practice
it seems 2 rounds is enough, so let's try 4 as the limit.

While we're at it, round the grid.contentX/contentY values that are
displayed. Intermediate values have always been shown with way too many
decimal places, which interfered with whatever value it has to display
the numbers.

Pick-to: 6.8
Task-number: QTBUG-33017
Task-number: QTBUG-88644
Change-Id: I2fc4843071276b3af544c2506eb152698542cd06
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
2024-07-02 08:43:00 -07:00
Shawn Rutledge 0debcf3ed3 Call QQuickItem::mouseUngrabEvent() on ungrab from QTabletEvent
As long as we rely on QGuiApplicationPrivate::processTabletEvent() to
synthesize mouse events from tablet events (we aren't doing it on the
fly as with touch events in 468626e99a),
and as long as most QQuickItems are not handling tablet events,
QQuickDeliveryAgentPrivate::onGrabChanged() almost always sees a
QMouseEvent losing its grab when e.g. ListView takes over from one of
its delegates while the user is trying to scroll with a stylus device.
This event's device is the stylus, though.

Whenever we see an EventPoint being canceled or ungrabbed, we must call
either mouseUngrabEvent() on the item, or touchUngrabEvent() if all the
points are released or cancelled, to avoid items getting "stuck" in
pressed state. It must not be skipped. So call mouseUngrabEvent()
whenever the event is a QSinglePointEvent, and touchUngrabEvent()
otherwise (since only touchscreens send multi-point events).

Make QQuickTest::pointerPress/Move/Release functions more correct for
stylus devices:
- we need the timestamp to monotonically increase, even though
  QTest::defaultMouseDelay() is usually 0 (which isn't sensible)
- QTest::mouseEvent() calls qt_handleMouseEvent which converts
  logical coordinates to native positions; but for tablet events,
  do it here for now, since there are no QTest methods to generate them.
  This helps QQuickFlickablePrivate::handleMoveEvent() to calculate
  deltas correctly.

Fixes: QTBUG-118903
Pick-to: 6.8 6.7 6.6 6.5
Change-Id: I5ec54c5181f5b9137fe16248884010aea94f671a
Reviewed-by: Doris Verria <doris.verria@qt.io>
2024-06-28 17:12:14 -07:00
Jan Arve Sæther 5e190fa77e Fix flaky test tst_qquicklistview::multipleTransitions
The test assumed that an item inserted in the beginning of the ListView
will always end up at position 0 (x or y).

This is wrong assumption, since the ListView can choose to put the new
items above/left of the existing items without having to adjust the
coordinates of all of the existing items, and then accordingly it will
adjust the origin(X,Y), ensuring that the visual rendering will
be the same for both cases.

The documentation of Flickable::originY explicitly mentions this
(https://doc.qt.io/qt-6/qml-qtquick-flickable.html#originY-prop):

 "originY : real
  [...]
  This is usually (0,0), however ListView and GridView may have an
  arbitrary origin due to delegate size variation, or item
  insertion/removal outside the visible region."

This can also be reproduced without any transitions, so assuming that
the y coordinate of the first item is always 0 should therefore strictly
not be part of a test intended for transitions.

Pick-to: 6.7 6.8
Fixes: QTBUG-123894
Change-Id: Idc63cd385ed62936d9e45e31fcf3f725ee4405c4
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2024-06-28 13:28:45 +00:00
Ivan Solovev 249fe4ba12 ListView: take section size into account while snapping an item into place
In case the sections are displayed using ViewSection.CurrentLabelAtStart,
the section size should be taken into account while snapping the items.
This patch extends the fixup() method to perform such checks.
The drawback of this approach is that the position adjustment takes
some time (because of the animation) and happens after the scrolling is
finished.
A better solution would be to fix the scrolling process in such a way,
that no adjustment is needed during fixup.

Fixes: QTBUG-30768
Pick-to: 6.8 6.7 6.5 6.2
Change-Id: I31a1a3af55afe8be4e8d7980cbb163622e3283bc
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2024-06-27 16:19:19 -07:00
Tor Arne Vestbø 81552d4712 Replace all occurrences of Q_OS_MAC with more appropriate defines
Pick-to: 6.8
Change-Id: I6ea24d0439c78efbb1df242fb980d3d8b084eeb2
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-06-04 10:11:35 +00:00
Mitch Curtis 617476d45b quicktestutils: rename delegateVisible to isDelegateVisible
Because it's the convention.

Pick-to: 6.5 6.6 6.7
Change-Id: I1d3d53f5c051ede0b011c1daa9d1019cad8875f8
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2024-03-21 17:41:29 +08:00
Lucie Gérard 9c5fc88388 Correct license for test files
According to QUIP-18 [1], all test files should be
LicenseRef-Qt-Commercial OR GPL-3.0-only

[1]: https://contribute.qt-project.org/quips/18

Pick-to: 6.7
Task-number: QTBUG-121787
Change-Id: I26d72e8de04d4c7c57b3b7838af5d033265de5ba
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2024-02-27 10:32:21 +01:00
Ulf Hermann 7cb7f6ab7f Remove remaining foreach in quick tests
Task-number: QTBUG-115808
Change-Id: I30c27cf9972257897f15d57d62ff05ad1028b35e
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-08-23 15:30:11 +02:00
Marc Mutz 8edbcdbeb4 Mark the module as free of Q_FOREACH, except where it isn't
The density of Q_FOREACH uses is high here, too high for this author,
unfamiliar with this code, to tackle in a short amount of time. But
they're concentrated in just a few TUs, so pick a different strategy:

Mark the whole module with QT_NO_FOREACH, to prevent new uses from
creeping in, and whitelist the affected TUs by #undef'ing
QT_NO_FOREACH locally, at the top of each file. For TUs that are part
of a larger executable, this requires these files to be compiled
separately, so add them to NO_PCH_SOURCES (which implies
NO_UNITY_BUILD_SOURCES, too). Created QTBUG-115808 to keep track of
this.

Task-number: QTBUG-115808
Change-Id: I29c377f939e3d747e3ce72c224c4ee722df7a95d
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-17 18:04:35 +02:00
Volker Hilsheimer 77886b496d Quick item view tests: fix compile warning
Don't use QCOMPARE for a true/false test, use QVERIFY. This conveniently
fixes the (bogus, perhaps) compiler warning with MSVC about comparing
a quint32 (the underlying type of the polishScheduled bitfield) with a
bool.

Pick-to: 6.5
Change-Id: Ib273ee30906e09955e849e65af2b7ff8ce3e2512
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2023-04-18 13:11:16 +02:00
Santhosh Kumar 3214689afd Fix content position of list view
The content position of list view is incorrect, if populate animation
is configured with BottomToTop or RightToLeft layout direction. This is
because, we are not setting internal position for first item in the
list view.

This patch will set correct internal postion to the first item in list
view.

Fixes: QTBUG-111050
Change-Id: I1a233a938e2c088d176d79871a08bcd2a8edd6b3
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2023-03-03 12:02:00 +01:00
Sami Shalayel e1cebe8128 QQuickMouseArea: do not overload pressed-signal
Renames the pressed() getter of the pressed property in QQuickMouseArea
to isPressed() to avoid overloading the pressed()-signal.
Signals should not be overloaded. Also, it makes code generation in
qmltc more complicated.

Task-number: QTBUG-110029
Change-Id: I2373f4fe97b1e955b815825003bc746f2eaf43be
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2023-01-24 13:41:45 +01:00
Shawn Rutledge 14321d2736 tst_QQuickListView::QTBUG_38209: QTRY_COMPARE_GE instead of QTRY_VERIFY
We need to see the values when it fails. It turns out that the movement
can be exactly 100 on macOS, and that's also "more than just a couple
pixels" so it should be ok.

Pick-to: 6.5
Change-Id: I4dcdf647886dd5dcc7267a32b1dd9858fdccf64d
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2023-01-11 20:13:18 +01:00
Shawn Rutledge 0461a51c8e tst_QQuickListView::flickBothDirections: flick more
If we make flickDeceleration's default value platform-dependent and
often larger, this test begins failing because it expects to flick
all the way to the end of the ListView. If we flick a longer distance
(starting at the lower-right instead of in the middle of the ListView)
in the same time, it's more likely to get to the end.

An alternative would be to set flickDeceleration back to the old value
in this test.

Pick-to: 6.5
Change-Id: If85d9502ceef9fbf6fc087240572cc98326453a5
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2023-01-05 06:04:29 +01:00
David Redondo 99047ae219 QQuickItemView: Fix max(X/Y)Extent()
QQuickFlickable maxXExtent() and maxYExtent() return the amount of space
that is not shown when inside a ScrollView. QQuickItemView however just
returned width() if vertical and height() if horizontal. In these cases
just defer to the QQuickFlickable base implementation like minXExtent()
and minYExtent() already do.

Fixes: QTBUG-83890
Pick-to: 6.2 6.4
Change-Id: I7f4060c2f46ae07611bedceca0d322c5f7f6affb
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-11-22 17:01:07 +01:00
Marc Mutz 5eb52b7255 Port from container::count() and length() to size() - V5
This is a semantic patch using ClangTidyTransformator as in
qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to
handle typedefs and accesses through pointers, too:

    const std::string o = "object";

    auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); };

    auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) {
        auto exprOfDeclaredType = [&](auto decl) {
            return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o);
        };
        return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))));
    };

    auto renameMethod = [&] (ArrayRef<StringRef> classes,
                            StringRef from, StringRef to) {
        return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)),
                            callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))),
                        changeTo(cat(access(o, cat(to)), "()")),
                        cat("use '", to, "' instead of '", from, "'"));
    };

    renameMethod(<classes>, "count", "size");
    renameMethod(<classes>, "length", "size");

except that on() was replaced with a matcher that doesn't ignoreParens().

a.k.a qt-port-to-std-compatible-api V5 with config Scope: 'Container'.

Change-Id: I58e1b41b91c34d2e860dbb5847b3752edbfc6fc9
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-10-13 00:18:35 +02: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
Mitch Curtis 08398aed81 tst_qquicklistview: remove some bindings to parent
See ed73efa27a.

Pick-to: 6.2 6.3 6.4
Change-Id: I32434afcfd5faaf1c05b50cd96dfe6e6468f3ac4
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-08-25 09:56:09 +08:00
Mitch Curtis 811009ffea tst_qquicklistview: fail on warnings
Task-number: QTBUG-98718
Pick-to: 6.2 6.3 6.4
Change-Id: Ia1395236848582681d03f43792ca92ed07db0408
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-07-05 14:34:37 +08:00
Mitch Curtis 234afb5502 Add convenience API for making QQmlDataTest-based tests fail on warnings
After this patch, if a QQmlDataTest-derived class passes
FailOnWarningsPolicy::FailOnWarnings to the base constructor, any
non-empty warning encountered by that test will result in a test
failure.

This avoids the need to duplicate the catch-all regex in tests that
want to fail on warnings.

The goal is to gradually enable failure-on-warnings over time.

Leave comments and explicitly pass DoNotFailOnWarnings for tests that
should never fail on warnings.

Task-number: QTBUG-98718
Pick-to: 6.2 6.3 6.4
Change-Id: I4b647d93a0f28ac891c4bdb19ef74569f2918e8f
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-07-05 14:34:37 +08: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 e58626a02b tst_qquicklistview: fix some TypeErrors and ReferenceErrors
- Ensure that context properties outlive the view.
- Ensure that delegates don't unconditionally reference properties of
the parent (which may be null).
- Add missing TestObject and test model.

Task-number: QTBUG-98718
Pick-to: 6.2 6.3 6.4
Change-Id: Icaf3c6824674819c88fc7be51932e6d7e5fb205a
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-06-10 10:32:31 +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
Fabian Kosmale 4f50697e6c Do not rely on transitive includes in tests
Change-Id: Icb68dbecab6f675352cd58333c82fa6648025367
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-02-14 12:38:10 +01:00
Mitch Curtis 5d656b31eb Revert "Fix ListView.isCurrentItem when used with DelegateModel"
This reverts commit d9f9d773e9.

It causes a heap-use-after-free in tst_swipeview.qml.

Task-number: QTBUG-97423
Pick-to: 5.15 6.1 6.2
Change-Id: I42e9831ae1399a010df28c39496a7778121f5e35
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2021-11-26 21:23:08 +01:00
Joni Poikelin d9f9d773e9 Fix ListView.isCurrentItem when used with DelegateModel
Fixes: QTBUG-86744
Pick-to: 5.15 6.1 6.2
Change-Id: I7287b39afc8f84e336aa46739b534e33e4212ea7
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-09-29 13:39:41 +02:00
Mitch Curtis e310dadef7 Consolidate test helpers into private libraries
Previously each test would include and build sources from the shared
folder. Now we make those sources a library, build it once, then have
each test link to it instead.

We also take the opportunity to move some helpers that qtquickcontrols2
had added into the quicktestutils library where it makes sense, and
for the helpers that don't make sense to be there, move them into
quickcontrolstestutils.

We add the libraries to src/ so that they are internal modules built as
part of Qt, rather than tests. That way we can use them in a standalone
test outside of qtdeclarative.

Task-number: QTBUG-95621
Pick-to: 6.2
Change-Id: I0a2ab3976fdbff2e4414df7bdc0808f16453b80a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-09-13 21:17:04 +02:00
Ulf Hermann 7c60fc811e Avoid memory leak in tst_qquicklistview
Change-Id: I74733325cdd81aa304c2e55acb257b1dbdb1300d
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2021-08-17 16:14:53 +02:00
Mitch Curtis 0e3902b83d ListView: support QList<QUrl> models
For now this patch just tacks on another list type, but there may be a
better way to account for all types in the future.

This change also adds tst_qquicklistview2 to speed up development.
tst_QQuickListView is 10000 lines long, and compiling it
is slow (36 seconds on a 2016 i7 MacBook Pro). In addition, a similar
approach (creating a second test to avoid the slowness of a massive one)
already exists for QQuickItem tests.

Task-number: QTBUG-72906
Pick-to: 6.1
Change-Id: I05455a2f20978b07eb38591ab63e7d0fb7dac1ab
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-04-29 13:20:09 +02:00
Jan Arve Sæther 79014a1b39 QQuickListView: Add autotest so that animated delegate does not crash
This is separate from the fix, since the test is supposed to also be
merged into dev. (Where the fix was not needed)

Task-number: QTBUG-86567
Pick-to: 5.15
Change-Id: I2cf1a4b11eed4fe356588aeff322d3a432f0fe83
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-02-03 12:01:40 +00:00
Shawn Rutledge ca4d628836 Attempt to stabilize tst_QQuickListView::sectionsSnap
It only failed due to being in a "bad" sequence with other tests somehow.
Fixing by reordering is lame, but I can't find the actual reason that it
fails, so far.

Task-number: QTBUG-86729
Change-Id: I8450c2e4b3119326c8518a526801cd10e933dca0
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2020-11-24 12:33:09 +01:00
David Skoland e47edfe7a7 Update tests to use new metaType system
Change from the QVariant enum to the QMetaType enum and prefer typeId
over userType where possible

Change-Id: Ic89c55978d46cc23d23b8e9c82c475c0c220fae3
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-11-02 14:56:00 +01:00
Volker Hilsheimer 1270a88cb3 Fix compile warnings from tests
Use streaming operators for debug/warnings to avoid qsizehint/int
conflicts.
Don't ignore return values from [[no_discard]] functions.
Don't copy elements from containers that return references.
Remove unused variables.

Change-Id: I7a0bef94a5e828bd8facee0c625ec48c3d1f1bdb
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-10-22 16:00:22 +02:00
Shawn Rutledge 6857ad3e68 QQuickListView: prevent mouse delivery in floating header or footer
Earlier we reimplemented the contains() method of ListView to prevent
dragging in an Overlay or Pullback header or footer. But in QQuickWindow
(QQuickWindowPrivate::pointerTargets()), an early check prevents
delivery of pointer events to an item that is clipped and for which
contains() returns false, and also to its children.  In that case, the
header or footer no longer responds to a mouse event even if you put a
MouseArea in it.

Reverts 6ad3445f1e159d9beea936b66d267dcaacdc5d6c; reimplemented using
similar logic in a new QQuickListViewPrivate::wantsPointerEvent()
method, overriding QQuickFlickablePrivate::wantsPointerEvent(), which
is now checked in event-handling code in addition to checking the
interactive flag.

Done-with: Wang Chuan <ouchuanm@outlook.com>
Pick-to: 5.15
Task-number: QTBUG-74046
Fixes: QTBUG-85302
Change-Id: I9474f035d26b74ee36c0ac19e45a77de2e694bf1
Reviewed-by: Wang Chuan <ouchuanm@outlook.com>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2020-10-07 11:08:41 +02:00
Shawn Rutledge 21f9f02e94 Stabilize tst_QQuickListView::parentBinding
Some platforms aren't registering their mouse devices yet, and we don't
want false failures in CI because of that, so just register a mouse,
even if it ends up being an extra one a lot of times.

Task-number: QTBUG-86729
Change-Id: Ia3a91e3d1e4fb8df90352555c9a7ec6ea18bf6fe
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2020-09-24 23:09:23 +02:00
Shawn Rutledge d0ae3a312a Remove QQuickPointerDevice in favor of QPointingDevice
...and generally deal with changes immediately required after adding
QInputDevice and QPointingDevice.

Also fixed a few usages of deprecated accessors that weren't taken
care of in 212c2bffbb.

Task-number: QTBUG-46412
Task-number: QTBUG-69433
Task-number: QTBUG-72167
Change-Id: I93a2643162878afa216556f10808fd92e0b20071
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2020-06-23 17:44:03 +02:00
Fabian Kosmale ab03621516 Cull removed items from QQuickItemView
Amends a20132c326, which fixed a crash,
but also prevented the item from being culled. This is fixed by
narrowing the scope of the condition to affect only the caching related
part.

Fixes: QTBUG-84604
Pick-to: 5.15
Change-Id: I9b8a1a148d6538a18280475d89b87a4049ff3465
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2020-06-15 17:52:16 +02:00
Shawn Rutledge 880ce02104 Modernize tst_QQuickListView::QTBUG_39492
- Don't use context properties: a singleton is better
- Use required properties to declare dependendencies
- Rename to treeDelegateModelLayoutChange() to describe what it's testing
  rather than just a bug number, and because it's somewhat analogous to
  tst_QQuickPathView::treeModel()

Task-number: QTBUG-39492
Change-Id: I753bbdf625b8d8c82774b6a2b1754fe3c8895823
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-06-10 18:55:37 +02:00
Shawn Rutledge a24a49dfbb Autotests: use std::atomic in incubateWhile()
Followup to a9bf6e652a

Change-Id: Ic010f2610177f93f8fc4e2312d6736c96390e585
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-05-15 08:48:03 +02:00
Simon Hausmann 0293ea2991 Update dependencies.yaml and adapt to API changes in qtbase
The evaluation callback does not have to perform the comparison anymore
and the shared pointer of the private is not used in the API anymore.

Also, the versionFunctions() has been moved out of QOpenGLContext
and renamed QOpenGLVersionFunctionsFactory::get().

QHash doesn't keep iterators stable under erase(), so clean up
the code relying on it, and avoid an intermediate QList at the
same time.

Task-number: QTBUG-74409
Change-Id: I90176be1067d88c8f2b1ea07198a06d432f5be9c
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2020-04-22 10:21:44 +02:00