aboutsummaryrefslogtreecommitdiffstats
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
* Clean up and un-blacklist tst_QQuickMouseArea testsShawn Rutledge2020-11-202-436/+251
| | | | | | | | | | | | | | | | - Use QQuickTest::showView() consistently to reduce boilerplate - Use QTest::mouse*() where possible rather than constructing QMouseEvents (and potentially getting them wrong) - Use QPointingDevicePrivate::firstPointExclusiveGrabber() on a specific device to check grab state rather than QQWindow::mouseGrabberItem() - The warning "event went missing during delivery!" has been removed, so tst_QQuickMouseArea::nestedEventDelivery() shouldn't expect it Task-number: QTBUG-86729 Change-Id: Ieb1af38c118dadf8cdf8ae19f92002207d71d5b5 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit f1a9c9b4273ec6104a0543b5cf48281141f613e6) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix tst_QQuickMouseArea::notPressedAfterStolenGrab againShawn Rutledge2020-11-193-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | Most of the time, QQuickWindowPrivate::deliverMatchingPointsToItem() doesn't need to call item->mouseUngrabEvent() because all grab changes are notified via the connection from signal QPointingDevice::grabChanged to slot QQuickWindowPrivate::onGrabChanged(). But in this case, MouseArea only accepts the event, rather than taking the grab itself. Therefore at the time the grab is "stolen", there was not yet any grabber, because grabbing is done after delivery. But we still need to inform MouseArea that it's not getting the grab it expects to get, so that it can reset its pressed state. But we don't want it to be redundant (other tests are counting events, and we don't want repeated ungrabs to show up in those); so now we have to track whether the item on which we're about to call mouseUngrabEvent() has already gotten it. This illustrates another problem with the tradition of accepting events and being unclear about what it means. Grabbing is one thing, ending delivery is another. Amends a97759a336c597327cb82eebc9f45c793aec32c9 Task-number: QTBUG-55325 Task-number: QTBUG-86729 Change-Id: I8150f901e00e7a71499fc98ab54f0ba75370f3ec Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Conditionally disable tests that depend on cxx11_future flagTony Sarajärvi2020-11-191-0/+2
| | | | | | | Task-number: QTBUG-88650 Change-Id: I2cac1b8ca7ec8ed8401206cf761244b3f483ca14 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Stop ungrabbing due to FocusAboutToChangeShawn Rutledge2020-11-181-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The goal is to un-blacklist the test for QTBUG-60123. To that end: revert 7b2e2117162594a2d0234bb02408f5b5a446488b and its followup 6933b7e8e6dc279a8eb34e1f4c60bc109dfb7d26. There is no detailed bug report explaining exactly why those were done, just the comment on code review: "This fixes the desktop components' combo box on linux re-opening at random times", probably referring to a combobox popup window in Controls 1. But when using QWidget::createWindowContainer() in two different windows and clicking MouseAreas in each of them, it turns out that this change of focus is causing the mouse grab to be canceled. The grab should be naturally given up after mouse release; canceling prematurely doesn't make sense. The Qt 5 fix for this bug was e0c30279ec1fad88346ed3fb483bc3c672fdd01b which tracked the grab on a per-window basis. It would be difficult to do that again now (change QPointingDevicePrivate::setExclusiveGrabber() to store a separate grabber for each window in which a grab occurred? what could go wrong...) It seems odd to have the same QEventPoint grabbed in two different windows at the same time, but popups need event forwarding so maybe that was why (if a MouseArea triggers the popup, should it stay pressed and keep its grab? the subsequent mouse moves and the release need to be forwarded to the popup, so maybe something inside the popup needs a grab, simultaneously or not). Anyway we don't have actual popup windows in Controls 2 right now; and we know that event forwarding for popups needs work in QtGui so that it will be easier when we try again to have them in Qt Quick (QTBUG-68080). So perhaps the original workaround has outlived its usefulness: popup event forwarding needs to be handled at the lower layer, not in Qt Quick. Task-number: QTBUG-57253 Task-number: QTBUG-60123 Task-number: QTBUG-86729 Change-Id: I56dbc3bb94f66a7f26f79a97bcb2f2bbc0b7aa92 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* tst_ma::pressedCanceledOnWindowDeactivate: don't pop up second windowShawn Rutledge2020-11-182-13/+2
| | | | | | | | | | | | | | I guess I must have thought it would be more realistic that way; but sending an explicit WindowDeactivate as we had it in early Qt 5 seems to keep the test passing now, and is probably more reliable. The original purpose of the test seems to be to verify the recursive delivery to all items via virtual QQuickItem::windowDeactivateEvent(), which MouseArea (and no other item!) overrides to ungrab the mouse. This mostly reverts commit 1c451b40aee66a38ca3d61e5beec4ae8c986c8ed. Change-Id: I0c6f953514095a491120a0aac9944dc8b04ca17d Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* tst_qqmlproperty: Fix interfaceBinding crash on MSVC 2019Maximilian Goldstein2020-11-182-8/+25
| | | | | | | Change-Id: I4bb4a66b7ccca838e058962bbc297659b273c78e Done-with: Fabian Kosmale <fabian.kosmale@qt.io> Fixes: QTBUG-84416 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Use metatype and remove unused variableDavid Skoland2020-11-183-4/+2
| | | | | Change-Id: I709c6a74dc6a3eb0cdd3e94168921274f90df4a4 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* tst_qmllint: Be more verbose when qmllint crashesUlf Hermann2020-11-171-0/+8
| | | | | | | Output the command line, exit status, exit code, stderr and stdout. Change-Id: I81a813bc44b7caf4c25d9097e8fbcbc3295ac6ec Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix tests that used out-of-context mouse grabsShawn Rutledge2020-11-173-9/+8
| | | | | | | | | | QQuickItem::grabMouse() is deprecated, and cannot be used at all when there is no current event being delivered. But we can still use QPointingDevicePrivate::setExclusiveGrabber(). Task-number: QTBUG-86729 Change-Id: I215de471e6dc44551720bc4c766b22cdfee94423 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Clean up tst_TouchMouseShawn Rutledge2020-11-171-424/+358
| | | | | | | | | | - The view-showing boilerplate is reduced - Uncommented and fixed up some statements that were failing at one time - Fixed override warnings - Use qCDebug not qDebug Change-Id: Ib437cc985c03776492da2502ecdb5176afadadf2 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Add QQuickTest::showView(); give QQuickTest::initView() default argsShawn Rutledge2020-11-172-13/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now the boilerplate for most QML-using C++ tests can be reduced from QQuickView window; QByteArray errorMessage; QVERIFY2(QQuickTest::initView(window, testFileUrl("myitems.qml"), true, &errorMessage), errorMessage.constData()); window.show(); QVERIFY(QTest::qWaitForWindowExposed(&window)); QVERIFY(window.rootObject() != nullptr); to QQuickView window; QVERIFY(QQuickTest::showView(window, testFileUrl("myitems.qml"))); The idea to dump the QML error output was nice, but the engine already generates QWARN output like this (lines partially wrapped, URL elided for brevity): QWARN : tst_TouchMouse::touchPointDeliveryOrder() [ 0.000 W] default unknown - file:/...rder.qml:14:29: Cannot assign to non-existent property "pill" Rectangle { anchors.pill: parent; color: "lightsteelblue" } ^ FAIL! : tst_TouchMouse::touchPointDeliveryOrder() 'QQuickTest::showView(window, testFileUrl("touchpointdeliveryorder.qml"))' returned FALSE. () Loc: [/home/rutledge/dev/qt6/qtdeclarative/tests/auto/quick/touchmouse/tst_touchmouse.cpp(1343)] Improves on a804f31ee2665501c1894cbae8302db181090bd5 Change-Id: I92b8e3720bb5b1d009580bb74566690ad3d5292c Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* When Flickable filters UngrabMouse, react as if it was ungrabbed itselfShawn Rutledge2020-11-171-2/+0
| | | | | | | | | | | | | | | | | | | | | Fixes tst_QQuickListView::touchCancel again. In this scenario, a TouchCancel is sent, but gets turned into an UngrabMouse for delivery to the MouseArea which is the current grabber. We try to avoid calling QQuickWindow::mouseGrabberItem() because it's too vague a question to ask (which mouse? or did you mean the synth-mouse during synthesis from a touch or tablet event?); and now it acts different anyway, because eventsInDelivery.top() is an UngrabMouse, which did not include a pointer to the QPointingDevice until now. So now we turn the UngrabMouse event into a QSinglePointEvent so that it's possible to get exclusiveGrabber() and check that the grabber is not the same Flickable. (Otherwise, the grabber that's getting ungrabbed is usually the child receiver item sent to childMouseEventFilter().) Task-number: QTBUG-86729 Task-number: QTBUG-74679 Change-Id: I6dfd96686bdfb54723bbe093406b6ab1f75de855 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Add tst_qquickflickable::parallelTouchShawn Rutledge2020-11-172-0/+110
| | | | | | | | | | | Prove that we can drag multiple Flickables with multiple touchpoints now. [ChangeLog][QtQuick][Flickable] Flickable now handles touch events directly: you can now drag multiple Flickables with multiple touchpoints. Fixes: QTBUG-30840 Change-Id: I0a3e58595a67f5afb4b93ad64d5280cb3fc52f7a Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Add tst_qquicktextedit::inFlickable testsShawn Rutledge2020-11-172-0/+126
| | | | | | Task-number: QTBUG-88169 Change-Id: Iaea3959365a580f3f8d2dd7ab2b227933e79cf59 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix incorrect assumptions with Metal in tst_qquickwindowLaszlo Agocs2020-11-171-4/+8
| | | | | | | | | Two cases fail due to attempting to query the MTLRenderCommandEncoder in a state where QRhi::beginPass() was not yet called. This is invalid and we should not test for it either. Change-Id: Ieaaaabd275db68be98365fb76a39f30a635d3543 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* tst_qqmlproperty: Skip crashing interfaceBindingMaximilian Goldstein2020-11-171-0/+3
| | | | | | Task-number: QTBUG-84416 Change-Id: I79048233041802fe74e28b07def5ca0a3181c358 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QV4Engine: Fix conversion of char16_tUlf Hermann2020-11-171-1/+17
| | | | | | | | This is a single char16_t, not an array of them. Pick-to: 5.15 Change-Id: I55d23ebb5f2abebd43cd4160a75d373706392ddf Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Don't synthesize mouse from touch for items that accept touchShawn Rutledge2020-11-175-146/+126
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Followup to 1457df74f4c1d770e1e820de8cd082be1bd2489e : if an item that has acceptTouchEvents() == true merely fails to accept one touch event, that does not mean a mouse event should be sent. Finish changing the default to false: handling touch events is opt-in, just like handling mouse events; most items don't. And if you opt in, then you MUST handle touch events, because you will NOT receive mouse events as a fall-back. Now that Flickable handles touch, filtering multi-touch events becomes relevant. There was a failure in tst_touchmouse::mouseOnFlickableOnPinch when Flickable grabs a stationary touchpoint at the same time as another touchpoint is pressed, preventing a child PinchArea from reacting. So there's a new rule: just as we start over with event delivery when a new point is pressed, QQuickFlickable::filterPointerEvent() should also not immediately grab when any point is newly pressed; it can afford to wait, because it's filtering, so it will be able to see if one point is dragged past the drag threshold later on. When a parent (such as Flickable) contains only mouse-handling items (such as MouseArea), the parent should filter the touch event if it is able (if acceptTouchEvents() returns true). Flickable is now able to. Filtering parents that are not able to filter touch events can still filter a synth-mouse event as before. But filtering both must be avoided: then we would have the problem that Flickable filters a touch move, sees that it's being dragged past the drag threshold, and sets d->stealMouse to true to indicate that it wants to steal the _next_ event; then it filters a synth-mouse move, and that's perceived as being the next event even though it's just a different view of the same event, so it steals it. In tst_qquickflickable::nestedMouseAreaUsingTouch we rely on the delay caused by waiting for the next event: the MouseArea is trying to drag an item and the Flickable wants to flick; both of them decide on the same event that the drag threshold is exceeded. But MouseArea calls setKeepMouseGrab() immediately, whereas Flickable doesn't try to steal the grab until the next event, and then it sees the keepMouseGrab flag has been set, so it doesn't do it. If Flickable could filter the same event twice (once as touch, once as synth-mouse), this logic doesn't work, so it's effectively "more grabby" than intended. So it works better to have it filter only the actual touch event, not the synth-mouse that comes after. When the child has pointer handlers, we need to visit them, and therefore we should let Flickable filter a touch event on the way. tst_FlickableInterop::touchDragFlickableBehindButton() depends on this. [ChangeLog][QtQuick][QQuickWindow] In Qt 6, a QQuickItem subclass must explicitly call setAcceptTouchEvents(true) to receive QTouchEvents, and then it must handle them: we no longer fall back to sending a QMouseEvent if the touch event is not accepted. If it has additionally called setFiltersChildMouseEvents(true), then it will filter touch events, not any synthetic mouse events that may be needed for some children. Task-number: QTBUG-87018 Fixes: QTBUG-88169 Change-Id: I8784fe097198c99c754c4ebe205bef8fe490f6f4 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Stabilize tst_QQuickMultiPointTouchArea::inFlickableWithPressDelayShawn Rutledge2020-11-161-9/+17
| | | | | | | | Flickable moves after taking over the grab, but this test was failing anyway. Might as well check for everything in one loop of move events. Change-Id: Iafa21cdfb88df36337e4350934d3bf569418bdca Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Blacklist tst_qquickpointhander::tabletStylus on macOSShawn Rutledge2020-11-161-0/+2
| | | | | | Task-number: QTBUG-88541 Change-Id: I35b3f99c4268b6615da373f90b53b6ca6ef16fce Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Don't copy or assign QEvent instances in testsVolker Hilsheimer2020-11-165-582/+768
| | | | | | | | | | | | | | | Copying/assigning polymorphic types is a code smell, use separate instances instead in the tests. Those should perhaps be rewritten to use a data driven testing approach, there's a lot of code repetition. In the test API implementation, first evaluate the parameters for the event, then construct the event once with the correct values. Change-Id: I2572772698cb0204f5ff950741b9fe3805fae15d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Use QFileInfo constructor explicitlyVolker Hilsheimer2020-11-151-2/+3
| | | | | | | Prepare for upcoming changes in qtbase. Change-Id: I592fe857dde13ce570f1525b5f327a07773be123 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* qmltyperegistrar: Use QString rather than string for stringsUlf Hermann2020-11-121-1/+1
| | | | | | | | All other type names are actual C++ type names. Also, correctly resolve qreal if its type is overridden at configure time. Change-Id: Ia2a1b4309f94e8c72461ee69005b1bdee6337370 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQuickViewTestUtil: mark QAIM method overridesShawn Rutledge2020-11-121-6/+6
| | | | | | | | Fixes a few -Wsuggest-override warnings with gcc 10.2 (but there are more). Change-Id: I36c29c6f2dc1577a05514950ce1a6b3a24da4f55 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: David Skoland <david.skoland@qt.io>
* ListModel: support URLsFabian Kosmale2020-11-122-0/+30
| | | | | | Fixes: QTBUG-88379 Change-Id: I6e2ea550d8f8972c5fdcdc21a5e3851992c591a5 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Fix QQWinPriv::deliverSinglePointEventUntilAccepted for wheel, gesturesShawn Rutledge2020-11-121-3/+0
| | | | | | | | | | | | | | | | | | | | | | WheelHandler was only reacting to one wheel event between mouse moves, because it got added to the QQPointerHandlerPriv::deviceDeliveryTargets() vector, and was not removed at the beginning of delivery of subsequent events, as QQuickWindowPrivate::deliverPointerEvent() does. (In Qt 5 the equivalent vector was cleared in QQuickPointerMouseEvent::reset().) Wheel events are delivered via deliverSinglePointEventUntilAccepted() (grabbing the wheel is still not implemented). Native gesture events are delivered that way too; and sure enough, the same bug happens on the macOS trackpad, whether you are attempting to do pinch zoom or just two-finger-flick. tst_QQuickWheelHandler::nestedHandler() sends multiple wheel events in a row, so we do have some test coverage, and hopefully this issue explains why it needed to be blacklisted. Fixes: QTBUG-88428 Task-number: QTBUG-86729 Change-Id: Id1ed4a38dfa3eb2253c4a60f09f80aea0f69707e Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Mostly un-blacklist Flickable and MultiPointTouchArea testsShawn Rutledge2020-11-112-25/+2
| | | | | | | | At least they pass again locally. Ubuntu is being problematic still. Task-number: QTBUG-86729 Change-Id: I3085b4070475f52f6e1f37b8455429a5bad08177 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* blacklist tst_QQuickListView::sectionsSnap in CI on macOSShawn Rutledge2020-11-111-0/+2
| | | | | | Task-number: QTBUG-86729 Change-Id: I38048b9b76de5356d50cf0313a06c3fbb3b35d89 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Teach flickable to handle and replay touch as it does mouseShawn Rutledge2020-11-115-52/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | QQuickWindowPrivate::cloneMouseEvent() renamed to clonePointerEvent() and generalized to be able to clone any of the kinds of QPointerEvent that we're interested in replaying. Now it is used only in QQuickFlickablePrivate::captureDelayedPress(). Reverts f278bb7c66bb00c9f81b7a3aceeb94cb9b3a1b66 and 012a4528a515af8d7ec7dbc05a38d8fd0d6d4d1b (don't skip tst_TouchMouse::buttonOnDelayedPressFlickable). Some test changes from f128b5dee8a2a03ebc55ed0cd1e749a6599282c3 also get reverted. QEventPoint should always have valid velocity now, so Flickable no longer has to calculate it for itself. Removing that became necessary to fix the movingAndFlicking test. Adds logging categories qt.quick.flickable.filter and .replay. Fixes: QTBUG-85607 Task-number: QTBUG-83437 Task-number: QTBUG-78818 Task-number: QTBUG-61144 Task-number: QTBUG-88038 Task-number: QTBUG-88138 Change-Id: I0ed6802dff5e5d1595adddc389642925f1f2c93d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* DesignerSupport: Add more tests for QQuickDesignerSupportThomas Hartmann2020-11-113-1/+185
| | | | | | | This patch adds a few more test cases. Change-Id: Ia2c4e016db57ef9cc6fccc1d4cfba6154068a5ff Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Integrate sequences with registration macrosUlf Hermann2020-11-113-8/+85
| | | | | | | | | | | | | | | | | | | | | | | | | | You get to write QML_SEQUENTIAL_CONTAINER(value_type) now, and qmltyperegistrar will generate a sensible registration call from that. A registration might look like this: struct MyStringListForeign { Q_GADGET QML_ANONYMOUS QML_SEQUENTIAL_CONTAINER(QString) QML_FOREIGN(MyStringList) QML_ADDED_IN_VERSION(3, 1) }; It's unfortunate that we need to use a metaobject to transfer all of this information, but there is no other sensible way. Transform the containers defined in qv4sequenceobject.cpp to use the new style, and move them out of the builtins, into QtQml. Recognize that only one of them was ever tested, and add tests for the rest. Task-number: QTBUG-82443 Change-Id: I3a30f9e27266bb575eea26c5daf5dad1ec461cc5 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* tst_qquickloader: Test setting source from component worksMaximilian Goldstein2020-11-114-0/+26
| | | | | | | Not verifying this works before has caused regressions. Change-Id: I4b99928bb6993d511349aec782660d24a134f67d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Remove debug usage of QT_FORCE_ASSERTSAlexandru Croitor2020-11-101-2/+0
| | | | | | | Amends a4d956048b4679bf5b448340d1f3428793699990 Change-Id: I9a44b6e800114968cb5e783282d439697b0a65a9 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmltyperegistrar: Add past-major-version optionMaximilian Goldstein2020-11-105-0/+19
| | | | | | | | Adds the option to specify past major versions of modules to be registered. This is necessary for modules that don't export any types themselves to work when built statically. Change-Id: I4b4a379f92707ec64cbb32f91db9d010440b95a2 Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
* Optimize particles vertex dataKaj Grönholm2020-11-092-7/+7
| | | | | | | | | | | | | | | | | | Use uchar instead of float for vertex data that doesn't need float. Continue using floats in shaders. Also remove animY2, which is same as animY1. These changes reduce memory usage especially when the amount of particles increases. Testing on windows, memory reductions with emitters/trailemitter example were: - OpenGL: 82.7 MB -> 76.5 MB - Vulkan: 130.8 MB -> 126.3 MB - D3D11: 143.7 MB -> 135.8 MB Task-number: QTBUG-88124 Change-Id: I8f8dcb3845323b0e69fb99b5bff830cd0f151a47 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
* QML: Rewrite Qt object in actual C++Ulf Hermann2020-11-095-156/+201
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Quite obviously, the Qt object is a singleton, extended with a namespace, backed by a member of the JavaScript global object. Defining all the methods as JavaScript functions is unnecessary and duplicates the general type transformation code. Also, it makes it hard to use those same methods from a C++ context as we cannot properly set up the arguments outside the JS engine. Rewriting the Qt object reveals some deficiencies in the old implementation that we need to fix now: 1. The enums of the Qt type were listed as properties of the Qt object, which means you could iterate them with a for..in loop in in JavaScript. This is just wrong. Enums are not properties. This functionality is deleted and the test adapted to check for each enum value separately. The commit message for the change that introduced the iterability already mentioned that the author had failed to find any occurrence of this in the real world. 2. Parsing time objects from strings was done by parsing the string as a date/time and then picking the time from that. We still support that for now, but output a (categorized) warning. Parsing the time directly is preferred where possible. 3. Previously you could create (invalid) dates and times from various kinds of QML types, like int and color. This does not work anymore as we now validate the types before calling the functions. 4. Passing more arguments to a function than the function accepted was unconditionally ignored before. Now, a Q_CLASSINFO on the surrounding class can specify that the arguments should be checked, in which case a JavaScript error is thrown if too many arguments are passed. In order for this to work correctly we also have to ignore JS undefined values as trailing arguments for overload resolution. This way, if a method matching the defined arguments exists, it will be preferred over a method that matches the full argument count, but possibly cannot accept undefined as parameter. Consequently a number of error messages change, which is reflected in the qqmlqt test. [ChangeLog][QtQMl][Important Behavior Changes] You can not iterate the enumerations of the Qt object in JavaScript anymore. This does not work with any other enumeration type either. You can of course still access them by name, for example as Qt.LeftButton or similar. [ChangeLog][QtQMl][Important Behavior Changes] The time formatting functions of the Qt object in QML now allow you to pass an actual time string, rather than a date/time string as argument. Passing a date/time string results in a warning now. [ChangeLog][QtQml][Important Behavior Changes] Functions in the Qt object for formatting date and time will now throw a JavaScript error when presented with a value of an incompatible type, such as int or color. [ChangeLog][QtQml][Important Behavior Changes] The Qt.resolvedUrl() function now returns a URL rather than a string. This follows the documentation. [ChangeLog][QtQml][Important Behavior Changes] The GlobalColor enum of the Qt namespace is not exposed to QML anymore. It did not make any sense before as the enum values could not be used as colors. Change-Id: I7fc2f24377eb2fde8f63a1ffac5548d652de7b12 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlListProperty: Use qsizetype rather than int for sizesUlf Hermann2020-11-094-9/+9
| | | | | | | | | | [ChangeLog][QtQml] The QQmlListProperty callback functions use qsizetype now as type for the size of a list. This is in line with the containers that you might use to back the list. Fixes: QTBUG-88269 Change-Id: Ia38403cb32f241e6c70e1a580dbeff1d6d694331 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qtdeclarative: finish fixing compilation with explicit QChar(int)David Faure2020-11-072-3/+3
| | | | | Change-Id: Idb26e2df6d4fe8940db57066a30fa8c243f6d2c9 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix misuses of the implicit QChar(int) constructorDavid Faure2020-11-072-4/+5
| | | | | | | | None of these cases intended to end up calling it, which proves that making it explicit (as will soon be the case) is a good idea. Change-Id: Ie60e85b554df956fd19bf86517945feac9f44b32 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* V4: Prevent heap objects from getting immediately swept by GCUlf Hermann2020-11-063-1/+97
| | | | | | | | | | | A destruction handler can cause a new object to be allocated during garbage collection. Depending on where in the heap the object ends up, it may be found during the sweep pass. As the mark pass had no chance to mark the object, we need to set the mark bit right at allocation time in this case. Change-Id: Ie43eeb548e78bd375b001b3a6bb4ef6596f91980 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Stabilize tst_QQuickDropArea::containsDrag_internalShawn Rutledge2020-11-061-5/+2
| | | | | | | | | | It seems timing-sensitive; as usual when we have processEvents() and then QCOMPARE, it's often better to just use QTRY_COMPARE in case it runs slower than expected on CI VMs. Fixes: QTBUG-88206 Change-Id: Ie6916a00e16e025c32940e6bffcabd1159480c5a Reviewed-by: Liang Qi <liang.qi@qt.io>
* Fix tst_QQuickText::fontSizeModeEskil Abrahamsen Blomfeldt2020-11-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | The test hardcodes the height of the Text element to be 35, and then it does a pre-check that this is higher than the height of the font. This is obviously a bit flaky and caused an error because the font at the given size was 35.7 and was rounded up. I did attempt to make the logic a bit more dynamic, and have the object's initial height be based on the height of the font, but other parts of the test would then fail because they depend on the size of the object. In the end, the simplest way seemed to be to just decrease the font size until it fit inside the original Text height and leave it at that. Fixes: QTBUG-88207 Change-Id: I9c327806bde8c339b299302004dfb72b34e87bcd Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Liang Qi <liang.qi@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* libinfix build: adjust qmldir entriesFabian Kosmale2020-11-062-1/+18
| | | | | | | Fixes: QTBUG-88209 Change-Id: Iae298355ce0b85945ea6c5c39805794f5f997845 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* QML engine: fix conversion scores for sequences in CallOverloadedFabian Kosmale2020-11-043-0/+45
| | | | | | | | | | | | A QV4Sequence can be converted back to its underlying container; we therefore should give the conversion of QV4Sequence to container a high score if metaTypeForSequence and the target metatype agree. This has a larger effect in Qt 6 than in Qt 5, as we now can have new sequence types for any (QMeta)Container. Fixes: QTBUG-87616 Change-Id: I2bf02ebadbf9b707719d09edaf14b112eb2caf4f Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Update MetaType things in testsDavid Skoland2020-11-045-17/+14
| | | | | | | Also fix some minute errors. Change-Id: I1815224a6efdd7e619dfe5a5911d8b1166a3b3c8 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Speed up tst_QQuickListView; round coordinate displayShawn Rutledge2020-11-032-3/+15
| | | | | Change-Id: I149258c69bac867a5d031b8d460e0192762fb8a5 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* tst_qqmlbinding: Do not leak componentFabian Kosmale2020-11-031-1/+2
| | | | | | | Change-Id: If562268b29fae9b0e0254719ce8d4489cfab2943 Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Get rid of all instance usage of QFontDatabaseVolker Hilsheimer2020-11-022-3/+2
| | | | | | | | All QFontDatabase APIs are static, use them accordingly. Task-number: QTBUG-88114 Change-Id: Iaa6be07e47adcdb5115e475cc5228f403e9a2b27 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* tst_qqmlbinding: Avoid event loop flakyness on Ubuntu 20.04Fabian Kosmale2020-11-021-2/+1
| | | | | | | | | | | | In a glib event loop, processEvents only processes events of the highest priority. Apparently, some higher priority event can occur which prevents the delayed binding from evaluating in time. Avoid the whole issue with QTRY_VERIFY, which runs the event loop multiple times if necessary. Task-number: QTBUG-86187 Change-Id: I796a2db1d017d389f198a24eb73d15da91ef0a65 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Fix compiler warnings from testsVolker Hilsheimer2020-11-022-7/+7
| | | | | | | | Replace foreach with ranged for; don't name unused function parameters. Change-Id: If0d9138261567edb14b72791799c6da1b16b5a5b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: David Skoland <david.skoland@qt.io>