aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-03-16 03:02:08 +0100
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-03-16 03:02:08 +0100
commit4a434b19c347a6014f42cbcf0f1493d689e579fc (patch)
treeb33cb6f0a59f01336d66b73bc30f822aa24e61aa /tests
parente78843a23e1485abddf81e10c34048b7e0bd9eaa (diff)
parent8b78d9cea3091b0bd94d1ae0c71a000f8e7e1903 (diff)
Merge remote-tracking branch 'origin/5.12' into 5.13
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/controls/data/tst_dialogbuttonbox.qml136
1 files changed, 134 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))
+ }
}