aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-03-21 14:06:03 +0100
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-03-21 14:06:03 +0100
commit1b2e0d509ed8df858a621908936114544cddc55f (patch)
treec2917dfeb3c802642ebcc28407d089c5a9c95afb /tests
parent745ff8a9186d40c5c53f8ffa0a26d2730e6c214d (diff)
parentacebfc7f1e50386a83c1f039399cf5cf914b893e (diff)
Merge remote-tracking branch 'origin/5.13' into dev
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/controls/data/tst_dialogbuttonbox.qml136
-rw-r--r--tests/auto/sanity/tst_sanity.cpp6
2 files changed, 140 insertions, 2 deletions
diff --git a/tests/auto/controls/data/tst_dialogbuttonbox.qml b/tests/auto/controls/data/tst_dialogbuttonbox.qml
index 62789a47..6eca8569 100644
--- a/tests/auto/controls/data/tst_dialogbuttonbox.qml
+++ b/tests/auto/controls/data/tst_dialogbuttonbox.qml
@@ -54,8 +54,8 @@ import QtQuick.Controls 2.12
TestCase {
id: testCase
- width: 200
- height: 200
+ width: 600
+ height: 400
visible: true
when: windowShown
name: "DialogButtonBox"
@@ -292,4 +292,136 @@ TestCase {
verify(buttonPosInBox.x >= 0)
verify(buttonPosInBox.x + button.width < control.width)
}
+
+ Component {
+ id: dialogComponent
+ // Based on the Default style, where a single button fills
+ // half the dialog's width and is aligned to the right.
+ Dialog {
+ id: control
+ standardButtons: Dialog.Ok
+ visible: true
+
+ footer: DialogButtonBox {
+ id: box
+ visible: count > 0
+ alignment: count === 1 ? Qt.AlignRight : undefined
+
+ implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
+ (count === 1 ? implicitContentWidth * 2 : implicitContentWidth) + leftPadding + rightPadding)
+ implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
+ implicitContentHeight + topPadding + bottomPadding)
+ contentWidth: contentItem.contentWidth
+
+ delegate: Button {
+ width: box.count === 1 ? box.availableWidth / 2 : undefined
+ }
+ }
+ }
+ }
+
+ // QTBUG-73860
+ function test_oneButtonAlignedRightInImplicitWidthBox() {
+ var dialog = createTemporaryObject(dialogComponent, testCase)
+ verify(dialog)
+
+ var box = dialog.footer
+ var listView = box.contentItem
+ waitForRendering(listView)
+
+ var button = box.itemAt(0)
+ verify(button)
+
+ // The button should never go outside of the box.
+ var buttonPosInBox = button.mapToItem(box, 0, 0)
+ verify(buttonPosInBox.x >= 0, "Expected button to be inside left edge "
+ + "of DialogButtonBox, but it's " + buttonPosInBox.x)
+ verify(buttonPosInBox.x + button.width <= box.width, "Expected button to be inside right edge "
+ + "of DialogButtonBox (" + box.width + "), but it's " + (buttonPosInBox.x + button.width))
+ compare(box.width, dialog.width)
+ // There's a single button and we align it to the right.
+ compare(box.contentItem.width, button.width)
+ compare(box.contentItem.x, box.width - box.rightPadding - box.contentItem.width)
+ }
+
+ Component {
+ id: customButtonBox
+
+ DialogButtonBox {
+ objectName: "customButtonBox"
+ alignment: Qt.AlignRight
+
+ property alias okButton: okButton
+
+ Button {
+ id: okButton
+ text: "OK"
+
+ DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole
+ }
+ }
+ }
+
+ // QTBUG-72886
+ function test_oneCustomButtonChangeText() {
+ var control = createTemporaryObject(customButtonBox, testCase, {})
+ verify(control)
+
+ var listView = control.contentItem
+ waitForRendering(listView)
+
+ var button = control.okButton
+ verify(button)
+ button.text = "some longer text";
+
+ // The button should never go outside of the box.
+ tryVerify(function() { return button.mapToItem(control, 0, 0).x >= 0 },
+ 1000, "Expected left edge of button to be within left edge of DialogButtonBox (i.e. greater than or equal to 0)" +
+ ", but it's " + button.mapToItem(control, 0, 0).x)
+ tryVerify(function() { return button.mapToItem(control, 0, 0).x + button.width <= control.width },
+ 1000, "Expected right edge of button to be within right edge of DialogButtonBox (i.e. less than or equal to " +
+ control.width + "), but it's " + (button.mapToItem(control, 0, 0).x + button.width))
+ }
+
+ Component {
+ id: customButtonBoxTwoButtons
+
+ DialogButtonBox {
+ objectName: "customButtonBoxTwoButtons"
+ alignment: Qt.AlignRight
+
+ property alias okButton: okButton
+
+ Button {
+ id: okButton
+ text: "OK"
+
+ DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole
+ }
+ Button {
+ text: "Cancel"
+
+ DialogButtonBox.buttonRole: DialogButtonBox.RejectRole
+ }
+ }
+ }
+
+ // QTBUG-72886
+ function test_twoCustomButtonsChangeText() {
+ var control = createTemporaryObject(customButtonBoxTwoButtons, testCase, {})
+ verify(control)
+
+ var listView = control.contentItem
+ waitForRendering(listView)
+
+ var button = control.okButton
+ button.text = "some longer text";
+ // The button should never go outside of the box.
+ tryVerify(function() { return button.mapToItem(control, 0, 0).x >= 0 },
+ 1000, "Expected left edge of button to be within left edge of DialogButtonBox (i.e. greater than or equal to 0)" +
+ ", but it's " + button.mapToItem(control, 0, 0).x)
+ tryVerify(function() { return button.mapToItem(control, 0, 0).x + button.width <= control.width },
+ 1000, "Expected right edge of button to be within right edge of DialogButtonBox (i.e. less than or equal to " +
+ control.width + "), but it's " + (button.mapToItem(control, 0, 0).x + button.width))
+ }
}
diff --git a/tests/auto/sanity/tst_sanity.cpp b/tests/auto/sanity/tst_sanity.cpp
index 69553d93..d2d962bc 100644
--- a/tests/auto/sanity/tst_sanity.cpp
+++ b/tests/auto/sanity/tst_sanity.cpp
@@ -137,6 +137,12 @@ protected:
m_errors += QString("%1:%2 : %3").arg(m_fileName).arg(node->firstSourceLocation().startLine).arg(error);
}
+ void throwRecursionDepthError()
+ {
+ m_errors += QString::fromLatin1("%1: Maximum statement or expression depth exceeded")
+ .arg(m_fileName);
+ }
+
private:
QString m_fileName;
QStringList m_errors;