diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2016-10-31 16:08:59 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2016-10-31 16:08:59 +0100 |
commit | f7fd7460231ea9ad80fc85b4af793ad7ace56930 (patch) | |
tree | 2155c9399945b4ebe0b9af84da75b478afb30683 /tests | |
parent | f4b2f9eeac7f9175a5834f405ad88fb6d28864e1 (diff) | |
parent | 10972ca272ae59fbe0f18eef6d9237fbd4aaca86 (diff) |
Merge remote-tracking branch 'origin/5.8' into dev
Conflicts:
src/quicktemplates2/qquickpopup.cpp
src/quicktemplates2/qquickpopup_p_p.h
Change-Id: I33241dfd15a320e6ae2f0c056252b0ec6be7c6f6
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/controls/data/tst_dialog.qml | 97 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_page.qml | 40 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_popup.qml | 31 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_scrollbar.qml | 16 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_scrollindicator.qml | 16 | ||||
-rw-r--r-- | tests/auto/drawer/tst_drawer.cpp | 2 | ||||
-rw-r--r-- | tests/manual/testbench/main.cpp | 2 | ||||
-rw-r--r-- | tests/manual/testbench/qml.qrc | 2 | ||||
-rw-r--r-- | tests/manual/testbench/testbench.qml (renamed from tests/manual/testbench/main.qml) | 140 |
9 files changed, 295 insertions, 51 deletions
diff --git a/tests/auto/controls/data/tst_dialog.qml b/tests/auto/controls/data/tst_dialog.qml index d4cbc222..69c47fed 100644 --- a/tests/auto/controls/data/tst_dialog.qml +++ b/tests/auto/controls/data/tst_dialog.qml @@ -62,16 +62,6 @@ TestCase { } Component { - id: headerBox - DialogButtonBox { position: DialogButtonBox.Header } - } - - Component { - id: footerBox - DialogButtonBox { position: DialogButtonBox.Footer } - } - - Component { id: signalSpy SignalSpy { } } @@ -79,9 +69,8 @@ TestCase { function test_defaults() { var control = dialog.createObject(testCase) verify(control) - verify(!control.header) - verify(!control.footer) - verify(control.buttonBox) + verify(control.header) + verify(control.footer) compare(control.standardButtons, 0) control.destroy() } @@ -122,22 +111,18 @@ TestCase { function test_buttonBox_data() { return [ - { tag: "default header", property: "header", buttonBox: headerBox }, - { tag: "default footer", property: "footer", buttonBox: footerBox }, - { tag: "custom header", property: "header", position: DialogButtonBox.Header }, - { tag: "custom footer", property: "footer", position: DialogButtonBox.Footer } + { tag: "default" }, + { tag: "custom", custom: true } ] } function test_buttonBox(data) { var control = dialog.createObject(testCase) - if (data.buttonBox) - control.buttonBox = data.buttonBox - else - control[data.property] = buttonBox.createObject(testCase, {position: data.position}) + if (data.custom) + control.footer = buttonBox.createObject(testCase) control.standardButtons = Dialog.Ok | Dialog.Cancel - var box = control[data.property] + var box = control.footer verify(box) compare(box.standardButtons, Dialog.Ok | Dialog.Cancel) @@ -192,30 +177,6 @@ TestCase { control.destroy() } - function test_warnings() { - var control = dialog.createObject(testCase) - verify(control) - - var testComponent = Qt.createComponent("TestItem.qml") - verify(testComponent) - - control.buttonBox = headerBox - control.header = testComponent.createObject(testCase) - ignoreWarning(Qt.resolvedUrl("tst_dialog.qml") + ":56:9: QML Dialog: Custom header detected. Cannot assign buttonBox as a header. No standard buttons will appear in the header.") - control.standardButtons = Dialog.Apply - - control.buttonBox = footerBox - control.footer = testComponent.createObject(testCase) - ignoreWarning(Qt.resolvedUrl("tst_dialog.qml") + ":56:9: QML Dialog: Custom footer detected. Cannot assign buttonBox as a footer. No standard buttons will appear in the footer.") - control.standardButtons = Dialog.Cancel - - control.buttonBox = testComponent - ignoreWarning(Qt.resolvedUrl("tst_dialog.qml") + ":56:9: QML Dialog: buttonBox must be an instance of DialogButtonBox") - control.standardButtons = Dialog.Ok - - control.destroy() - } - function test_layout() { var control = dialog.createObject(testCase, {width: 100, height: 100}) verify(control) @@ -294,4 +255,48 @@ TestCase { control.destroy() } + + function test_spacing_data() { + return [ + { tag: "content", header: false, content: true, footer: false }, + { tag: "header,content", header: true, content: true, footer: false }, + { tag: "content,footer", header: false, content: true, footer: true }, + { tag: "header,content,footer", header: true, content: true, footer: true }, + { tag: "header,footer", header: true, content: false, footer: true }, + { tag: "header", header: true, content: false, footer: false }, + { tag: "footer", header: false, content: false, footer: true }, + ] + } + + function test_spacing(data) { + var control = dialog.createObject(testCase, {spacing: 20, width: 100, height: 100}) + verify(control) + + control.open() + waitForRendering(control.contentItem) + verify(control.visible) + + control.contentItem.visible = data.content + control.header = buttonBox.createObject(control.contentItem, {visible: data.header}) + control.footer = buttonBox.createObject(control.contentItem, {visible: data.footer}) + + compare(control.header.x, 0) + compare(control.header.y, 0) + compare(control.header.width, control.width) + verify(control.header.height > 0) + + compare(control.footer.x, 0) + compare(control.footer.y, control.height - control.footer.height) + compare(control.footer.width, control.width) + verify(control.footer.height > 0) + + compare(control.contentItem.x, control.leftPadding) + compare(control.contentItem.y, control.topPadding + (data.header ? control.header.height + control.spacing : 0)) + compare(control.contentItem.width, control.availableWidth) + compare(control.contentItem.height, control.availableHeight + - (data.header ? control.header.height + control.spacing : 0) + - (data.footer ? control.footer.height + control.spacing : 0)) + + control.destroy() + } } diff --git a/tests/auto/controls/data/tst_page.qml b/tests/auto/controls/data/tst_page.qml index a1cdbf8e..9b52236e 100644 --- a/tests/auto/controls/data/tst_page.qml +++ b/tests/auto/controls/data/tst_page.qml @@ -226,4 +226,44 @@ TestCase { control.destroy() } + + function test_spacing_data() { + return [ + { tag: "content", header: false, content: true, footer: false }, + { tag: "header,content", header: true, content: true, footer: false }, + { tag: "content,footer", header: false, content: true, footer: true }, + { tag: "header,content,footer", header: true, content: true, footer: true }, + { tag: "header,footer", header: true, content: false, footer: true }, + { tag: "header", header: true, content: false, footer: false }, + { tag: "footer", header: false, content: false, footer: true }, + ] + } + + function test_spacing(data) { + var control = page.createObject(testCase, {spacing: 20, width: 100, height: 100}) + verify(control) + + control.contentItem.visible = data.content + control.header = toolBar.createObject(control.contentItem, {visible: data.header}) + control.footer = toolBar.createObject(control.contentItem, {visible: data.footer}) + + compare(control.header.x, 0) + compare(control.header.y, 0) + compare(control.header.width, control.width) + verify(control.header.height > 0) + + compare(control.footer.x, 0) + compare(control.footer.y, control.height - control.footer.height) + compare(control.footer.width, control.width) + verify(control.footer.height > 0) + + compare(control.contentItem.x, control.leftPadding) + compare(control.contentItem.y, control.topPadding + (data.header ? control.header.height + control.spacing : 0)) + compare(control.contentItem.width, control.availableWidth) + compare(control.contentItem.height, control.availableHeight + - (data.header ? control.header.height + control.spacing : 0) + - (data.footer ? control.footer.height + control.spacing : 0)) + + control.destroy() + } } diff --git a/tests/auto/controls/data/tst_popup.qml b/tests/auto/controls/data/tst_popup.qml index c81c6341..982ac7ab 100644 --- a/tests/auto/controls/data/tst_popup.qml +++ b/tests/auto/controls/data/tst_popup.qml @@ -1229,4 +1229,35 @@ TestCase { control.destroy() } + + Component { + id: xyBindingLoop + ApplicationWindow { + id: window + width: 360 + height: 360 + visible: true + property alias popup: popup + + Popup { + id: popup + visible: true + x: (parent.width - width) / 2 + y: (parent.height - height) / 2 + Label { + text: "Content" + anchors.fill: parent + } + } + } + } + + function test_xyBindingLoop() { + var window = xyBindingLoop.createObject(testCase) + var control = window.popup + waitForRendering(control.contentItem) + compare(control.x, (control.parent.width - control.width) / 2) + compare(control.y, (control.parent.height - control.height) / 2) + window.destroy() + } } diff --git a/tests/auto/controls/data/tst_scrollbar.qml b/tests/auto/controls/data/tst_scrollbar.qml index 15b4b3f0..54ecf15f 100644 --- a/tests/auto/controls/data/tst_scrollbar.qml +++ b/tests/auto/controls/data/tst_scrollbar.qml @@ -155,6 +155,22 @@ TestCase { compare(horizontal.size, container.visibleArea.widthRatio) compare(horizontal.position, container.visibleArea.xPosition) + var oldY = vertical.y + var oldHeight = vertical.height + vertical.parent = testCase + vertical.y -= 10 + container.height += 10 + compare(vertical.y, oldY - 10) + compare(vertical.height, oldHeight) + + var oldX = horizontal.x + var oldWidth = horizontal.width + horizontal.parent = testCase + horizontal.x -= 10 + container.width += 10 + compare(horizontal.x, oldX - 10) + compare(horizontal.width, oldWidth) + container.destroy() } diff --git a/tests/auto/controls/data/tst_scrollindicator.qml b/tests/auto/controls/data/tst_scrollindicator.qml index 551247f6..1ec03b15 100644 --- a/tests/auto/controls/data/tst_scrollindicator.qml +++ b/tests/auto/controls/data/tst_scrollindicator.qml @@ -150,6 +150,22 @@ TestCase { compare(horizontal.size, container.visibleArea.widthRatio) compare(horizontal.position, container.visibleArea.xPosition) + var oldY = vertical.y + var oldHeight = vertical.height + vertical.parent = testCase + vertical.y -= 10 + container.height += 10 + compare(vertical.y, oldY - 10) + compare(vertical.height, oldHeight) + + var oldX = horizontal.x + var oldWidth = horizontal.width + horizontal.parent = testCase + horizontal.x -= 10 + container.width += 10 + compare(horizontal.x, oldX - 10) + compare(horizontal.width, oldWidth) + container.destroy() } diff --git a/tests/auto/drawer/tst_drawer.cpp b/tests/auto/drawer/tst_drawer.cpp index 58a5ba3c..a523beed 100644 --- a/tests/auto/drawer/tst_drawer.cpp +++ b/tests/auto/drawer/tst_drawer.cpp @@ -380,7 +380,7 @@ void tst_Drawer::reposition() window->setWidth(window->width() + 100); QTRY_COMPARE(geometry(dimmer), QRectF(0, 150, window->width(), window->height() - 150)); - QCOMPARE(geometry(popupItem), QRectF(window->width() - drawer->width(), 150, window->width() / 2, window->height() - 150)); + QTRY_COMPARE(geometry(popupItem), QRectF(window->width() - drawer->width(), 150, window->width() / 2, window->height() - 150)); drawer->close(); QTRY_COMPARE(geometry(popupItem), QRectF(window->width(), 150, window->width() / 2, window->height() - 150)); diff --git a/tests/manual/testbench/main.cpp b/tests/manual/testbench/main.cpp index a782b5fe..5a54dab3 100644 --- a/tests/manual/testbench/main.cpp +++ b/tests/manual/testbench/main.cpp @@ -54,7 +54,7 @@ int main(int argc, char *argv[]) // TODO: move style selection into app UI and use settings to save choices. // qputenv("QT_QUICK_CONTROLS_STYLE", "material"); QQmlApplicationEngine engine; - engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + engine.load(QUrl(QStringLiteral("qrc:/testbench.qml"))); return app.exec(); } diff --git a/tests/manual/testbench/qml.qrc b/tests/manual/testbench/qml.qrc index 5f6483ac..9f4b1783 100644 --- a/tests/manual/testbench/qml.qrc +++ b/tests/manual/testbench/qml.qrc @@ -1,5 +1,5 @@ <RCC> <qresource prefix="/"> - <file>main.qml</file> + <file>testbench.qml</file> </qresource> </RCC> diff --git a/tests/manual/testbench/main.qml b/tests/manual/testbench/testbench.qml index ea59d5b5..38fd06fc 100644 --- a/tests/manual/testbench/main.qml +++ b/tests/manual/testbench/testbench.qml @@ -745,14 +745,14 @@ ApplicationWindow { Frame { Tumbler { model: 5 - implicitWidth: 100 + implicitWidth: 80 implicitHeight: 100 } } Frame { Tumbler { model: 5 - implicitWidth: 100 + implicitWidth: 80 implicitHeight: 100 enabled: false } @@ -761,11 +761,147 @@ ApplicationWindow { RowLayout { Dial { + implicitWidth: 100 + implicitHeight: 100 } Dial { + implicitWidth: 100 + implicitHeight: 100 enabled: false } } + + ListModel { + id: checkableDelegateModel + ListElement { label: "Normal" } + ListElement { label: "Pressed"; press: true } + ListElement { label: "Checked"; check: true } + ListElement { label: "CH + PR"; check: true; press: true } + ListElement { label: "Disabled"; disabled: true } + } + + RowLayout { + Frame { + Column { + width: 200 + + Repeater { + model: checkableDelegateModel + delegate: CheckDelegate { + text: label + width: parent.width + down: press + checked: check + enabled: !disabled + ButtonGroup.group: radioButtonGroup + } + } + } + } + + ButtonGroup { + id: radioButtonGroup + } + + Frame { + Column { + width: 200 + + Repeater { + model: checkableDelegateModel + delegate: RadioDelegate { + text: label + down: press + width: parent.width + checked: check + enabled: !disabled + ButtonGroup.group: radioButtonGroup + } + } + } + } + + Frame { + Column { + width: 200 + + Repeater { + model: checkableDelegateModel + delegate: SwitchDelegate { + text: label + width: parent.width + checked: check + down: press + enabled: !disabled + } + } + } + } + } + + ListModel { + id: regularDelegateModel + ListElement { label: "Normal" } + ListElement { label: "Pressed"; press: true } + ListElement { label: "Disabled"; disabled: true } + } + + RowLayout { + Frame { + Column { + width: 200 + + Repeater { + model: regularDelegateModel + delegate: ItemDelegate { + text: label + width: parent.width + down: press + enabled: !disabled + } + } + } + } + Frame { + Column { + id: listView + width: 200 + clip: true + + Repeater { + model: regularDelegateModel + delegate: SwipeDelegate { + id: swipeDelegate + text: label + width: parent.width + down: press + enabled: !disabled + + Component { + id: removeComponent + + Rectangle { + color: swipeDelegate.swipe.complete && swipeDelegate.pressed ? "#333" : "#444" + width: parent.width + height: parent.height + clip: true + + Label { + font.pixelSize: swipeDelegate.font.pixelSize + text: "Boop" + color: "white" + anchors.centerIn: parent + } + } + } + + swipe.left: removeComponent + swipe.right: removeComponent + } + } + } + } + } } } } |