diff options
Diffstat (limited to 'tests/auto/quickcontrols2/controls')
7 files changed, 266 insertions, 3 deletions
diff --git a/tests/auto/quickcontrols2/controls/data/tst_dialog.qml b/tests/auto/quickcontrols2/controls/data/tst_dialog.qml index 6aa9d39af0..821c7999e0 100644 --- a/tests/auto/quickcontrols2/controls/data/tst_dialog.qml +++ b/tests/auto/quickcontrols2/controls/data/tst_dialog.qml @@ -125,6 +125,8 @@ TestCase { control.closePolicy = Popup.CloseOnPressOutside control.open() verify(control.visible) + // wait for enter transitions to finish + openedSpy.wait() mousePress(testCase, 1, 1) compare(rejectedSpy.count, 3) @@ -143,6 +145,7 @@ TestCase { control.closePolicy = Popup.CloseOnReleaseOutside control.open() verify(control.visible) + openedSpy.wait() mousePress(testCase, 1, 1) compare(rejectedSpy.count, 3) @@ -298,6 +301,7 @@ TestCase { compare(control.implicitHeight, control.contentItem.implicitHeight + control.topPadding + control.bottomPadding + control.header.implicitHeight + control.footer.implicitHeight) + control.footer.implicitWidth = 0 control.header.implicitWidth = 150 compare(control.implicitWidth, control.header.implicitWidth) diff --git a/tests/auto/quickcontrols2/controls/data/tst_popup.qml b/tests/auto/quickcontrols2/controls/data/tst_popup.qml index 58ab662f48..278ee62f06 100644 --- a/tests/auto/quickcontrols2/controls/data/tst_popup.qml +++ b/tests/auto/quickcontrols2/controls/data/tst_popup.qml @@ -6,6 +6,7 @@ import QtTest import QtQuick.Controls import QtQuick.Templates as T import QtQuick.NativeStyle as NativeStyle +import Qt.test.controls TestCase { id: testCase @@ -1405,6 +1406,16 @@ TestCase { property alias popup: popup property alias popupTitle: popupTitle + property alias popupContent: popupContent + property bool gotMouseEvent: false + + MouseArea { + id: windowMouseArea + enabled: true + anchors.fill: parent + onPressed: gotMouseEvent = true + } + Popup { id: popup @@ -1412,6 +1423,7 @@ TestCase { height: 200 background: Rectangle { + id: popupContent color: "#505050" Rectangle { id: popupTitle @@ -1456,6 +1468,11 @@ TestCase { let popup = window.popup popup.open() + + // mouse clicks into the popup must not propagate to the parent + mouseClick(window) + compare(window.gotMouseEvent, false) + let title = window.popupTitle verify(title) @@ -1469,5 +1486,26 @@ TestCase { fuzzyCompare(popup.y, oldPos.y + 5, 1) mouseRelease(title, pressPoint.x, pressPoint.y) compare(title.pressedPosition, Qt.point(0, 0)) + + } + + Component { + id: cppDimmerComponent + + Popup { + dim: true + Overlay.modeless: ComponentCreator.createComponent( + "import QtQuick; Rectangle { objectName: \"rect\"; color: \"tomato\" }") + } + } + + function test_dimmerComponentCreatedInCpp() { + let control = createTemporaryObject(cppDimmerComponent, testCase) + verify(control) + + control.open() + tryCompare(control, "opened", true) + let rect = findChild(control.Overlay.overlay, "rect") + verify(rect) } } diff --git a/tests/auto/quickcontrols2/controls/data/tst_scrollview.qml b/tests/auto/quickcontrols2/controls/data/tst_scrollview.qml index 73332e0b4d..1ab2475c45 100644 --- a/tests/auto/quickcontrols2/controls/data/tst_scrollview.qml +++ b/tests/auto/quickcontrols2/controls/data/tst_scrollview.qml @@ -578,4 +578,88 @@ TestCase { compare(mouseWheelSpy.count, 1) compare(mouseArea.flickable.contentY, 0) } + + Component { + id: bindingToContentItemAndStandaloneFlickable + + Item { + width: 200 + height: 200 + + property alias scrollView: scrollView + + ScrollView { + id: scrollView + anchors.fill: parent + contentItem: listView + + property Item someBinding: contentItem + } + ListView { + id: listView + model: 10 + delegate: ItemDelegate { + text: modelData + width: listView.width + } + } + } + } + + // Tests that scroll bars show up for a ScrollView where + // - its contentItem is declared as a standalone, separate item + // - there is a binding to contentItem (which causes a default Flickable to be created) + function test_bindingToContentItemAndStandaloneFlickable() { + let root = createTemporaryObject(bindingToContentItemAndStandaloneFlickable, testCase) + verify(root) + + let control = root.scrollView + let verticalScrollBar = control.ScrollBar.vertical + let horizontalScrollBar = control.ScrollBar.horizontal + compare(verticalScrollBar.parent, control) + compare(horizontalScrollBar.parent, control) + verify(verticalScrollBar.visible) + verify(horizontalScrollBar.visible) + + mouseDrag(verticalScrollBar, verticalScrollBar.width / 2, verticalScrollBar.height / 2, 0, 50) + verify(verticalScrollBar.active) + verify(horizontalScrollBar.active) + } + + Component { + id: contentItemAssignedImperatively + + Item { + width: 100 + height: 100 + + property alias scrollView: scrollView + + ListView { + id: listView + model: 20 + delegate: Text { + text: modelData + } + } + + Component.onCompleted: scrollView.contentItem = listView + + ScrollView { + id: scrollView + anchors.fill: parent + + ScrollBar.horizontal.policy: ScrollBar.AlwaysOff + } + } + } + + // Tests that a ListView declared before the ScrollView (as the QObject destruction order + // is relevant for the bug) and assigned imperatively to ScrollView does not cause a crash + // on exit. + function test_contentItemAssignedImperatively() { + let root = createTemporaryObject(contentItemAssignedImperatively, testCase) + verify(root) + // Shouldn't crash. + } } diff --git a/tests/auto/quickcontrols2/controls/data/tst_splitview.qml b/tests/auto/quickcontrols2/controls/data/tst_splitview.qml index add4d7b7ec..c7b5819c3d 100644 --- a/tests/auto/quickcontrols2/controls/data/tst_splitview.qml +++ b/tests/auto/quickcontrols2/controls/data/tst_splitview.qml @@ -6,6 +6,7 @@ import QtQuick.Controls import QtQuick.Window import QtTest import Qt.labs.settings +import Qt.test.controls TestCase { id: testCase @@ -2528,4 +2529,65 @@ TestCase { mouseMove(control, control.width - 100, control.height / 2) verify(!targetHandle.SplitHandle.hovered) } + + Component { + id: cppHandleSplitViewComponent + + SplitView { + anchors.fill: parent + handle: ComponentCreator.createComponent(` + import QtQuick + + Rectangle { + objectName: "handle" + implicitWidth: 10 + implicitHeight: 10 + color: "tomato" + }`) + + Rectangle { + objectName: "navajowhite" + color: objectName + implicitWidth: 100 + implicitHeight: 100 + } + Rectangle { + objectName: "steelblue" + color: objectName + implicitWidth: 200 + implicitHeight: 200 + } + } + } + + function test_handleComponentCreatedInCpp() { + let control = createTemporaryObject(cppHandleSplitViewComponent, testCase) + verify(control) + + let handles = findHandles(control) + compare(handles.length, 1) + compare(handles[0].color, Qt.color("tomato")) + } + + function test_touch() { + let control = createTemporaryObject(threeSizedItemsComponent, testCase) + verify(control) + + let touch = touchEvent(control) + + let handles = findHandles(control) + let firstHandle = handles[0] + let handleCenter = control.mapFromItem(firstHandle, firstHandle.width / 2, firstHandle.height / 2) + touch.press(0, control, handleCenter.x, handleCenter.y).commit() + verify(firstHandle.SplitHandle.pressed) + + touch.move(0, control, handleCenter.x + 100, handleCenter.y).commit() + verify(firstHandle.SplitHandle.pressed) + let firstItem = control.itemAt(0) + compare(firstItem.width, 125) + + touch.release(0, control, handleCenter.x + 100, handleCenter.y).commit() + verify(!firstHandle.SplitHandle.pressed) + compare(firstItem.width, 125) + } } diff --git a/tests/auto/quickcontrols2/controls/data/tst_stackview.qml b/tests/auto/quickcontrols2/controls/data/tst_stackview.qml index f2a3781fb1..901c9609a0 100644 --- a/tests/auto/quickcontrols2/controls/data/tst_stackview.qml +++ b/tests/auto/quickcontrols2/controls/data/tst_stackview.qml @@ -4,6 +4,7 @@ import QtQuick import QtTest import QtQuick.Controls +import Qt.test.controls TestCase { id: testCase @@ -1225,7 +1226,12 @@ TestCase { Item { objectName: "clearUponDestructionItem" - Component.onDestruction: container.onDestructionCallback(stackView) + onParentChanged: { + // We don't actually do this on destruction because destruction is delayed. + // Rather, we do it when we get un-parented. + if (parent === null) + container.onDestructionCallback(stackView) + } } } @@ -1544,4 +1550,48 @@ TestCase { tryCompare(control, "busy", true) tryCompare(control, "busy", false) } + + Component { + id: cppComponent + + StackView { + id: stackView + anchors.fill: parent + initialItem: cppComponent + + property Component cppComponent: ComponentCreator.createComponent("import QtQuick; Rectangle { color: \"navajowhite\" }") + } + } + + // Test that a component created in C++ works with StackView. + function test_componentCreatedInCpp() { + let control = createTemporaryObject(cppComponent, testCase) + verify(control) + compare(control.currentItem.color, Qt.color("navajowhite")) + + control.push(control.cppComponent, { color: "tomato" }) + compare(control.currentItem.color, Qt.color("tomato")) + } + + Component { + id: noProperties + Item {} + } + + Component { + id: invalidProperties + + StackView { + anchors.fill: parent + } + } + + function test_invalidProperties() { + let control = createTemporaryObject(invalidProperties, testCase) + verify(control) + verify(control.empty) + ignoreWarning(/Cannot resolve property "unknownProperty.test"/) + control.push(noProperties, { "unknownProperty.test": "crashes" }) + verify(!control.empty) + } } diff --git a/tests/auto/quickcontrols2/controls/data/tst_swipedelegate.qml b/tests/auto/quickcontrols2/controls/data/tst_swipedelegate.qml index 1a544e4c8c..77204015b7 100644 --- a/tests/auto/quickcontrols2/controls/data/tst_swipedelegate.qml +++ b/tests/auto/quickcontrols2/controls/data/tst_swipedelegate.qml @@ -4,7 +4,7 @@ import QtQuick import QtTest import QtQuick.Controls - +import Qt.test.controls TestCase { id: testCase @@ -1726,4 +1726,23 @@ TestCase { compare(control.background.width, 200) compare(control.contentItem.width, 200 - control.leftPadding - control.rightPadding) } + + Component { + id: cppDelegateComponent + + SwipeDelegate { + text: "SwipeDelegate" + width: 150 + swipe.right: ComponentCreator.createComponent( + "import QtQuick; Rectangle { width: 100; height: parent.height; color: \"tomato\" }") + } + } + + function test_delegateComponentCreatedInCpp() { + let control = createTemporaryObject(cppDelegateComponent, testCase) + verify(control) + + swipe(control, 0, -1.0) + compare(control.swipe.rightItem.color, Qt.color("tomato")) + } } diff --git a/tests/auto/quickcontrols2/controls/data/tst_tooltip.qml b/tests/auto/quickcontrols2/controls/data/tst_tooltip.qml index af661def9d..9874988c44 100644 --- a/tests/auto/quickcontrols2/controls/data/tst_tooltip.qml +++ b/tests/auto/quickcontrols2/controls/data/tst_tooltip.qml @@ -249,7 +249,13 @@ TestCase { function test_activateShortcutWhileToolTipVisible() { if ((Qt.platform.pluginName === "offscreen") || (Qt.platform.pluginName === "minimal")) - skip("Mouse hoovering not functional on offscreen/minimal platforms") + skip("Mouse hovering not functional on offscreen/minimal platforms") + + // Window shortcuts (the default context for Shortcut) require the window to have focus. + var window = testCase.Window.window + verify(window) + window.requestActivate() + tryCompare(window, "active", true) var root = createTemporaryObject(buttonAndShortcutComponent, testCase) verify(root) |