diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/controls/data/tst_abstractbutton.qml | 107 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_buttongroup.qml | 28 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_checkbox.qml | 87 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_checkdelegate.qml | 47 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_scrollbar.qml | 48 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_scrollindicator.qml | 48 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_spinbox.qml | 44 | ||||
-rw-r--r--[-rwxr-xr-x] | tests/manual/testbench/fonts/LICENSE.txt | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | tests/manual/testbench/fonts/fontawesome.ttf | bin | 5464 -> 5464 bytes | |||
-rw-r--r-- | tests/tests.pro | 2 |
10 files changed, 390 insertions, 21 deletions
diff --git a/tests/auto/controls/data/tst_abstractbutton.qml b/tests/auto/controls/data/tst_abstractbutton.qml index 7acf9882..b266b183 100644 --- a/tests/auto/controls/data/tst_abstractbutton.qml +++ b/tests/auto/controls/data/tst_abstractbutton.qml @@ -119,6 +119,113 @@ TestCase { compare(control.implicitHeight, 220) } + function test_pressPoint_data() { + return [ + { tag: "mouse", mouse: true }, + { tag: "touch", touch: true } + ] + } + + function test_pressPoint(data) { + var control = createTemporaryObject(button, testCase, {width: 100, height: 40}) + verify(control) + + var pressXChanges = 0 + var pressYChanges = 0 + + var pressXSpy = signalSpy.createObject(control, {target: control, signalName: "pressXChanged"}) + verify(pressXSpy.valid) + + var pressYSpy = signalSpy.createObject(control, {target: control, signalName: "pressYChanged"}) + verify(pressYSpy.valid) + + compare(control.pressX, 0) + compare(control.pressY, 0) + + var touch = data.touch ? touchEvent(control) : null + + if (data.touch) + touch.press(0, control, control.width / 2, control.height / 2).commit() + else + mousePress(control, control.width / 2, control.height / 2) + compare(control.pressX, control.width / 2) + compare(control.pressY, control.height / 2) + compare(pressXSpy.count, ++pressXChanges) + compare(pressYSpy.count, ++pressYChanges) + + if (data.touch) + touch.move(0, control, control.width / 2, control.height / 2).commit() + else + mouseMove(control, control.width / 2, control.height / 2) + compare(control.pressX, control.width / 2) + compare(control.pressY, control.height / 2) + compare(pressXSpy.count, pressXChanges) + compare(pressYSpy.count, pressYChanges) + + if (data.touch) + touch.move(0, control, control.width / 4, control.height / 4).commit() + else + mouseMove(control, control.width / 4, control.height / 4) + compare(control.pressX, control.width / 4) + compare(control.pressY, control.height / 4) + compare(pressXSpy.count, ++pressXChanges) + compare(pressYSpy.count, ++pressYChanges) + + if (data.touch) + touch.move(0, control, 0, 0).commit() + else + mouseMove(control, 0, 0) + compare(control.pressX, 0) + compare(control.pressY, 0) + compare(pressXSpy.count, ++pressXChanges) + compare(pressYSpy.count, ++pressYChanges) + + if (data.touch) + touch.move(0, control, -control.width / 2, -control.height / 2).commit() + else + mouseMove(control, -control.width / 2, -control.height / 2) + compare(control.pressX, -control.width / 2) + compare(control.pressY, -control.height / 2) + compare(pressXSpy.count, ++pressXChanges) + compare(pressYSpy.count, ++pressYChanges) + + if (data.touch) + touch.release(0, control, -control.width / 2, -control.height / 2).commit() + else + mouseRelease(control, -control.width / 2, -control.height / 2) + compare(control.pressX, -control.width / 2) + compare(control.pressY, -control.height / 2) + compare(pressXSpy.count, pressXChanges) + compare(pressYSpy.count, pressYChanges) + + if (data.touch) + touch.press(0, control, control.width - 1, control.height - 1).commit() + else + mousePress(control, control.width - 1, control.height - 1) + compare(control.pressX, control.width - 1) + compare(control.pressY, control.height - 1) + compare(pressXSpy.count, ++pressXChanges) + compare(pressYSpy.count, ++pressYChanges) + + if (data.touch) + touch.move(0, control, control.width + 1, control.height + 1).commit() + else + mousePress(control, control.width + 1, control.height + 1) + compare(control.pressX, control.width + 1) + compare(control.pressY, control.height + 1) + compare(pressXSpy.count, ++pressXChanges) + compare(pressYSpy.count, ++pressYChanges) + + if (data.touch) + touch.release(0, control, control.width + 2, control.height + 2).commit() + else + mouseRelease(control, control.width + 2, control.height + 2) + compare(control.pressX, control.width + 2) + compare(control.pressY, control.height + 2) + compare(pressXSpy.count, ++pressXChanges) + compare(pressYSpy.count, ++pressYChanges) + } + function test_pressAndHold() { var control = createTemporaryObject(button, testCase, {checkable: true}) verify(control) diff --git a/tests/auto/controls/data/tst_buttongroup.qml b/tests/auto/controls/data/tst_buttongroup.qml index 7d981dd3..1b7fa4a3 100644 --- a/tests/auto/controls/data/tst_buttongroup.qml +++ b/tests/auto/controls/data/tst_buttongroup.qml @@ -99,6 +99,7 @@ TestCase { compare(group.buttons.length, 0) compare(group.checkedButton, null) compare(group.exclusive, true) + compare(group.checkState, Qt.Unchecked) } function test_current() { @@ -371,36 +372,63 @@ TestCase { var group = createTemporaryObject(nonExclusiveGroup, testCase) verify(group) + compare(group.checkState, Qt.Unchecked) + var button1 = createTemporaryObject(button, testCase, {checked: true}) group.addButton(button1) compare(button1.checked, true) compare(group.checkedButton, null) + compare(group.checkState, Qt.Checked) var button2 = createTemporaryObject(button, testCase, {checked: true}) group.addButton(button2) compare(button1.checked, true) compare(button2.checked, true) compare(group.checkedButton, null) + compare(group.checkState, Qt.Checked) + + var button3 = createTemporaryObject(button, testCase, {checked: false}) + group.addButton(button3) + compare(button1.checked, true) + compare(button2.checked, true) + compare(button3.checked, false) + compare(group.checkedButton, null) + compare(group.checkState, Qt.PartiallyChecked) button1.checked = false compare(button1.checked, false) compare(button2.checked, true) + compare(button3.checked, false) compare(group.checkedButton, null) + compare(group.checkState, Qt.PartiallyChecked) button2.checked = false compare(button1.checked, false) compare(button2.checked, false) + compare(button3.checked, false) compare(group.checkedButton, null) + compare(group.checkState, Qt.Unchecked) button1.checked = true compare(button1.checked, true) compare(button2.checked, false) + compare(button3.checked, false) compare(group.checkedButton, null) + compare(group.checkState, Qt.PartiallyChecked) button2.checked = true compare(button1.checked, true) compare(button2.checked, true) + compare(button3.checked, false) + compare(group.checkedButton, null) + compare(group.checkState, Qt.PartiallyChecked) + + button3.checked = true + compare(button1.checked, true) + compare(button2.checked, true) + compare(button3.checked, true) compare(group.checkedButton, null) + compare(group.checkState, Qt.Checked) } Component { diff --git a/tests/auto/controls/data/tst_checkbox.qml b/tests/auto/controls/data/tst_checkbox.qml index 5f36b00c..3fb7d15e 100644 --- a/tests/auto/controls/data/tst_checkbox.qml +++ b/tests/auto/controls/data/tst_checkbox.qml @@ -382,17 +382,19 @@ TestCase { compare(container.cb2.tristate, false) container.cb1.checkState = Qt.PartiallyChecked - compare(container.cb1.checked, true) + compare(container.cb1.checked, false) compare(container.cb1.checkState, Qt.PartiallyChecked) - compare(container.cb2.checked, true) + compare(container.cb2.checked, false) compare(container.cb2.checkState, Qt.PartiallyChecked) - compare(container.cb1.tristate, true) - compare(container.cb2.tristate, true) + // note: since Qt Quick Controls 2.4 (Qt 5.11), CheckBox does not + // force tristate when checkState is set to Qt.PartiallyChecked + compare(container.cb1.tristate, false) + compare(container.cb2.tristate, false) } function test_tristate() { - var control = createTemporaryObject(checkBox, testCase) + var control = createTemporaryObject(checkBox, testCase, {tristate: true}) var sequenceSpy = signalSequenceSpy.createObject(control, {target: control}) @@ -400,23 +402,22 @@ TestCase { control.forceActiveFocus() verify(control.activeFocus) - compare(control.tristate, false) + compare(control.tristate, true) compare(control.checked, false) compare(control.checkState, Qt.Unchecked) - sequenceSpy.expectedSequence = [["checkStateChanged", { "pressed": false, "checked": true, "checkState": Qt.PartiallyChecked }], - ["checkedChanged", { "pressed": false, "checked": true, "checkState": Qt.PartiallyChecked }]] + sequenceSpy.expectedSequence = [["checkStateChanged", { "pressed": false, "checked": false, "checkState": Qt.PartiallyChecked }]] control.checkState = Qt.PartiallyChecked - compare(control.tristate, true) - compare(control.checked, true) + compare(control.checked, false) compare(control.checkState, Qt.PartiallyChecked) verify(sequenceSpy.success) // key: partial -> checked - sequenceSpy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": true, "checkState": Qt.PartiallyChecked }], + sequenceSpy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": false, "checkState": Qt.PartiallyChecked }], "pressed", - ["pressedChanged", { "pressed": false, "checked": true, "checkState": Qt.PartiallyChecked }], + ["pressedChanged", { "pressed": false, "checked": false, "checkState": Qt.PartiallyChecked }], ["checkStateChanged", { "pressed": false, "checked": true, "checkState": Qt.Checked }], + ["checkedChanged", { "pressed": false, "checked": true, "checkState": Qt.Checked }], "released", "clicked"] keyClick(Qt.Key_Space) @@ -441,20 +442,20 @@ TestCase { sequenceSpy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": false, "checkState": Qt.Unchecked }], "pressed", ["pressedChanged", { "pressed": false, "checked": false, "checkState": Qt.Unchecked }], - ["checkStateChanged", { "pressed": false, "checked": true, "checkState": Qt.PartiallyChecked }], - ["checkedChanged", { "pressed": false, "checked": true, "checkState": Qt.PartiallyChecked }], + ["checkStateChanged", { "pressed": false, "checked": false, "checkState": Qt.PartiallyChecked }], "released", "clicked"] keyClick(Qt.Key_Space) - compare(control.checked, true) + compare(control.checked, false) compare(control.checkState, Qt.PartiallyChecked) verify(sequenceSpy.success) // mouse: partial -> checked - sequenceSpy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": true, "checkState": Qt.PartiallyChecked }], + sequenceSpy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": false, "checkState": Qt.PartiallyChecked }], "pressed", - ["pressedChanged", { "pressed": false, "checked": true, "checkState": Qt.PartiallyChecked }], + ["pressedChanged", { "pressed": false, "checked": false, "checkState": Qt.PartiallyChecked }], ["checkStateChanged", { "pressed": false, "checked": true, "checkState": Qt.Checked }], + ["checkedChanged", { "pressed": false, "checked": true, "checkState": Qt.Checked }], "released", "clicked"] mouseClick(control) @@ -479,12 +480,11 @@ TestCase { sequenceSpy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": false, "checkState": Qt.Unchecked }], "pressed", ["pressedChanged", { "pressed": false, "checked": false, "checkState": Qt.Unchecked }], - ["checkStateChanged", { "pressed": false, "checked": true, "checkState": Qt.PartiallyChecked }], - ["checkedChanged", { "pressed": false, "checked": true, "checkState": Qt.PartiallyChecked }], + ["checkStateChanged", { "pressed": false, "checked": false, "checkState": Qt.PartiallyChecked }], "released", "clicked"] mouseClick(control) - compare(control.checked, true) + compare(control.checked, false) compare(control.checkState, Qt.PartiallyChecked) verify(sequenceSpy.success) } @@ -494,4 +494,51 @@ TestCase { verify(control) compare(control.baselineOffset, control.contentItem.y + control.contentItem.baselineOffset) } + + Component { + id: nextCheckStateBox + CheckBox { + tristate: true + nextCheckState: function() { + if (checkState === Qt.Checked) + return Qt.Unchecked + else + return Qt.Checked + } + } + } + + function test_nextCheckState_data() { + return [ + { tag: "unchecked", checkState: Qt.Unchecked, expectedState: Qt.Checked }, + { tag: "partially-checked", checkState: Qt.PartiallyChecked, expectedState: Qt.Checked }, + { tag: "checked", checkState: Qt.Checked, expectedState: Qt.Unchecked } + ] + } + + function test_nextCheckState(data) { + var control = createTemporaryObject(nextCheckStateBox, testCase) + verify(control) + + // mouse + control.checkState = data.checkState + compare(control.checkState, data.checkState) + mouseClick(control) + compare(control.checkState, data.expectedState) + + // touch + control.checkState = data.checkState + compare(control.checkState, data.checkState) + var touch = touchEvent(control) + touch.press(0, control).commit().release(0, control).commit() + compare(control.checkState, data.expectedState) + + // keyboard + control.forceActiveFocus() + tryCompare(control, "activeFocus", true) + control.checkState = data.checkState + compare(control.checkState, data.checkState) + keyClick(Qt.Key_Space) + compare(control.checkState, data.expectedState) + } } diff --git a/tests/auto/controls/data/tst_checkdelegate.qml b/tests/auto/controls/data/tst_checkdelegate.qml index 9f92b4dc..72b45251 100644 --- a/tests/auto/controls/data/tst_checkdelegate.qml +++ b/tests/auto/controls/data/tst_checkdelegate.qml @@ -170,4 +170,51 @@ TestCase { break; } } + + Component { + id: nextCheckStateDelegate + CheckDelegate { + tristate: true + nextCheckState: function() { + if (checkState === Qt.Checked) + return Qt.Unchecked + else + return Qt.Checked + } + } + } + + function test_nextCheckState_data() { + return [ + { tag: "unchecked", checkState: Qt.Unchecked, expectedState: Qt.Checked }, + { tag: "partially-checked", checkState: Qt.PartiallyChecked, expectedState: Qt.Checked }, + { tag: "checked", checkState: Qt.Checked, expectedState: Qt.Unchecked } + ] + } + + function test_nextCheckState(data) { + var control = createTemporaryObject(nextCheckStateDelegate, testCase) + verify(control) + + // mouse + control.checkState = data.checkState + compare(control.checkState, data.checkState) + mouseClick(control) + compare(control.checkState, data.expectedState) + + // touch + control.checkState = data.checkState + compare(control.checkState, data.checkState) + var touch = touchEvent(control) + touch.press(0, control).commit().release(0, control).commit() + compare(control.checkState, data.expectedState) + + // keyboard + control.forceActiveFocus() + tryCompare(control, "activeFocus", true) + control.checkState = data.checkState + compare(control.checkState, data.checkState) + keyClick(Qt.Key_Space) + compare(control.checkState, data.expectedState) + } } diff --git a/tests/auto/controls/data/tst_scrollbar.qml b/tests/auto/controls/data/tst_scrollbar.qml index d515db7e..90fe9468 100644 --- a/tests/auto/controls/data/tst_scrollbar.qml +++ b/tests/auto/controls/data/tst_scrollbar.qml @@ -788,4 +788,52 @@ TestCase { if (control.background) tryCompare(control.background, "opacity", 0) } + + function test_minimumSize() { + var container = createTemporaryObject(flickable, testCase) + verify(container) + waitForRendering(container) + + var vertical = scrollBar.createObject(container, {minimumSize: 0.1}) + container.ScrollBar.vertical = vertical + + compare(container.visibleArea.heightRatio, 0.5) + compare(vertical.size, 0.5) + compare(vertical.visualSize, 0.5) + compare(vertical.contentItem.height, 0.5 * vertical.availableHeight) + + container.contentHeight = 2000 + + compare(container.visibleArea.heightRatio, 0.05) + compare(vertical.size, 0.05) + compare(vertical.visualSize, 0.1) + compare(vertical.contentItem.height, 0.1 * vertical.availableHeight) + + verify(container.atYBeginning) + compare(container.visibleArea.yPosition, 0.0) + compare(vertical.position, 0.0) + compare(vertical.visualPosition, 0.0) + compare(vertical.contentItem.y, vertical.topPadding) + + container.contentY = 1900 + + verify(container.atYEnd) + compare(container.visibleArea.yPosition, 0.95) + compare(vertical.position, 0.95) + compare(vertical.visualPosition, 0.9) + compare(vertical.contentItem.y, vertical.topPadding + 0.9 * vertical.availableHeight) + + container.contentHeight = 125 + + compare(container.visibleArea.heightRatio, 0.8) + compare(vertical.size, 0.8) + compare(vertical.visualSize, 0.8) + compare(vertical.contentItem.height, 0.8 * vertical.availableHeight) + + verify(container.atYEnd) + compare(container.visibleArea.yPosition, 0.2) + compare(vertical.position, 0.2) + compare(vertical.visualPosition, 0.2) + compare(vertical.contentItem.y, vertical.topPadding + 0.2 * vertical.availableHeight) + } } diff --git a/tests/auto/controls/data/tst_scrollindicator.qml b/tests/auto/controls/data/tst_scrollindicator.qml index a6275f91..9435ec3b 100644 --- a/tests/auto/controls/data/tst_scrollindicator.qml +++ b/tests/auto/controls/data/tst_scrollindicator.qml @@ -258,4 +258,52 @@ TestCase { touch.release(0, control).commit() verify(!ma.pressed) } + + function test_minimumSize() { + var container = createTemporaryObject(flickable, testCase) + verify(container) + waitForRendering(container) + + var vertical = scrollIndicator.createObject(container, {minimumSize: 0.1}) + container.ScrollIndicator.vertical = vertical + + compare(container.visibleArea.heightRatio, 0.5) + compare(vertical.size, 0.5) + compare(vertical.visualSize, 0.5) + compare(vertical.contentItem.height, 0.5 * vertical.availableHeight) + + container.contentHeight = 2000 + + compare(container.visibleArea.heightRatio, 0.05) + compare(vertical.size, 0.05) + compare(vertical.visualSize, 0.1) + compare(vertical.contentItem.height, 0.1 * vertical.availableHeight) + + verify(container.atYBeginning) + compare(container.visibleArea.yPosition, 0.0) + compare(vertical.position, 0.0) + compare(vertical.visualPosition, 0.0) + compare(vertical.contentItem.y, vertical.topPadding) + + container.contentY = 1900 + + verify(container.atYEnd) + compare(container.visibleArea.yPosition, 0.95) + compare(vertical.position, 0.95) + compare(vertical.visualPosition, 0.9) + compare(vertical.contentItem.y, vertical.topPadding + 0.9 * vertical.availableHeight) + + container.contentHeight = 125 + + compare(container.visibleArea.heightRatio, 0.8) + compare(vertical.size, 0.8) + compare(vertical.visualSize, 0.8) + compare(vertical.contentItem.height, 0.8 * vertical.availableHeight) + + verify(container.atYEnd) + compare(container.visibleArea.yPosition, 0.2) + compare(vertical.position, 0.2) + compare(vertical.visualPosition, 0.2) + compare(vertical.contentItem.y, vertical.topPadding + 0.2 * vertical.availableHeight) + } } diff --git a/tests/auto/controls/data/tst_spinbox.qml b/tests/auto/controls/data/tst_spinbox.qml index 5a3b1f29..9568da1a 100644 --- a/tests/auto/controls/data/tst_spinbox.qml +++ b/tests/auto/controls/data/tst_spinbox.qml @@ -570,4 +570,48 @@ TestCase { verify(control) compare(control.value, 1000) } + + Component { + id: sizeBox + SpinBox { + from: 0 + to: items.length - 1 + + property var items: ["Small", "Medium", "Large"] + + validator: RegExpValidator { + regExp: new RegExp("(Small|Medium|Large)", "i") + } + + textFromValue: function(value) { + return items[value]; + } + + valueFromText: function(text) { + for (var i = 0; i < items.length; ++i) { + if (items[i].toLowerCase().indexOf(text.toLowerCase()) === 0) + return i + } + return sb.value + } + } + } + + function test_textFromValue_data() { + return [ + { tag: "default", component: spinBox, values: [0, 10, 99], displayTexts: ["0", "10", "99"] }, + { tag: "custom", component: sizeBox, values: [0, 1, 2], displayTexts: ["Small", "Medium", "Large"] } + ] + } + + function test_textFromValue(data) { + var control = createTemporaryObject(data.component, testCase) + verify(control) + + for (var i = 0; i < data.values.length; ++i) { + control.value = data.values[i] + compare(control.value, data.values[i]) + compare(control.displayText, data.displayTexts[i]) + } + } } diff --git a/tests/manual/testbench/fonts/LICENSE.txt b/tests/manual/testbench/fonts/LICENSE.txt index 8fa3da36..8fa3da36 100755..100644 --- a/tests/manual/testbench/fonts/LICENSE.txt +++ b/tests/manual/testbench/fonts/LICENSE.txt diff --git a/tests/manual/testbench/fonts/fontawesome.ttf b/tests/manual/testbench/fonts/fontawesome.ttf Binary files differindex 49b6c5da..49b6c5da 100755..100644 --- a/tests/manual/testbench/fonts/fontawesome.ttf +++ b/tests/manual/testbench/fonts/fontawesome.ttf diff --git a/tests/tests.pro b/tests/tests.pro index e98339ef..0bf4ae1f 100644 --- a/tests/tests.pro +++ b/tests/tests.pro @@ -1,4 +1,4 @@ TEMPLATE = subdirs SUBDIRS += \ auto \ - benchmarks +# benchmarks |