diff options
author | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2020-07-17 15:40:17 +0200 |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2020-07-17 15:40:17 +0200 |
commit | 50244fc5d6f0730a447f1ac1ce19827890bc1456 (patch) | |
tree | fd937513dc616c270a1b8da23f982c2b9a7b6ac2 /tests/auto | |
parent | bf727efa7aa9a4738ae86a2c699832129813c670 (diff) | |
parent | 49ffc6e6af83b295c67fd119b79c925879cc292e (diff) |
Merge branch 'dev' into nativestyle
Change-Id: I5375ecd1dcbc058806e34fce757df2bf30dac16e
Diffstat (limited to 'tests/auto')
22 files changed, 501 insertions, 192 deletions
diff --git a/tests/auto/accessibility/tst_accessibility.cpp b/tests/auto/accessibility/tst_accessibility.cpp index 220facb3..3d9a318d 100644 --- a/tests/auto/accessibility/tst_accessibility.cpp +++ b/tests/auto/accessibility/tst_accessibility.cpp @@ -177,8 +177,8 @@ void tst_accessibility::a11y() QCOMPARE(attached->role(), role); QCOMPARE(attached->name(), text); #else - Q_UNUSED(role) - Q_UNUSED(text) + Q_UNUSED(role); + Q_UNUSED(text); #endif } @@ -264,8 +264,8 @@ void tst_accessibility::override() QCOMPARE(attached->role(), role); QCOMPARE(attached->name(), name + "Override"); #else - Q_UNUSED(role) - Q_UNUSED(text) + Q_UNUSED(role); + Q_UNUSED(text); #endif } diff --git a/tests/auto/controls/data/tst_combobox.qml b/tests/auto/controls/data/tst_combobox.qml index 64a525bf..7369f263 100644 --- a/tests/auto/controls/data/tst_combobox.qml +++ b/tests/auto/controls/data/tst_combobox.qml @@ -48,10 +48,10 @@ ** ****************************************************************************/ -import QtQuick 2.14 -import QtQuick.Window 2.2 -import QtTest 1.0 -import QtQuick.Controls 2.12 +import QtQuick 2.15 +import QtQuick.Window 2.15 +import QtTest 1.15 +import QtQuick.Controls 2.15 TestCase { id: testCase @@ -1970,4 +1970,182 @@ TestCase { compare(comboBox1.currentIndex, 9) compare(currentIndexSpy.count, 1) } + + Component { + id: appFontTextFieldComponent + TextField { + objectName: "appFontTextField" + font: Qt.application.font + // We don't want the background's implicit width to interfere with our tests, + // which are about implicit width of the contentItem of ComboBox, which is by default TextField. + background: null + } + } + + Component { + id: appFontContentItemComboBoxComponent + ComboBox { + // Override the contentItem so that the font doesn't vary between styles. + contentItem: TextField { + objectName: "appFontContentItemTextField" + // We do this just to be extra sure that the font never comes from the control, + // as we want it to match that of the TextField in the appFontTextFieldComponent. + font: Qt.application.font + background: null + } + } + } + + Component { + id: twoItemListModelComponent + + ListModel { + ListElement { display: "Short" } + ListElement { display: "Kinda long" } + } + } + + function appendedToModel(model, item) { + if (Array.isArray(model)) { + let newModel = model + newModel.push(item) + return newModel + } + + if (model.hasOwnProperty("append")) { + model.append({ display: item }) + // To account for the fact that changes to a JS array are not seen by the QML engine, + // we need to reassign the entire model and hence return it. For simplicity in the + // calling code, we do it for the ListModel code path too. It should be a no-op. + return model + } + + console.warn("appendedToModel: unrecognised model") + return undefined + } + + function removedFromModel(model, index, count) { + if (Array.isArray(model)) { + let newModel = model + newModel.splice(index, count) + return newModel + } + + if (model.hasOwnProperty("remove")) { + model.remove(index, count) + return model + } + + console.warn("removedFromModel: unrecognised model") + return undefined + } + + // We don't use a data-driven test for the policy because the checks vary a lot based on which enum we're testing. + function test_implicitContentWidthPolicy_ContentItemImplicitWidth() { + // Set ContentItemImplicitWidth and ensure that implicitContentWidth is as wide as the current item + // by comparing it against the implicitWidth of an identical TextField + let control = createTemporaryObject(appFontContentItemComboBoxComponent, testCase, { + model: ["Short", "Kinda long"], + implicitContentWidthPolicy: ComboBox.ContentItemImplicitWidth + }) + verify(control) + compare(control.implicitContentWidthPolicy, ComboBox.ContentItemImplicitWidth) + + let textField = createTemporaryObject(appFontTextFieldComponent, testCase) + verify(textField) + // Don't set any text on textField because we're not accounting for the widest + // text here, so we want to compare it against an empty TextField. + compare(control.implicitContentWidth, textField.implicitWidth) + + textField.font.pixelSize *= 2 + control.font.pixelSize *= 2 + compare(control.implicitContentWidth, textField.implicitWidth) + } + + function test_implicitContentWidthPolicy_WidestText_data() { + return [ + { tag: "Array", model: ["Short", "Kinda long"] }, + { tag: "ListModel", model: twoItemListModelComponent.createObject(testCase) }, + ] + } + + function test_implicitContentWidthPolicy_WidestText(data) { + let control = createTemporaryObject(appFontContentItemComboBoxComponent, testCase, { + model: data.model, + implicitContentWidthPolicy: ComboBox.WidestText + }) + verify(control) + compare(control.implicitContentWidthPolicy, ComboBox.WidestText) + + let textField = createTemporaryObject(appFontTextFieldComponent, testCase) + verify(textField) + textField.text = "Kinda long" + // Note that we don't need to change the current index here, as the implicitContentWidth + // is set to the implicitWidth of the TextField within the ComboBox as if it had the largest + // text from the model set on it. + // We use Math.ceil because TextInput uses qCeil internally, whereas the implicitWidth + // binding for TextField does not. + compare(Math.ceil(control.implicitContentWidth), Math.ceil(textField.implicitWidth)) + + // Add a longer item; it should affect the implicit content width. + let modifiedModel = appendedToModel(data.model, "Moderately long") + control.model = modifiedModel + textField.text = "Moderately long" + compare(Math.ceil(control.implicitContentWidth), Math.ceil(textField.implicitWidth)) + + // Remove the last two items; it should use the only remaining item's width. + modifiedModel = removedFromModel(data.model, 1, 2) + control.model = modifiedModel + compare(control.count, 1) + compare(control.currentText, "Short") + textField.text = "Short" + compare(Math.ceil(control.implicitContentWidth), Math.ceil(textField.implicitWidth)) + + // Changes in font should result in the implicitContentWidth being updated. + textField.font.pixelSize *= 2 + // We have to change the contentItem's font size manually since we break the + // style's binding to the control's font when we set Qt.application.font to it. + control.contentItem.font.pixelSize *= 2 + control.font.pixelSize *= 2 + compare(Math.ceil(control.implicitContentWidth), Math.ceil(textField.implicitWidth)) + } + + function test_implicitContentWidthPolicy_WidestTextWhenCompleted_data() { + return test_implicitContentWidthPolicy_WidestText_data() + } + + function test_implicitContentWidthPolicy_WidestTextWhenCompleted(data) { + let control = createTemporaryObject(appFontContentItemComboBoxComponent, testCase, { + model: data.model, + implicitContentWidthPolicy: ComboBox.WidestTextWhenCompleted + }) + verify(control) + compare(control.implicitContentWidthPolicy, ComboBox.WidestTextWhenCompleted) + + let textField = createTemporaryObject(appFontTextFieldComponent, testCase) + verify(textField) + textField.text = "Kinda long" + compare(Math.ceil(control.implicitContentWidth), Math.ceil(textField.implicitWidth)) + + // Add a longer item; it should not affect the implicit content width + // since we've already accounted for it once. + let modifiedModel = appendedToModel(data.model, "Moderately long") + control.model = modifiedModel + compare(Math.ceil(control.implicitContentWidth), Math.ceil(textField.implicitWidth)) + + // Remove the last two items; it should still not affect the implicit content width. + modifiedModel = removedFromModel(data.model, 1, 2) + control.model = modifiedModel + compare(control.count, 1) + compare(control.currentText, "Short") + compare(Math.ceil(control.implicitContentWidth), Math.ceil(textField.implicitWidth)) + + // Changes in font should not result in the implicitContentWidth being updated. + let oldTextFieldImplicitWidth = textField.implicitWidth + // Changes in font should result in the implicitContentWidth being updated. + textField.font.pixelSize *= 2 + control.contentItem.font.pixelSize *= 2 + control.font.pixelSize *= 2 + compare(Math.ceil(control.implicitContentWidth), Math.ceil(oldTextFieldImplicitWidth)) + } } diff --git a/tests/auto/controls/data/tst_popup.qml b/tests/auto/controls/data/tst_popup.qml index 71d6f2d7..0c6ab78a 100644 --- a/tests/auto/controls/data/tst_popup.qml +++ b/tests/auto/controls/data/tst_popup.qml @@ -1062,8 +1062,8 @@ TestCase { function findOverlay(window, popup) { var item = popup.contentItem.parent - var idx = indexOf(window.overlay.children, item) - return window.overlay.children[idx - 1] + var idx = indexOf(window.Overlay.overlay.children, item) + return window.Overlay.overlay.children[idx - 1] } function test_overlay() { @@ -1073,42 +1073,41 @@ TestCase { window.requestActivate() tryCompare(window, "active", true) - compare(window.overlay.children.length, 0) - compare(window.overlay, window.Overlay.overlay) + compare(window.Overlay.overlay.children.length, 0) var firstOverlay = findOverlay(window, window.firstDrawer) verify(!firstOverlay) window.firstDrawer.open() - compare(window.overlay.children.length, 2) // 1 drawer + 1 overlay + compare(window.Overlay.overlay.children.length, 2) // 1 drawer + 1 overlay firstOverlay = findOverlay(window, window.firstDrawer) verify(firstOverlay) compare(firstOverlay.z, window.firstDrawer.z) - compare(indexOf(window.overlay.children, firstOverlay), - indexOf(window.overlay.children, window.firstDrawer.contentItem.parent) - 1) + compare(indexOf(window.Overlay.overlay.children, firstOverlay), + indexOf(window.Overlay.overlay.children, window.firstDrawer.contentItem.parent) - 1) tryCompare(firstOverlay, "opacity", 1.0) var secondOverlay = findOverlay(window, window.secondDrawer) verify(!secondOverlay) window.secondDrawer.open() - compare(window.overlay.children.length, 4) // 2 drawers + 2 overlays + compare(window.Overlay.overlay.children.length, 4) // 2 drawers + 2 overlays secondOverlay = findOverlay(window, window.secondDrawer) verify(secondOverlay) compare(secondOverlay.z, window.secondDrawer.z) - compare(indexOf(window.overlay.children, secondOverlay), - indexOf(window.overlay.children, window.secondDrawer.contentItem.parent) - 1) + compare(indexOf(window.Overlay.overlay.children, secondOverlay), + indexOf(window.Overlay.overlay.children, window.secondDrawer.contentItem.parent) - 1) tryCompare(secondOverlay, "opacity", 1.0) window.firstDrawer.close() tryCompare(window.firstDrawer, "visible", false) firstOverlay = findOverlay(window, window.firstDrawer) verify(!firstOverlay) - compare(window.overlay.children.length, 2) // 1 drawer + 1 overlay + compare(window.Overlay.overlay.children.length, 2) // 1 drawer + 1 overlay window.secondDrawer.close() tryCompare(window.secondDrawer, "visible", false) secondOverlay = findOverlay(window, window.secondDrawer) verify(!secondOverlay) - compare(window.overlay.children.length, 0) + compare(window.Overlay.overlay.children.length, 0) var modalOverlay = findOverlay(window, window.modalPopup) verify(!modalOverlay) @@ -1118,7 +1117,7 @@ TestCase { compare(modalOverlay.z, window.modalPopup.z) compare(window.modalPopup.visible, true) tryCompare(modalOverlay, "opacity", 1.0) - compare(window.overlay.children.length, 2) // 1 popup + 1 overlay + compare(window.Overlay.overlay.children.length, 2) // 1 popup + 1 overlay var modelessOverlay = findOverlay(window, window.modelessPopup) verify(!modelessOverlay) @@ -1128,13 +1127,13 @@ TestCase { compare(modelessOverlay.z, window.modelessPopup.z) compare(window.modelessPopup.visible, true) tryCompare(modelessOverlay, "opacity", 1.0) - compare(window.overlay.children.length, 4) // 2 popups + 2 overlays + compare(window.Overlay.overlay.children.length, 4) // 2 popups + 2 overlays window.modelessPopup.close() tryCompare(window.modelessPopup, "visible", false) modelessOverlay = findOverlay(window, window.modelessPopup) verify(!modelessOverlay) - compare(window.overlay.children.length, 2) // 1 popup + 1 overlay + compare(window.Overlay.overlay.children.length, 2) // 1 popup + 1 overlay compare(window.modalPopup.visible, true) compare(modalOverlay.opacity, 1.0) @@ -1143,29 +1142,29 @@ TestCase { tryCompare(window.modalPopup, "visible", false) modalOverlay = findOverlay(window, window.modalPopup) verify(!modalOverlay) - compare(window.overlay.children.length, 0) + compare(window.Overlay.overlay.children.length, 0) window.plainPopup.open() tryCompare(window.plainPopup, "visible", true) - compare(window.overlay.children.length, 1) // only popup added, no overlays involved + compare(window.Overlay.overlay.children.length, 1) // only popup added, no overlays involved window.plainPopup.modal = true - compare(window.overlay.children.length, 2) // overlay added + compare(window.Overlay.overlay.children.length, 2) // overlay added window.plainPopup.close() tryCompare(window.plainPopup, "visible", false) - compare(window.overlay.children.length, 0) // popup + overlay removed + compare(window.Overlay.overlay.children.length, 0) // popup + overlay removed window.modalPopupWithoutDim.open() tryCompare(window.modalPopupWithoutDim, "visible", true) - compare(window.overlay.children.length, 1) // only popup added, no overlays involved + compare(window.Overlay.overlay.children.length, 1) // only popup added, no overlays involved window.modalPopupWithoutDim.dim = true - compare(window.overlay.children.length, 2) // overlay added + compare(window.Overlay.overlay.children.length, 2) // overlay added window.modalPopupWithoutDim.close() tryCompare(window.modalPopupWithoutDim, "visible", false) - compare(window.overlay.children.length, 0) // popup + overlay removed + compare(window.Overlay.overlay.children.length, 0) // popup + overlay removed } function test_attached_applicationwindow() { diff --git a/tests/auto/cursor/tst_cursor.cpp b/tests/auto/cursor/tst_cursor.cpp index 2491a972..ed5db5b1 100644 --- a/tests/auto/cursor/tst_cursor.cpp +++ b/tests/auto/cursor/tst_cursor.cpp @@ -182,6 +182,7 @@ void tst_cursor::scrollBar() // Ensure that the mouse cursor has the correct shape when over a scrollbar // which is itself over a text area with IBeamCursor. QQuickApplicationHelper helper(this, QStringLiteral("scrollbar.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickApplicationWindow *window = helper.appWindow; window->show(); QVERIFY(QTest::qWaitForWindowActive(window)); diff --git a/tests/auto/designer/tst_designer.cpp b/tests/auto/designer/tst_designer.cpp index 2c67c2c6..0d8bc73b 100644 --- a/tests/auto/designer/tst_designer.cpp +++ b/tests/auto/designer/tst_designer.cpp @@ -101,7 +101,7 @@ void tst_Designer::test_controls() "Item {\n"); QByteArray source = before; - source.append(type); + source.append(type.toUtf8()); const QByteArray after(" {" "}\n" diff --git a/tests/auto/focus/tst_focus.cpp b/tests/auto/focus/tst_focus.cpp index 8a1b36ad..b1b23244 100644 --- a/tests/auto/focus/tst_focus.cpp +++ b/tests/auto/focus/tst_focus.cpp @@ -43,8 +43,8 @@ #include <QtQuick/private/qquickitem_p.h> #include <QtQuickTemplates2/private/qquickcontrol_p.h> #include <QtGui/private/qguiapplication_p.h> +#include <QtGui/qpointingdevice.h> #include <QtGui/qstylehints.h> -#include <QtGui/qtouchdevice.h> #include "../shared/util.h" #include "../shared/visualtestutil.h" @@ -159,18 +159,7 @@ void tst_focus::policy() window->requestActivate(); QVERIFY(QTest::qWaitForWindowActive(window.data())); - struct TouchDeviceDeleter - { - static inline void cleanup(QTouchDevice *device) - { - QWindowSystemInterface::unregisterTouchDevice(device); - delete device; - } - }; - - QScopedPointer<QTouchDevice, TouchDeviceDeleter> device(new QTouchDevice); - device->setType(QTouchDevice::TouchScreen); - QWindowSystemInterface::registerTouchDevice(device.data()); + QScopedPointer<QPointingDevice> device(QTest::createTouchDevice()); control->setFocusPolicy(Qt::NoFocus); QCOMPARE(control->focusPolicy(), Qt::NoFocus); @@ -366,18 +355,7 @@ void tst_focus::scope() window->requestActivate(); QVERIFY(QTest::qWaitForWindowActive(window.data())); - struct TouchDeviceDeleter - { - static inline void cleanup(QTouchDevice *device) - { - QWindowSystemInterface::unregisterTouchDevice(device); - delete device; - } - }; - - QScopedPointer<QTouchDevice, TouchDeviceDeleter> device(new QTouchDevice); - device->setType(QTouchDevice::TouchScreen); - QWindowSystemInterface::registerTouchDevice(device.data()); + QScopedPointer<QPointingDevice> device(QTest::createTouchDevice()); child->forceActiveFocus(); QVERIFY(child->hasActiveFocus()); diff --git a/tests/auto/platform/data/tst_menuitem.qml b/tests/auto/platform/data/tst_menuitem.qml index 29d369bc..316af97d 100644 --- a/tests/auto/platform/data/tst_menuitem.qml +++ b/tests/auto/platform/data/tst_menuitem.qml @@ -68,8 +68,9 @@ TestCase { } } - SignalSpy { - id: spy + Component { + id: signalSpyComponent + SignalSpy {} } function test_properties_data() { @@ -81,30 +82,32 @@ TestCase { {tag: "checked", signal: "checkedChanged", init: false, value: true}, {tag: "role", signal: "roleChanged", init: MenuItem.TextHeuristicRole, value: MenuItem.AboutRole}, {tag: "text", signal: "textChanged", init: "", value: "text"}, - {tag: "iconSource", signal: "iconSourceChanged", init: "", value: "qrc:/undo.png"}, - {tag: "iconName", signal: "iconNameChanged", init: "", value: "edit-undo"}, + {tag: "icon.source", signal: "iconChanged", init: "", value: "qrc:/undo.png"}, + {tag: "icon.name", signal: "iconChanged", init: "", value: "edit-undo"}, {tag: "shortcut", signal: "shortcutChanged", init: undefined, value: StandardKey.Undo} ] } function test_properties(data) { - var item = menuItem.createObject(testCase) + let item = createTemporaryObject(menuItem, testCase) verify(item) - spy.target = item - spy.signalName = data.signal + let groupedProperty = data.tag.indexOf(".") !== -1 + let spy = createTemporaryObject(signalSpyComponent, testCase, { + target: item, signalName: data.signal + }) + verify(spy) verify(spy.valid) - compare(item[data.tag], data.init) - item[data.tag] = data.value + let propertyName = groupedProperty ? data.tag.split('.')[1] : data.tag + let object = !groupedProperty ? item : item.icon + compare(object[propertyName], data.init) + object[propertyName] = data.value compare(spy.count, 1) - compare(item[data.tag], data.value) + compare(object[propertyName], data.value) - item[data.tag] = data.value + object[propertyName] = data.value compare(spy.count, 1) - - spy.clear() - item.destroy() } function test_role() { diff --git a/tests/auto/platform/data/tst_systemtrayicon.qml b/tests/auto/platform/data/tst_systemtrayicon.qml index ce7d8b8d..d7a63551 100644 --- a/tests/auto/platform/data/tst_systemtrayicon.qml +++ b/tests/auto/platform/data/tst_systemtrayicon.qml @@ -61,44 +61,48 @@ TestCase { name: "SystemTrayIcon" Component { - id: systemTrayIcon + id: systemTrayIconComponent // Check that icon.name can be used in this Qt.labs.platform version SystemTrayIcon { icon.name: "" } } - SignalSpy { - id: spy + Component { + id: signalSpyComponent + SignalSpy {} } function test_properties_data() { return [ {tag: "visible", signal: "visibleChanged", init: false, value: true}, - {tag: "iconSource", signal: "iconSourceChanged", init: "", value: "qrc:/tray.png"}, - {tag: "iconName", signal: "iconNameChanged", init: "", value: "icon-name"}, + {tag: "icon.source", signal: "iconChanged", init: "", value: "qrc:/tray.png"}, + {tag: "icon.name", signal: "iconChanged", init: "", value: "icon-name"}, {tag: "tooltip", signal: "tooltipChanged", init: "", value: "tooltip"}, ] } function test_properties(data) { - var icon = systemTrayIcon.createObject(testCase) + let icon = createTemporaryObject(systemTrayIconComponent, testCase) verify(icon) - spy.target = icon - spy.signalName = data.signal + let groupedProperty = data.tag.indexOf(".") !== -1 + let spy = createTemporaryObject(signalSpyComponent, testCase, { + target: icon, signalName: data.signal + }) + verify(spy) verify(spy.valid) - compare(icon[data.tag], data.init) - icon[data.tag] = data.value - compare(spy.count, 1) - compare(icon[data.tag], data.value) + let propertyName = groupedProperty ? data.tag.split('.')[1] : data.tag + let object = !groupedProperty ? icon : icon.icon + compare(object[propertyName], data.init) - icon[data.tag] = data.value + object[propertyName] = data.value compare(spy.count, 1) + compare(object[propertyName], data.value) - spy.clear() - icon.destroy() + object[propertyName] = data.value + compare(spy.count, 1) } function test_messageIcon() { @@ -119,17 +123,17 @@ TestCase { } function test_activated() { - var icon = systemTrayIcon.createObject(testCase) + let icon = createTemporaryObject(systemTrayIconComponent, testCase) verify(icon) - spy.target = icon - spy.signalName = "activated" + let spy = createTemporaryObject(signalSpyComponent, testCase, { + target: icon, signalName: "activated" + }) + verify(spy) + verify(spy.valid) icon.activated(SystemTrayIcon.Trigger) compare(spy.count, 1) compare(spy.signalArguments[0][0], SystemTrayIcon.Trigger) - - spy.clear() - icon.destroy() } } diff --git a/tests/auto/qquickapplicationwindow/data/attachedProperties.qml b/tests/auto/qquickapplicationwindow/data/attachedProperties.qml index 53a139c1..fdb349ce 100644 --- a/tests/auto/qquickapplicationwindow/data/attachedProperties.qml +++ b/tests/auto/qquickapplicationwindow/data/attachedProperties.qml @@ -65,7 +65,6 @@ ApplicationWindow { property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl property Item attached_header: ApplicationWindow.header property Item attached_footer: ApplicationWindow.footer - property Item attached_overlay: ApplicationWindow.overlay } Item { @@ -76,7 +75,6 @@ ApplicationWindow { property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl property Item attached_header: ApplicationWindow.header property Item attached_footer: ApplicationWindow.footer - property Item attached_overlay: ApplicationWindow.overlay } QtObject { @@ -87,7 +85,6 @@ ApplicationWindow { property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl property Item attached_header: ApplicationWindow.header property Item attached_footer: ApplicationWindow.footer - property Item attached_overlay: ApplicationWindow.overlay } property alias childWindow: childWindow @@ -103,7 +100,6 @@ ApplicationWindow { property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl property Item attached_header: ApplicationWindow.header property Item attached_footer: ApplicationWindow.footer - property Item attached_overlay: ApplicationWindow.overlay Control { id: childWindowControl @@ -113,7 +109,6 @@ ApplicationWindow { property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl property Item attached_header: ApplicationWindow.header property Item attached_footer: ApplicationWindow.footer - property Item attached_overlay: ApplicationWindow.overlay } Item { @@ -124,7 +119,6 @@ ApplicationWindow { property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl property Item attached_header: ApplicationWindow.header property Item attached_footer: ApplicationWindow.footer - property Item attached_overlay: ApplicationWindow.overlay } QtObject { @@ -135,7 +129,6 @@ ApplicationWindow { property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl property Item attached_header: ApplicationWindow.header property Item attached_footer: ApplicationWindow.footer - property Item attached_overlay: ApplicationWindow.overlay } } @@ -152,7 +145,6 @@ ApplicationWindow { property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl property Item attached_header: ApplicationWindow.header property Item attached_footer: ApplicationWindow.footer - property Item attached_overlay: ApplicationWindow.overlay Control { id: childAppWindowControl @@ -162,7 +154,6 @@ ApplicationWindow { property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl property Item attached_header: ApplicationWindow.header property Item attached_footer: ApplicationWindow.footer - property Item attached_overlay: ApplicationWindow.overlay } Item { @@ -173,7 +164,6 @@ ApplicationWindow { property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl property Item attached_header: ApplicationWindow.header property Item attached_footer: ApplicationWindow.footer - property Item attached_overlay: ApplicationWindow.overlay } QtObject { @@ -184,7 +174,6 @@ ApplicationWindow { property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl property Item attached_header: ApplicationWindow.header property Item attached_footer: ApplicationWindow.footer - property Item attached_overlay: ApplicationWindow.overlay } } } diff --git a/tests/auto/qquickapplicationwindow/tst_qquickapplicationwindow.cpp b/tests/auto/qquickapplicationwindow/tst_qquickapplicationwindow.cpp index b907f5c3..baaa3503 100644 --- a/tests/auto/qquickapplicationwindow/tst_qquickapplicationwindow.cpp +++ b/tests/auto/qquickapplicationwindow/tst_qquickapplicationwindow.cpp @@ -287,7 +287,6 @@ void tst_QQuickApplicationWindow::attachedProperties() QCOMPARE(childControl->property("attached_activeFocusControl").value<QQuickItem *>(), window->activeFocusControl()); QCOMPARE(childControl->property("attached_header").value<QQuickItem *>(), window->header()); QCOMPARE(childControl->property("attached_footer").value<QQuickItem *>(), window->footer()); - QCOMPARE(childControl->property("attached_overlay").value<QQuickItem *>(), window->overlay()); QQuickItem *childItem = object->property("childItem").value<QQuickItem *>(); QVERIFY(childItem); @@ -296,7 +295,6 @@ void tst_QQuickApplicationWindow::attachedProperties() QCOMPARE(childItem->property("attached_activeFocusControl").value<QQuickItem *>(), window->activeFocusControl()); QCOMPARE(childItem->property("attached_header").value<QQuickItem *>(), window->header()); QCOMPARE(childItem->property("attached_footer").value<QQuickItem *>(), window->footer()); - QCOMPARE(childItem->property("attached_overlay").value<QQuickItem *>(), window->overlay()); QObject *childObject = object->property("childObject").value<QObject *>(); QVERIFY(childObject); @@ -305,7 +303,6 @@ void tst_QQuickApplicationWindow::attachedProperties() QVERIFY(!childObject->property("attached_activeFocusControl").value<QQuickItem *>()); QVERIFY(!childObject->property("attached_header").value<QQuickItem *>()); QVERIFY(!childObject->property("attached_footer").value<QQuickItem *>()); - QVERIFY(!childObject->property("attached_overlay").value<QQuickItem *>()); QQuickWindow *childWindow = object->property("childWindow").value<QQuickWindow *>(); QVERIFY(childWindow); @@ -314,7 +311,6 @@ void tst_QQuickApplicationWindow::attachedProperties() QVERIFY(!childWindow->property("attached_activeFocusControl").value<QQuickItem *>()); QVERIFY(!childWindow->property("attached_header").value<QQuickItem *>()); QVERIFY(!childWindow->property("attached_footer").value<QQuickItem *>()); - QVERIFY(!childWindow->property("attached_overlay").value<QQuickItem *>()); QQuickItem *childWindowControl = object->property("childWindowControl").value<QQuickItem *>(); QVERIFY(childWindowControl); @@ -323,7 +319,6 @@ void tst_QQuickApplicationWindow::attachedProperties() QVERIFY(!childWindowControl->property("attached_activeFocusControl").value<QQuickItem *>()); QVERIFY(!childWindowControl->property("attached_header").value<QQuickItem *>()); QVERIFY(!childWindowControl->property("attached_footer").value<QQuickItem *>()); - QCOMPARE(childWindowControl->property("attached_overlay").value<QQuickItem *>(), QQuickOverlay::overlay(childWindow)); QQuickItem *childWindowItem = object->property("childWindowItem").value<QQuickItem *>(); QVERIFY(childWindowItem); @@ -332,7 +327,6 @@ void tst_QQuickApplicationWindow::attachedProperties() QVERIFY(!childWindowItem->property("attached_activeFocusControl").value<QQuickItem *>()); QVERIFY(!childWindowItem->property("attached_header").value<QQuickItem *>()); QVERIFY(!childWindowItem->property("attached_footer").value<QQuickItem *>()); - QCOMPARE(childWindowItem->property("attached_overlay").value<QQuickItem *>(), QQuickOverlay::overlay(childWindow)); QObject *childWindowObject = object->property("childWindowObject").value<QObject *>(); QVERIFY(childWindowObject); @@ -341,7 +335,6 @@ void tst_QQuickApplicationWindow::attachedProperties() QVERIFY(!childWindowObject->property("attached_activeFocusControl").value<QQuickItem *>()); QVERIFY(!childWindowObject->property("attached_header").value<QQuickItem *>()); QVERIFY(!childWindowObject->property("attached_footer").value<QQuickItem *>()); - QVERIFY(!childWindowObject->property("attached_overlay").value<QQuickItem *>()); QQuickApplicationWindow *childAppWindow = object->property("childAppWindow").value<QQuickApplicationWindow *>(); QVERIFY(childAppWindow); @@ -350,7 +343,6 @@ void tst_QQuickApplicationWindow::attachedProperties() QVERIFY(!childAppWindow->property("attached_activeFocusControl").value<QQuickItem *>()); QVERIFY(!childAppWindow->property("attached_header").value<QQuickItem *>()); QVERIFY(!childAppWindow->property("attached_footer").value<QQuickItem *>()); - QVERIFY(!childAppWindow->property("attached_overlay").value<QQuickItem *>()); QQuickItem *childAppWindowControl = object->property("childAppWindowControl").value<QQuickItem *>(); QVERIFY(childAppWindowControl); @@ -359,7 +351,6 @@ void tst_QQuickApplicationWindow::attachedProperties() QCOMPARE(childAppWindowControl->property("attached_activeFocusControl").value<QQuickItem *>(), childAppWindow->activeFocusControl()); QCOMPARE(childAppWindowControl->property("attached_header").value<QQuickItem *>(), childAppWindow->header()); QCOMPARE(childAppWindowControl->property("attached_footer").value<QQuickItem *>(), childAppWindow->footer()); - QCOMPARE(childAppWindowControl->property("attached_overlay").value<QQuickItem *>(), childAppWindow->overlay()); QQuickItem *childAppWindowItem = object->property("childAppWindowItem").value<QQuickItem *>(); QVERIFY(childAppWindowItem); @@ -368,7 +359,6 @@ void tst_QQuickApplicationWindow::attachedProperties() QCOMPARE(childAppWindowItem->property("attached_activeFocusControl").value<QQuickItem *>(), childAppWindow->activeFocusControl()); QCOMPARE(childAppWindowItem->property("attached_header").value<QQuickItem *>(), childAppWindow->header()); QCOMPARE(childAppWindowItem->property("attached_footer").value<QQuickItem *>(), childAppWindow->footer()); - QCOMPARE(childAppWindowItem->property("attached_overlay").value<QQuickItem *>(), childAppWindow->overlay()); QObject *childAppWindowObject = object->property("childAppWindowObject").value<QObject *>(); QVERIFY(childAppWindowObject); @@ -377,7 +367,6 @@ void tst_QQuickApplicationWindow::attachedProperties() QVERIFY(!childAppWindowObject->property("attached_activeFocusControl").value<QQuickItem *>()); QVERIFY(!childAppWindowObject->property("attached_header").value<QQuickItem *>()); QVERIFY(!childAppWindowObject->property("attached_footer").value<QQuickItem *>()); - QVERIFY(!childAppWindowObject->property("attached_overlay").value<QQuickItem *>()); window->show(); window->requestActivate(); @@ -416,7 +405,6 @@ void tst_QQuickApplicationWindow::attachedProperties() QCOMPARE(childControl->property("attached_activeFocusControl").value<QQuickItem *>(), childAppWindowControl); QCOMPARE(childControl->property("attached_header").value<QQuickItem *>(), childAppWindow->header()); QCOMPARE(childControl->property("attached_footer").value<QQuickItem *>(), childAppWindow->footer()); - QCOMPARE(childControl->property("attached_overlay").value<QQuickItem *>(), childAppWindow->overlay()); childItem->setParentItem(childAppWindow->contentItem()); QCOMPARE(childItem->window(), childAppWindow); @@ -425,7 +413,6 @@ void tst_QQuickApplicationWindow::attachedProperties() QCOMPARE(childItem->property("attached_activeFocusControl").value<QQuickItem *>(), childAppWindowControl); QCOMPARE(childItem->property("attached_header").value<QQuickItem *>(), childAppWindow->header()); QCOMPARE(childItem->property("attached_footer").value<QQuickItem *>(), childAppWindow->footer()); - QCOMPARE(childItem->property("attached_overlay").value<QQuickItem *>(), childAppWindow->overlay()); childControl->setParentItem(nullptr); QVERIFY(!childControl->window()); @@ -434,7 +421,6 @@ void tst_QQuickApplicationWindow::attachedProperties() QVERIFY(!childControl->property("attached_activeFocusControl").value<QQuickItem *>()); QVERIFY(!childControl->property("attached_header").value<QQuickItem *>()); QVERIFY(!childControl->property("attached_footer").value<QQuickItem *>()); - QVERIFY(!childControl->property("attached_overlay").value<QQuickItem *>()); childItem->setParentItem(nullptr); QVERIFY(!childItem->window()); @@ -443,7 +429,6 @@ void tst_QQuickApplicationWindow::attachedProperties() QVERIFY(!childItem->property("attached_activeFocusControl").value<QQuickItem *>()); QVERIFY(!childItem->property("attached_header").value<QQuickItem *>()); QVERIFY(!childItem->property("attached_footer").value<QQuickItem *>()); - QVERIFY(!childItem->property("attached_overlay").value<QQuickItem *>()); childAppWindow->close(); qApp->processEvents(); @@ -464,7 +449,6 @@ void tst_QQuickApplicationWindow::attachedProperties() QVERIFY(!childControl->property("attached_contentItem").value<QQuickItem *>()); QVERIFY(!childControl->property("attached_header").value<QQuickItem *>()); QVERIFY(!childControl->property("attached_footer").value<QQuickItem *>()); - QCOMPARE(childControl->property("attached_overlay").value<QQuickItem *>(), QQuickOverlay::overlay(childWindow)); childItem->setParentItem(childWindow->contentItem()); QCOMPARE(childItem->window(), childWindow); @@ -473,7 +457,6 @@ void tst_QQuickApplicationWindow::attachedProperties() QVERIFY(!childControl->property("attached_contentItem").value<QQuickItem *>()); QVERIFY(!childControl->property("attached_header").value<QQuickItem *>()); QVERIFY(!childControl->property("attached_footer").value<QQuickItem *>()); - QCOMPARE(childControl->property("attached_overlay").value<QQuickItem *>(), QQuickOverlay::overlay(childWindow)); childControl->setParentItem(nullptr); QVERIFY(!childControl->window()); @@ -482,7 +465,6 @@ void tst_QQuickApplicationWindow::attachedProperties() QVERIFY(!childControl->property("attached_activeFocusControl").value<QQuickItem *>()); QVERIFY(!childControl->property("attached_header").value<QQuickItem *>()); QVERIFY(!childControl->property("attached_footer").value<QQuickItem *>()); - QVERIFY(!childControl->property("attached_overlay").value<QQuickItem *>()); childItem->setParentItem(nullptr); QVERIFY(!childItem->window()); @@ -491,7 +473,6 @@ void tst_QQuickApplicationWindow::attachedProperties() QVERIFY(!childItem->property("attached_activeFocusControl").value<QQuickItem *>()); QVERIFY(!childItem->property("attached_header").value<QQuickItem *>()); QVERIFY(!childItem->property("attached_footer").value<QQuickItem *>()); - QVERIFY(!childItem->property("attached_overlay").value<QQuickItem *>()); childWindow->close(); } diff --git a/tests/auto/qquickcontrol/tst_qquickcontrol.cpp b/tests/auto/qquickcontrol/tst_qquickcontrol.cpp index c8d34756..6acb192f 100644 --- a/tests/auto/qquickcontrol/tst_qquickcontrol.cpp +++ b/tests/auto/qquickcontrol/tst_qquickcontrol.cpp @@ -53,16 +53,7 @@ private slots: void flickable(); private: - struct TouchDeviceDeleter - { - static inline void cleanup(QTouchDevice *device) - { - QWindowSystemInterface::unregisterTouchDevice(device); - delete device; - } - }; - - QScopedPointer<QTouchDevice, TouchDeviceDeleter> touchDevice; + QScopedPointer<QPointingDevice> touchDevice; }; @@ -71,9 +62,7 @@ void tst_QQuickControl::initTestCase() QQmlDataTest::initTestCase(); qputenv("QML_NO_TOUCH_COMPRESSION", "1"); - touchDevice.reset(new QTouchDevice); - touchDevice->setType(QTouchDevice::TouchScreen); - QWindowSystemInterface::registerTouchDevice(touchDevice.data()); + touchDevice.reset(QTest::createTouchDevice()); } void tst_QQuickControl::flickable() diff --git a/tests/auto/qquickdrawer/tst_qquickdrawer.cpp b/tests/auto/qquickdrawer/tst_qquickdrawer.cpp index 7644cacf..c96b156c 100644 --- a/tests/auto/qquickdrawer/tst_qquickdrawer.cpp +++ b/tests/auto/qquickdrawer/tst_qquickdrawer.cpp @@ -40,8 +40,8 @@ #include "../shared/visualtestutil.h" #include "../shared/qtest_quickcontrols.h" +#include <QtGui/qpointingdevice.h> #include <QtGui/qstylehints.h> -#include <QtGui/qtouchdevice.h> #include <QtGui/qguiapplication.h> #include <QtGui/qpa/qwindowsysteminterface.h> #include <QtQuick/private/qquickwindow_p.h> @@ -112,16 +112,7 @@ private slots: void topEdgeScreenEdge(); private: - struct TouchDeviceDeleter - { - static inline void cleanup(QTouchDevice *device) - { - QWindowSystemInterface::unregisterTouchDevice(device); - delete device; - } - }; - - QScopedPointer<QTouchDevice, TouchDeviceDeleter> touchDevice; + QScopedPointer<QPointingDevice> touchDevice; }; @@ -130,9 +121,7 @@ void tst_QQuickDrawer::initTestCase() QQmlDataTest::initTestCase(); qputenv("QML_NO_TOUCH_COMPRESSION", "1"); - touchDevice.reset(new QTouchDevice); - touchDevice->setType(QTouchDevice::TouchScreen); - QWindowSystemInterface::registerTouchDevice(touchDevice.data()); + touchDevice.reset(QTest::createTouchDevice()); } void tst_QQuickDrawer::defaults() @@ -180,6 +169,7 @@ void tst_QQuickDrawer::visible() { QFETCH(QString, source); QQuickApplicationHelper helper(this, source); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); @@ -220,6 +210,7 @@ void tst_QQuickDrawer::visible() void tst_QQuickDrawer::state() { QQuickApplicationHelper helper(this, "applicationwindow.qml"); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); @@ -340,6 +331,7 @@ void tst_QQuickDrawer::position() QFETCH(qreal, position); QQuickApplicationHelper helper(this, QStringLiteral("applicationwindow.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickApplicationWindow *window = helper.appWindow; window->show(); @@ -387,6 +379,7 @@ void tst_QQuickDrawer::dragMargin() QFETCH(qreal, dragFromRight); QQuickApplicationHelper helper(this, QStringLiteral("applicationwindow.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickApplicationWindow *window = helper.appWindow; window->show(); @@ -433,6 +426,7 @@ static QRectF geometry(const QQuickItem *item) void tst_QQuickDrawer::reposition() { QQuickApplicationHelper helper(this, QStringLiteral("reposition.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickApplicationWindow *window = helper.appWindow; window->show(); @@ -491,6 +485,7 @@ void tst_QQuickDrawer::reposition() void tst_QQuickDrawer::header() { QQuickApplicationHelper helper(this, QStringLiteral("header.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickApplicationWindow *window = helper.appWindow; window->show(); @@ -545,6 +540,7 @@ void tst_QQuickDrawer::hover() QFETCH(bool, modal); QQuickApplicationHelper helper(this, source); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); window->requestActivate(); @@ -628,6 +624,7 @@ void tst_QQuickDrawer::wheel() QFETCH(bool, modal); QQuickApplicationHelper helper(this, source); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); QVERIFY(QTest::qWaitForWindowExposed(window)); @@ -690,6 +687,7 @@ void tst_QQuickDrawer::wheel() void tst_QQuickDrawer::multiple() { QQuickApplicationHelper helper(this, QStringLiteral("multiple.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); QVERIFY(QTest::qWaitForWindowExposed(window)); @@ -834,6 +832,7 @@ void tst_QQuickDrawer::touch() QFETCH(QPoint, to); QQuickApplicationHelper helper(this, source); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); @@ -868,6 +867,7 @@ void tst_QQuickDrawer::touch() void tst_QQuickDrawer::multiTouch() { QQuickApplicationHelper helper(this, QStringLiteral("multiTouch.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); QVERIFY(QTest::qWaitForWindowActive(window)); @@ -981,6 +981,7 @@ void tst_QQuickDrawer::multiTouch() void tst_QQuickDrawer::grabber() { QQuickApplicationHelper helper(this, QStringLiteral("grabber.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); QVERIFY(QTest::qWaitForWindowExposed(window)); @@ -1025,6 +1026,7 @@ void tst_QQuickDrawer::interactive() { QFETCH(QString, source); QQuickApplicationHelper helper(this, source); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); @@ -1087,6 +1089,7 @@ void tst_QQuickDrawer::flickable() QFETCH(QPoint, to); QQuickApplicationHelper helper(this, QStringLiteral("flickable.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); QVERIFY(QTest::qWaitForWindowExposed(window)); @@ -1143,6 +1146,7 @@ void tst_QQuickDrawer::dragOverModalShadow() QFETCH(bool, mouse); QQuickApplicationHelper helper(this, QStringLiteral("dragOverModalShadow.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); QVERIFY(QTest::qWaitForWindowActive(window)); @@ -1199,6 +1203,7 @@ void tst_QQuickDrawer::nonModal() QFETCH(bool, mouse); QQuickApplicationHelper helper(this, QStringLiteral("window.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); QVERIFY(QTest::qWaitForWindowActive(window)); @@ -1282,6 +1287,7 @@ void tst_QQuickDrawer::slider() QFETCH(int, delta); QQuickApplicationHelper helper(this, QStringLiteral("slider.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); QVERIFY(QTest::qWaitForWindowActive(window)); @@ -1325,6 +1331,7 @@ void tst_QQuickDrawer::slider() void tst_QQuickDrawer::topEdgeScreenEdge() { QQuickApplicationHelper helper(this, QStringLiteral("topEdgeScreenEdge.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); QVERIFY(QTest::qWaitForWindowActive(window)); diff --git a/tests/auto/qquickheaderview/tst_qquickheaderview.cpp b/tests/auto/qquickheaderview/tst_qquickheaderview.cpp index 611e39cb..d8d71183 100644 --- a/tests/auto/qquickheaderview/tst_qquickheaderview.cpp +++ b/tests/auto/qquickheaderview/tst_qquickheaderview.cpp @@ -203,7 +203,7 @@ public: } private: - QVector<QVariant> hData, vData; + QList<QVariant> hData, vData; }; class tst_QQuickHeaderView : public QQmlDataTest { diff --git a/tests/auto/qquickiconlabel/tst_qquickiconlabel.cpp b/tests/auto/qquickiconlabel/tst_qquickiconlabel.cpp index 0ecc95c5..7a1cb259 100644 --- a/tests/auto/qquickiconlabel/tst_qquickiconlabel.cpp +++ b/tests/auto/qquickiconlabel/tst_qquickiconlabel.cpp @@ -26,7 +26,7 @@ ** ****************************************************************************/ -#include <QtCore/qvector.h> +#include <QtCore/qlist.h> #include <qtest.h> @@ -64,13 +64,13 @@ tst_qquickiconlabel::tst_qquickiconlabel() void tst_qquickiconlabel::display_data() { - QTest::addColumn<QVector<QQuickIconLabel::Display> >("displayTypes"); + QTest::addColumn<QList<QQuickIconLabel::Display> >("displayTypes"); QTest::addColumn<bool>("mirrored"); QTest::addColumn<qreal>("labelWidth"); QTest::addColumn<qreal>("labelHeight"); QTest::addColumn<qreal>("spacing"); - typedef QVector<QQuickIconLabel::Display> DisplayVector; + typedef QList<QQuickIconLabel::Display> DisplayVector; QQuickIconLabel::Display IconOnly = QQuickIconLabel::IconOnly; QQuickIconLabel::Display TextOnly = QQuickIconLabel::TextOnly; QQuickIconLabel::Display TextUnderIcon = QQuickIconLabel::TextUnderIcon; @@ -108,7 +108,7 @@ void tst_qquickiconlabel::display_data() void tst_qquickiconlabel::display() { - QFETCH(QVector<QQuickIconLabel::Display>, displayTypes); + QFETCH(QList<QQuickIconLabel::Display>, displayTypes); QFETCH(bool, mirrored); QFETCH(qreal, labelWidth); QFETCH(qreal, labelHeight); diff --git a/tests/auto/qquickmaterialstyleconf/tst_qquickmaterialstyleconf.cpp b/tests/auto/qquickmaterialstyleconf/tst_qquickmaterialstyleconf.cpp index 72136445..7612b99b 100644 --- a/tests/auto/qquickmaterialstyleconf/tst_qquickmaterialstyleconf.cpp +++ b/tests/auto/qquickmaterialstyleconf/tst_qquickmaterialstyleconf.cpp @@ -57,6 +57,7 @@ private slots: void tst_qquickmaterialstyleconf::conf() { QQuickApplicationHelper helper(this, QLatin1String("applicationwindow.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QFont customFont; customFont.setFamily("Courier"); @@ -101,6 +102,7 @@ void tst_qquickmaterialstyleconf::variants() qputenv("QT_QUICK_CONTROLS_CONF", confPath); QQuickApplicationHelper helper(this, QLatin1String("applicationwindow.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickApplicationWindow *window = helper.appWindow; window->show(); diff --git a/tests/auto/qquickmenu/data/applicationwindow.qml b/tests/auto/qquickmenu/data/applicationwindow.qml index 986853e4..13f14d2d 100644 --- a/tests/auto/qquickmenu/data/applicationwindow.qml +++ b/tests/auto/qquickmenu/data/applicationwindow.qml @@ -59,6 +59,7 @@ ApplicationWindow { property alias emptyMenu: emptyMenu property alias menu: menu property alias menuButton: menuButton + property Overlay overlay: menu.Overlay.overlay Menu { id: emptyMenu diff --git a/tests/auto/qquickmenu/tst_qquickmenu.cpp b/tests/auto/qquickmenu/tst_qquickmenu.cpp index 54a5d9f4..a06b715f 100644 --- a/tests/auto/qquickmenu/tst_qquickmenu.cpp +++ b/tests/auto/qquickmenu/tst_qquickmenu.cpp @@ -106,6 +106,7 @@ private slots: void tst_QQuickMenu::defaults() { QQuickApplicationHelper helper(this, QLatin1String("applicationwindow.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickMenu *emptyMenu = helper.appWindow->property("emptyMenu").value<QQuickMenu*>(); QCOMPARE(emptyMenu->isVisible(), false); @@ -117,6 +118,7 @@ void tst_QQuickMenu::defaults() void tst_QQuickMenu::count() { QQuickApplicationHelper helper(this, QLatin1String("applicationwindow.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickMenu *menu = helper.window->property("emptyMenu").value<QQuickMenu*>(); QVERIFY(menu); @@ -149,6 +151,7 @@ void tst_QQuickMenu::mouse() QSKIP("Mouse hovering not functional on offscreen/minimal platforms"); QQuickApplicationHelper helper(this, QLatin1String("applicationwindow.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickApplicationWindow *window = helper.appWindow; centerOnScreen(window); @@ -157,9 +160,12 @@ void tst_QQuickMenu::mouse() QVERIFY(QTest::qWaitForWindowActive(window)); QQuickMenu *menu = window->property("menu").value<QQuickMenu*>(); + QVERIFY(menu); menu->open(); QVERIFY(menu->isVisible()); - QVERIFY(window->overlay()->childItems().contains(menu->contentItem()->parentItem())); + QQuickOverlay *overlay = window->property("overlay").value<QQuickOverlay*>(); + QVERIFY(overlay); + QVERIFY(overlay->childItems().contains(menu->contentItem()->parentItem())); QTRY_VERIFY(menu->isOpened()); QQuickItem *firstItem = menu->itemAt(0); @@ -182,14 +188,14 @@ void tst_QQuickMenu::mouse() QCOMPARE(triggeredSpy.count(), 1); QTRY_COMPARE(visibleSpy.count(), 1); QVERIFY(!menu->isVisible()); - QVERIFY(!window->overlay()->childItems().contains(menu->contentItem())); + QVERIFY(!overlay->childItems().contains(menu->contentItem())); QCOMPARE(menu->currentIndex(), -1); QCOMPARE(menu->contentItem()->property("currentIndex"), QVariant(-1)); menu->open(); QCOMPARE(visibleSpy.count(), 2); QVERIFY(menu->isVisible()); - QVERIFY(window->overlay()->childItems().contains(menu->contentItem()->parentItem())); + QVERIFY(overlay->childItems().contains(menu->contentItem()->parentItem())); QTRY_VERIFY(menu->isOpened()); // Ensure that we have enough space to click outside of the menu. @@ -199,12 +205,12 @@ void tst_QQuickMenu::mouse() QPoint(menu->contentItem()->width() + 1, menu->contentItem()->height() + 1)); QTRY_COMPARE(visibleSpy.count(), 3); QVERIFY(!menu->isVisible()); - QVERIFY(!window->overlay()->childItems().contains(menu->contentItem()->parentItem())); + QVERIFY(!overlay->childItems().contains(menu->contentItem()->parentItem())); menu->open(); QCOMPARE(visibleSpy.count(), 4); QVERIFY(menu->isVisible()); - QVERIFY(window->overlay()->childItems().contains(menu->contentItem()->parentItem())); + QVERIFY(overlay->childItems().contains(menu->contentItem()->parentItem())); QTRY_VERIFY(menu->isOpened()); // Hover-highlight through the menu items one by one @@ -237,13 +243,14 @@ void tst_QQuickMenu::mouse() // QCOMPARE(triggeredSpy.count(), 1); // QCOMPARE(visibleSpy.count(), 5); // QVERIFY(!menu->isVisible()); -// QVERIFY(!window->overlay()->childItems().contains(menu->contentItem())); +// QVERIFY(!overlay->childItems().contains(menu->contentItem())); // QCOMPARE(menu->contentItem()->property("currentIndex"), QVariant(-1)); } void tst_QQuickMenu::pressAndHold() { QQuickApplicationHelper helper(this, QLatin1String("pressAndHold.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); @@ -268,6 +275,7 @@ void tst_QQuickMenu::contextMenuKeyboard() QSKIP("This platform only allows tab focus for text controls"); QQuickApplicationHelper helper(this, QLatin1String("applicationwindow.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickApplicationWindow *window = helper.appWindow; centerOnScreen(window); @@ -289,7 +297,9 @@ void tst_QQuickMenu::contextMenuKeyboard() menu->open(); QCOMPARE(visibleSpy.count(), 1); QVERIFY(menu->isVisible()); - QVERIFY(window->overlay()->childItems().contains(menu->contentItem()->parentItem())); + QQuickOverlay *overlay = window->property("overlay").value<QQuickOverlay*>(); + QVERIFY(overlay); + QVERIFY(overlay->childItems().contains(menu->contentItem()->parentItem())); QTRY_VERIFY(menu->isOpened()); QVERIFY(!firstItem->hasActiveFocus()); QVERIFY(!firstItem->property("highlighted").toBool()); @@ -322,7 +332,7 @@ void tst_QQuickMenu::contextMenuKeyboard() QCOMPARE(secondTriggeredSpy.count(), 1); QTRY_COMPARE(visibleSpy.count(), 2); QVERIFY(!menu->isVisible()); - QVERIFY(!window->overlay()->childItems().contains(menu->contentItem())); + QVERIFY(!overlay->childItems().contains(menu->contentItem())); QVERIFY(!firstItem->hasActiveFocus()); QVERIFY(!firstItem->hasVisualFocus()); QVERIFY(!firstItem->isHighlighted()); @@ -352,7 +362,7 @@ void tst_QQuickMenu::contextMenuKeyboard() QCOMPARE(firstTriggeredSpy.count(), 1); QTRY_COMPARE(visibleSpy.count(), 4); QVERIFY(!menu->isVisible()); - QVERIFY(!window->overlay()->childItems().contains(menu->contentItem())); + QVERIFY(!overlay->childItems().contains(menu->contentItem())); QVERIFY(!firstItem->hasActiveFocus()); QVERIFY(!firstItem->hasVisualFocus()); QVERIFY(!firstItem->isHighlighted()); @@ -365,7 +375,7 @@ void tst_QQuickMenu::contextMenuKeyboard() menu->open(); QCOMPARE(visibleSpy.count(), 5); QVERIFY(menu->isVisible()); - QVERIFY(window->overlay()->childItems().contains(menu->contentItem()->parentItem())); + QVERIFY(overlay->childItems().contains(menu->contentItem()->parentItem())); QTRY_VERIFY(menu->isOpened()); QVERIFY(!firstItem->hasActiveFocus()); QVERIFY(!firstItem->hasVisualFocus()); @@ -451,6 +461,7 @@ void tst_QQuickMenu::disabledMenuItemKeyNavigation() QSKIP("This platform only allows tab focus for text controls"); QQuickApplicationHelper helper(this, QLatin1String("disabledMenuItemKeyNavigation.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickApplicationWindow *window = helper.appWindow; centerOnScreen(window); @@ -515,6 +526,7 @@ void tst_QQuickMenu::mnemonics() #endif QQuickApplicationHelper helper(this, QLatin1String("mnemonics.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); @@ -562,6 +574,7 @@ void tst_QQuickMenu::menuButton() QSKIP("This platform only allows tab focus for text controls"); QQuickApplicationHelper helper(this, QLatin1String("applicationwindow.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickApplicationWindow *window = helper.appWindow; window->show(); @@ -588,6 +601,7 @@ void tst_QQuickMenu::menuButton() void tst_QQuickMenu::addItem() { QQuickApplicationHelper helper(this, QLatin1String("addItem.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickApplicationWindow *window = helper.appWindow; window->show(); QVERIFY(QTest::qWaitForWindowActive(window)); @@ -609,6 +623,7 @@ void tst_QQuickMenu::addItem() void tst_QQuickMenu::menuSeparator() { QQuickApplicationHelper helper(this, QLatin1String("menuSeparator.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; centerOnScreen(window); moveMouseAway(window); @@ -686,6 +701,7 @@ void tst_QQuickMenu::menuSeparator() void tst_QQuickMenu::repeater() { QQuickApplicationHelper helper(this, QLatin1String("repeater.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); QVERIFY(QTest::qWaitForWindowActive(window)); @@ -730,6 +746,7 @@ void tst_QQuickMenu::repeater() void tst_QQuickMenu::order() { QQuickApplicationHelper helper(this, QLatin1String("order.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); QVERIFY(QTest::qWaitForWindowActive(window)); @@ -751,6 +768,7 @@ void tst_QQuickMenu::order() void tst_QQuickMenu::popup() { QQuickApplicationHelper helper(this, QLatin1String("popup.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickApplicationWindow *window = helper.appWindow; centerOnScreen(window); moveMouseAway(window); @@ -907,6 +925,7 @@ void tst_QQuickMenu::popup() void tst_QQuickMenu::actions() { QQuickApplicationHelper helper(this, QLatin1String("actions.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); QVERIFY(QTest::qWaitForWindowActive(window)); @@ -975,6 +994,7 @@ void tst_QQuickMenu::actions() void tst_QQuickMenu::removeTakeItem() { QQuickApplicationHelper helper(this, QLatin1String("removeTakeItem.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); QVERIFY(QTest::qWaitForWindowActive(window)); @@ -1032,6 +1052,7 @@ void tst_QQuickMenu::subMenuMouse() QFETCH(bool, cascade); QQuickApplicationHelper helper(this, QLatin1String("subMenus.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickApplicationWindow *window = helper.appWindow; centerOnScreen(window); moveMouseAway(window); @@ -1138,6 +1159,7 @@ void tst_QQuickMenu::subMenuDisabledMouse() QFETCH(bool, cascade); QQuickApplicationHelper helper(this, QLatin1String("subMenuDisabled.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickApplicationWindow *window = helper.appWindow; centerOnScreen(window); moveMouseAway(window); @@ -1200,6 +1222,7 @@ void tst_QQuickMenu::subMenuKeyboard() QFETCH(bool, mirrored); QQuickApplicationHelper helper(this, QLatin1String("subMenus.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickApplicationWindow *window = helper.appWindow; centerOnScreen(window); moveMouseAway(window); @@ -1322,6 +1345,7 @@ void tst_QQuickMenu::subMenuDisabledKeyboard() QFETCH(bool, mirrored); QQuickApplicationHelper helper(this, QLatin1String("subMenuDisabled.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickApplicationWindow *window = helper.appWindow; centerOnScreen(window); moveMouseAway(window); @@ -1372,6 +1396,12 @@ void tst_QQuickMenu::subMenuDisabledKeyboard() QVERIFY(!subMenu->isVisible()); } +/* + QCOMPARE() compares doubles with 1-in-1e12 precision, which is too fine for these tests. + Casting to floats, compared with 1-in-1e5 precision, gives more robust results. +*/ +#define FLOAT_EQ(u, v) QCOMPARE(float(u), float(v)) + void tst_QQuickMenu::subMenuPosition_data() { QTest::addColumn<bool>("cascade"); @@ -1398,6 +1428,7 @@ void tst_QQuickMenu::subMenuPosition() QFETCH(qreal, overlap); QQuickApplicationHelper helper(this, QLatin1String("subMenus.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickApplicationWindow *window = helper.appWindow; // Ensure that the default size of the window fits three menus side by side. @@ -1471,19 +1502,20 @@ void tst_QQuickMenu::subMenuPosition() if (cascade) { QCOMPARE(subMenu1->parentItem(), subMenu1Item); // vertically aligned to the parent menu item - QCOMPARE(subMenu1->popupItem()->y(), mainMenu->popupItem()->y() + subMenu1Item->y()); + // We cast to float here because we want to use its larger tolerance for equality (because it has less precision than double). + FLOAT_EQ(subMenu1->popupItem()->y(), mainMenu->popupItem()->y() + subMenu1Item->y()); if (mirrored) { // on the left of the parent menu - QCOMPARE(subMenu1->popupItem()->x(), mainMenu->popupItem()->x() - subMenu1->width() + overlap); + FLOAT_EQ(subMenu1->popupItem()->x(), mainMenu->popupItem()->x() - subMenu1->width() + overlap); } else { // on the right of the parent menu - QCOMPARE(subMenu1->popupItem()->x(), mainMenu->popupItem()->x() + mainMenu->width() - overlap); + FLOAT_EQ(subMenu1->popupItem()->x(), mainMenu->popupItem()->x() + mainMenu->width() - overlap); } } else { QCOMPARE(subMenu1->parentItem(), mainMenu->parentItem()); // centered over the parent menu - QCOMPARE(subMenu1->popupItem()->x(), mainMenu->popupItem()->x() + (mainMenu->width() - subMenu1->width()) / 2); - QCOMPARE(subMenu1->popupItem()->y(), mainMenu->popupItem()->y() + (mainMenu->height() - subMenu1->height()) / 2); + FLOAT_EQ(subMenu1->popupItem()->x(), mainMenu->popupItem()->x() + (mainMenu->width() - subMenu1->width()) / 2); + FLOAT_EQ(subMenu1->popupItem()->y(), mainMenu->popupItem()->y() + (mainMenu->height() - subMenu1->height()) / 2); } // open the sub-sub-menu (can flip) @@ -1500,25 +1532,28 @@ void tst_QQuickMenu::subMenuPosition() if (cascade) { QCOMPARE(subSubMenu1->parentItem(), subSubMenu1Item); // vertically aligned to the parent menu item - QCOMPARE(subSubMenu1->popupItem()->y(), subMenu1->popupItem()->y() + subSubMenu1Item->y()); + FLOAT_EQ(subSubMenu1->popupItem()->y(), subMenu1->popupItem()->y() + subSubMenu1Item->y()); if (mirrored != flip) { // on the left of the parent menu - QCOMPARE(subSubMenu1->popupItem()->x(), subMenu1->popupItem()->x() - subSubMenu1->width() + overlap); + FLOAT_EQ(subSubMenu1->popupItem()->x(), subMenu1->popupItem()->x() - subSubMenu1->width() + overlap); } else { // on the right of the parent menu - QCOMPARE(subSubMenu1->popupItem()->x(), subMenu1->popupItem()->x() + subMenu1->width() - overlap); + FLOAT_EQ(subSubMenu1->popupItem()->x(), subMenu1->popupItem()->x() + subMenu1->width() - overlap); } } else { QCOMPARE(subSubMenu1->parentItem(), subMenu1->parentItem()); // centered over the parent menu - QCOMPARE(subSubMenu1->popupItem()->x(), subMenu1->popupItem()->x() + (subMenu1->width() - subSubMenu1->width()) / 2); - QCOMPARE(subSubMenu1->popupItem()->y(), subMenu1->popupItem()->y() + (subMenu1->height() - subSubMenu1->height()) / 2); + FLOAT_EQ(subSubMenu1->popupItem()->x(), subMenu1->popupItem()->x() + (subMenu1->width() - subSubMenu1->width()) / 2); + FLOAT_EQ(subSubMenu1->popupItem()->y(), subMenu1->popupItem()->y() + (subMenu1->height() - subSubMenu1->height()) / 2); } } +#undef FLOAT_EQ + void tst_QQuickMenu::addRemoveSubMenus() { QQuickApplicationHelper helper(this, QLatin1String("subMenus.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); QVERIFY(QTest::qWaitForWindowActive(window)); @@ -1590,6 +1625,7 @@ void tst_QQuickMenu::scrollable() QFETCH(QString, qmlFilePath); QQuickApplicationHelper helper(this, qmlFilePath); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); QVERIFY(QTest::qWaitForWindowActive(window)); @@ -1629,6 +1665,7 @@ void tst_QQuickMenu::disableWhenTriggered() QFETCH(int, subMenuItemIndex); QQuickApplicationHelper helper(this, QLatin1String("disableWhenTriggered.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); QVERIFY(QTest::qWaitForWindowActive(window)); @@ -1684,6 +1721,7 @@ void tst_QQuickMenu::menuItemWidth() QFETCH(bool, mirrored); QQuickApplicationHelper helper(this, QLatin1String("menuItemWidths.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickApplicationWindow *window = helper.appWindow; window->show(); QVERIFY(QTest::qWaitForWindowActive(window)); @@ -1712,6 +1750,7 @@ void tst_QQuickMenu::menuItemWidthAfterMenuWidthChanged() QFETCH(bool, mirrored); QQuickApplicationHelper helper(this, QLatin1String("menuItemWidths.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickApplicationWindow *window = helper.appWindow; window->show(); QVERIFY(QTest::qWaitForWindowActive(window)); @@ -1756,6 +1795,7 @@ void tst_QQuickMenu::menuItemWidthAfterImplicitWidthChanged() QFETCH(bool, mirrored); QQuickApplicationHelper helper(this, QLatin1String("menuItemWidths.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickApplicationWindow *window = helper.appWindow; window->show(); QVERIFY(QTest::qWaitForWindowActive(window)); @@ -1786,6 +1826,7 @@ void tst_QQuickMenu::menuItemWidthAfterImplicitWidthChanged() void tst_QQuickMenu::menuItemWidthAfterRetranslate() { QQuickApplicationHelper helper(this, QLatin1String("menuItemWidths.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickApplicationWindow *window = helper.appWindow; window->show(); QVERIFY(QTest::qWaitForWindowActive(window)); diff --git a/tests/auto/qquickpopup/data/centerInOverlayWithinStackViewItem.qml b/tests/auto/qquickpopup/data/centerInOverlayWithinStackViewItem.qml new file mode 100644 index 00000000..076e2230 --- /dev/null +++ b/tests/auto/qquickpopup/data/centerInOverlayWithinStackViewItem.qml @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.15 +import QtQuick.Controls 2.15 + +ApplicationWindow { + width: 400 + height: 400 + + property Popup popup: stackView.currentItem.popup + + StackView { + id: stackView + objectName: "stackView" + anchors.fill: parent + + initialItem: Rectangle { + objectName: "rectangle" + + property alias popup: popup + + Popup { + id: popup + objectName: "popup" + width: 100 + height: 100 + visible: true + anchors.centerIn: Overlay.overlay + } + } + } +} diff --git a/tests/auto/qquickpopup/tst_qquickpopup.cpp b/tests/auto/qquickpopup/tst_qquickpopup.cpp index 162a48ba..d8dac979 100644 --- a/tests/auto/qquickpopup/tst_qquickpopup.cpp +++ b/tests/auto/qquickpopup/tst_qquickpopup.cpp @@ -99,6 +99,7 @@ private slots: void setOverlayParentToNull(); void tabFence(); void invisibleToolTipOpen(); + void centerInOverlayWithinStackViewItem(); }; void tst_QQuickPopup::initTestCase() @@ -118,6 +119,7 @@ void tst_QQuickPopup::visible() { QFETCH(QString, source); QQuickApplicationHelper helper(this, source); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); @@ -151,6 +153,7 @@ void tst_QQuickPopup::visible() void tst_QQuickPopup::state() { QQuickApplicationHelper helper(this, "applicationwindow.qml"); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); @@ -212,6 +215,7 @@ void tst_QQuickPopup::overlay() QFETCH(bool, dim); QQuickApplicationHelper helper(this, source); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); @@ -300,18 +304,7 @@ void tst_QQuickPopup::overlay() QVERIFY(popup->isVisible()); QVERIFY(overlay->isVisible()); - struct TouchDeviceDeleter - { - static inline void cleanup(QTouchDevice *device) - { - QWindowSystemInterface::unregisterTouchDevice(device); - delete device; - } - }; - - QScopedPointer<QTouchDevice, TouchDeviceDeleter> device(new QTouchDevice); - device->setType(QTouchDevice::TouchScreen); - QWindowSystemInterface::registerTouchDevice(device.data()); + QScopedPointer<QPointingDevice> device(QTest::createTouchDevice()); QTest::touchEvent(window, device.data()).press(0, QPoint(1, 1)); QCOMPARE(overlayPressedSignal.count(), ++overlayPressCount); @@ -374,6 +367,7 @@ void tst_QQuickPopup::zOrder() { QFETCH(QString, source); QQuickApplicationHelper helper(this, source); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); @@ -483,6 +477,7 @@ void tst_QQuickPopup::closePolicy() QFETCH(QQuickPopup::ClosePolicy, closePolicy); QQuickApplicationHelper helper(this, source); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); @@ -567,6 +562,7 @@ void tst_QQuickPopup::activeFocusOnClose1() // Test that a popup that never sets focus: true (e.g. ToolTip) doesn't affect // the active focus item when it closes. QQuickApplicationHelper helper(this, QStringLiteral("activeFocusOnClose1.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickApplicationWindow *window = helper.appWindow; window->show(); window->requestActivate(); @@ -610,6 +606,7 @@ void tst_QQuickPopup::activeFocusOnClose2() // calling forceActiveFocus() on another item) before it closes doesn't // affect the active focus item when it closes. QQuickApplicationHelper helper(this, QStringLiteral("activeFocusOnClose2.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickApplicationWindow *window = helper.appWindow; window->show(); window->requestActivate(); @@ -646,6 +643,7 @@ void tst_QQuickPopup::activeFocusOnClose3() // Test that a closing popup that had focus doesn't steal focus from // another popup that the focus was transferred to. QQuickApplicationHelper helper(this, QStringLiteral("activeFocusOnClose3.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickApplicationWindow *window = helper.appWindow; window->show(); window->requestActivate(); @@ -677,6 +675,7 @@ void tst_QQuickPopup::activeFocusOnClosingSeveralPopups() { // Test that active focus isn't lost when multiple popup closing simultaneously QQuickApplicationHelper helper(this, QStringLiteral("activeFocusOnClosingSeveralPopups.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickApplicationWindow *window = helper.appWindow; window->show(); window->requestActivate(); @@ -738,6 +737,7 @@ void tst_QQuickPopup::hover() QFETCH(bool, modal); QQuickApplicationHelper helper(this, source); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); window->requestActivate(); @@ -812,6 +812,7 @@ void tst_QQuickPopup::wheel() QFETCH(bool, modal); QQuickApplicationHelper helper(this, source); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); QVERIFY(QTest::qWaitForWindowExposed(window)); @@ -882,6 +883,7 @@ void tst_QQuickPopup::parentDestroyed() void tst_QQuickPopup::nested() { QQuickApplicationHelper helper(this, QStringLiteral("nested.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); QVERIFY(QTest::qWaitForWindowExposed(window)); @@ -909,6 +911,7 @@ void tst_QQuickPopup::nested() void tst_QQuickPopup::grabber() { QQuickApplicationHelper helper(this, QStringLiteral("grabber.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); QVERIFY(QTest::qWaitForWindowExposed(window)); @@ -961,6 +964,7 @@ void tst_QQuickPopup::cursorShape() // Ensure that the mouse cursor has the correct shape when over a popup // which is itself over an item with a different shape. QQuickApplicationHelper helper(this, QStringLiteral("cursor.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickApplicationWindow *window = helper.appWindow; centerOnScreen(window); moveMouseAway(window); @@ -1018,6 +1022,7 @@ void tst_QQuickPopup::closeOnEscapeWithNestedPopups() // Tests the scenario in the Gallery example, where there are nested popups that should // close in the correct order when the Escape key is pressed. QQuickApplicationHelper helper(this, QStringLiteral("closeOnEscapeWithNestedPopups.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickApplicationWindow *window = helper.appWindow; window->show(); QVERIFY(QTest::qWaitForWindowExposed(window)); @@ -1081,6 +1086,7 @@ void tst_QQuickPopup::closeOnEscapeWithNestedPopups() void tst_QQuickPopup::closeOnEscapeWithVisiblePopup() { QQuickApplicationHelper helper(this, QStringLiteral("closeOnEscapeWithVisiblePopup.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); QVERIFY(QTest::qWaitForWindowActive(window)); @@ -1131,6 +1137,7 @@ void tst_QQuickPopup::orientation() QFETCH(QPointF, position); QQuickApplicationHelper helper(this, "orientation.qml"); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->reportContentOrientationChange(orientation); @@ -1170,6 +1177,7 @@ void tst_QQuickPopup::qquickview() void tst_QQuickPopup::disabledPalette() { QQuickApplicationHelper helper(this, "disabledPalette.qml"); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); @@ -1206,6 +1214,7 @@ void tst_QQuickPopup::disabledPalette() void tst_QQuickPopup::disabledParentPalette() { QQuickApplicationHelper helper(this, "disabledPalette.qml"); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); @@ -1251,6 +1260,7 @@ void tst_QQuickPopup::disabledParentPalette() void tst_QQuickPopup::countChanged() { QQuickApplicationHelper helper(this, "countChanged.qml"); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); @@ -1273,6 +1283,7 @@ void tst_QQuickPopup::toolTipCrashOnClose() QSKIP("Test requires QtGraphicalEffects"); QQuickApplicationHelper helper(this, "toolTipCrashOnClose.qml"); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); @@ -1293,6 +1304,7 @@ void tst_QQuickPopup::setOverlayParentToNull() QSKIP("Test requires QtGraphicalEffects"); QQuickApplicationHelper helper(this, "toolTipCrashOnClose.qml"); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); @@ -1313,6 +1325,7 @@ void tst_QQuickPopup::tabFence() QSKIP("This platform only allows tab focus for text controls"); QQuickApplicationHelper helper(this, "tabFence.qml"); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); @@ -1366,6 +1379,7 @@ void tst_QQuickPopup::tabFence() void tst_QQuickPopup::invisibleToolTipOpen() { QQuickApplicationHelper helper(this, "invisibleToolTipOpen.qml"); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; centerOnScreen(window); @@ -1390,6 +1404,22 @@ void tst_QQuickPopup::invisibleToolTipOpen() QTRY_VERIFY(mouseArea->property("isToolTipVisible").toBool()); } +void tst_QQuickPopup::centerInOverlayWithinStackViewItem() +{ + QQuickApplicationHelper helper(this, "centerInOverlayWithinStackViewItem.qml"); + QVERIFY2(helper.ready, helper.failureMessage()); + + QQuickWindow *window = helper.window; + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + + QQuickPopup *popup = window->property("popup").value<QQuickPopup*>(); + QVERIFY(popup); + QTRY_COMPARE(popup->isVisible(), true); + + // Shouldn't crash on exit. +} + QTEST_QUICKCONTROLS_MAIN(tst_QQuickPopup) #include "tst_qquickpopup.moc" diff --git a/tests/auto/qquickuniversalstyleconf/tst_qquickuniversalstyleconf.cpp b/tests/auto/qquickuniversalstyleconf/tst_qquickuniversalstyleconf.cpp index 51cc5883..08eae67c 100644 --- a/tests/auto/qquickuniversalstyleconf/tst_qquickuniversalstyleconf.cpp +++ b/tests/auto/qquickuniversalstyleconf/tst_qquickuniversalstyleconf.cpp @@ -54,6 +54,7 @@ private slots: void tst_qquickuniversalstyleconf::conf() { QQuickApplicationHelper helper(this, QLatin1String("applicationwindow.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QFont customFont; customFont.setFamily("Courier"); diff --git a/tests/auto/sanity/tst_sanity.cpp b/tests/auto/sanity/tst_sanity.cpp index b5d0054b..35c48970 100644 --- a/tests/auto/sanity/tst_sanity.cpp +++ b/tests/auto/sanity/tst_sanity.cpp @@ -211,9 +211,9 @@ void tst_Sanity::functions_data() class SignalHandlerValidator : public BaseValidator { protected: - static bool isSignalHandler(const QStringRef &name) + static bool isSignalHandler(QStringView name) { - return name.length() > 2 && name.startsWith("on") && name.at(2).isUpper(); + return name.length() > 2 && name.startsWith(QLatin1String("on")) && name.at(2).isUpper(); } virtual bool visit(QQmlJS::AST::UiScriptBinding *node) diff --git a/tests/auto/shared/visualtestutil.h b/tests/auto/shared/visualtestutil.h index d5e651c5..e3f4075d 100644 --- a/tests/auto/shared/visualtestutil.h +++ b/tests/auto/shared/visualtestutil.h @@ -122,19 +122,44 @@ namespace QQuickVisualTestUtil component.loadUrl(testCase->testFileUrl(testFilePath)); QObject *rootObject = component.create(); cleanup.reset(rootObject); - QVERIFY2(rootObject, qPrintable(QString::fromLatin1("Failed to create window: %1").arg(component.errorString()))); + if (!rootObject) { + errorMessage = QString::fromUtf8("Failed to create window: %1").arg(component.errorString()).toUtf8(); + return; + } window = qobject_cast<QQuickWindow*>(rootObject); appWindow = qobject_cast<QQuickApplicationWindow*>(rootObject); - QVERIFY(window); - QVERIFY(!window->isVisible()); + if (!window) { + errorMessage = QString::fromUtf8("Root object %1 must be a QQuickWindow subclass").arg(QDebug::toString(window)).toUtf8(); + return; + } + + if (window->isVisible()) { + errorMessage = QString::fromUtf8("Expected window not to be visible, but it is").toUtf8(); + return; + } + + ready = true; + } + + // Return a C-style string instead of QString because that's what QTest uses for error messages, + // so it saves code at the calling site. + inline const char *failureMessage() const + { + return errorMessage.constData(); } QQmlEngine engine; QQmlComponent component; QScopedPointer<QObject> cleanup; - QQuickApplicationWindow *appWindow; - QQuickWindow *window; + QQuickApplicationWindow *appWindow = nullptr; + QQuickWindow *window = nullptr; + + bool ready = false; + // Store as a byte array so that we can return its raw data safely; + // using qPrintable() in failureMessage() will construct a throwaway QByteArray + // that is destroyed before the function returns. + QByteArray errorMessage; }; void addTestRowForEachControl(QQmlEngine *engine, const QString &sourcePath, const QString &targetPath, const QStringList &skiplist = QStringList()); |