diff options
Diffstat (limited to 'tests/auto/controls')
-rw-r--r-- | tests/auto/controls/data/tst_button.qml | 76 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_combobox.qml | 49 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_frame.qml | 26 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_groupbox.qml | 22 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_pane.qml | 26 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_toolbar.qml | 34 |
6 files changed, 144 insertions, 89 deletions
diff --git a/tests/auto/controls/data/tst_button.qml b/tests/auto/controls/data/tst_button.qml index 1faf1956..45fad8cb 100644 --- a/tests/auto/controls/data/tst_button.qml +++ b/tests/auto/controls/data/tst_button.qml @@ -163,86 +163,10 @@ TestCase { control.destroy() } - Component { - id: eventButton - Button { - property var lastPress - property var lastRelease - property var lastClick - property var lastDoubleClick - - function reset() { - lastPress = undefined - lastRelease = undefined - lastClick = undefined - lastDoubleClick = undefined - } - - onPressed: { lastPress = { x: mouse.x, y: mouse.y, button: mouse.button, buttons: mouse.buttons, modifiers: mouse.modifiers, wasHeld: mouse.wasHeld, isClick: mouse.isClick } } - onReleased: { lastRelease = { x: mouse.x, y: mouse.y, button: mouse.button, buttons: mouse.buttons, modifiers: mouse.modifiers, wasHeld: mouse.wasHeld, isClick: mouse.isClick } } - onClicked: { lastClick = { x: mouse.x, y: mouse.y, button: mouse.button, buttons: mouse.buttons, modifiers: mouse.modifiers, wasHeld: mouse.wasHeld, isClick: mouse.isClick } } - onDoubleClicked: { lastDoubleClick = { x: mouse.x, y: mouse.y, button: mouse.button, buttons: mouse.buttons, modifiers: mouse.modifiers, wasHeld: mouse.wasHeld, isClick: mouse.isClick } } - } - } - function eventErrorMessage(actual, expected) { return "actual event:" + JSON.stringify(actual) + ", expected event:" + JSON.stringify(expected) } - function test_events() { - var control = eventButton.createObject(testCase) - verify(control) - - control.forceActiveFocus() - verify(control.activeFocus) - - mousePress(control, control.width / 2, control.height / 2, Qt.LeftButton) - var expected = { x: Math.round(control.width / 2), y: Math.round(control.height / 2), button: Qt.LeftButton, buttons: Qt.LeftButton, modifiers: Qt.NoModifier, wasHeld: false, isClick: false } - compare(control.lastPress, expected, eventErrorMessage(control.lastPress, expected)) - compare(control.lastRelease, undefined) - compare(control.lastClick, undefined) - compare(control.lastDoubleClick, undefined) - - control.reset() - - mouseMove(control, control.width / 3, control.height / 3, Qt.LeftButton) - compare(control.lastPress, undefined) - compare(control.lastRelease, undefined) - compare(control.lastClick, undefined) - compare(control.lastDoubleClick, undefined) - - control.reset() - - mouseRelease(control, control.width / 4, control.height / 4, Qt.LeftButton) - compare(control.lastPress, undefined) - expected = { x: Math.round(control.width / 4), y: Math.round(control.height / 4), button: Qt.LeftButton, buttons: Qt.NoButton, modifiers: Qt.NoModifier, wasHeld: false, isClick: false } - compare(control.lastRelease, expected, eventErrorMessage(control.lastRelease, expected)) - expected = { x: Math.round(control.width / 4), y: Math.round(control.height / 4), button: Qt.LeftButton, buttons: Qt.NoButton, modifiers: Qt.NoModifier, wasHeld: false, isClick: true } - compare(control.lastClick, expected, eventErrorMessage(control.lastClick, expected)) - compare(control.lastDoubleClick, undefined) - - control.reset() - - keyPress(Qt.Key_Space) - expected = { x: Math.round(control.width / 2), y: Math.round(control.height / 2), button: Qt.NoButton, buttons: Qt.NoButton, modifiers: Qt.NoModifier, wasHeld: false, isClick: false } - compare(control.lastPress, expected, eventErrorMessage(control.lastPress, expected)) - compare(control.lastRelease, undefined) - compare(control.lastClick, undefined) - compare(control.lastDoubleClick, undefined) - - control.reset() - - keyRelease(Qt.Key_Space) - compare(control.lastPress, undefined) - expected = { x: Math.round(control.width / 2), y: Math.round(control.height / 2), button: Qt.NoButton, buttons: Qt.NoButton, modifiers: Qt.NoModifier, wasHeld: false, isClick: false } - compare(control.lastRelease, expected, eventErrorMessage(control.lastRelease, expected)) - expected = { x: Math.round(control.width / 2), y: Math.round(control.height / 2), button: Qt.NoButton, buttons: Qt.NoButton, modifiers: Qt.NoModifier, wasHeld: false, isClick: true } - compare(control.lastClick, expected, eventErrorMessage(control.lastClick, expected)) - compare(control.lastDoubleClick, undefined) - - control.destroy() - } - SignalSpy { id: clickSpy; signalName: "clicked" } function test_autoRepeat() { diff --git a/tests/auto/controls/data/tst_combobox.qml b/tests/auto/controls/data/tst_combobox.qml index d74c52aa..55ac3e8d 100644 --- a/tests/auto/controls/data/tst_combobox.qml +++ b/tests/auto/controls/data/tst_combobox.qml @@ -69,7 +69,7 @@ TestCase { id: comboBox ComboBox { delegate: ItemDelegate { - width: parent.width + width: popup.width } } } @@ -137,6 +137,36 @@ TestCase { control.destroy() } + function test_objects() { + var control = comboBox.createObject(window.contentItem) + verify(control) + + var items = [ + { text: "Apple" }, + { text: "Orange" }, + { text: "Banana" } + ] + + control.model = items + compare(control.model, items) + + compare(control.count, 3) + compare(control.currentIndex, 0) + compare(control.currentText, "Apple") + + control.currentIndex = 2 + compare(control.currentIndex, 2) + compare(control.currentText, "Banana") + + control.model = null + compare(control.model, null) + compare(control.count, 0) + compare(control.currentIndex, -1) + compare(control.currentText, "") + + control.destroy() + } + function test_number() { var control = comboBox.createObject(window.contentItem) verify(control) @@ -201,11 +231,24 @@ TestCase { ListElement { name: "Banana"; color: "yellow" } } - function test_textRole() { + property var fruitarray: [ + { name: "Apple", color: "red" }, + { name: "Orange", color: "orange" }, + { name: "Banana", color: "yellow" } + ] + + function test_textRole_data() { + return [ + { tag: "ListModel", model: fruitmodel }, + { tag: "ObjectArray", model: fruitarray } + ] + } + + function test_textRole(data) { var control = comboBox.createObject(window.contentItem) verify(control) - control.model = fruitmodel + control.model = data.model compare(control.count, 3) compare(control.currentIndex, 0) compare(control.currentText, "") diff --git a/tests/auto/controls/data/tst_frame.qml b/tests/auto/controls/data/tst_frame.qml index feb6cf11..d50a0dfc 100644 --- a/tests/auto/controls/data/tst_frame.qml +++ b/tests/auto/controls/data/tst_frame.qml @@ -57,7 +57,7 @@ TestCase { Component { id: oneChildFrame - GroupBox { + Frame { Item { implicitWidth: 100 implicitHeight: 30 @@ -67,7 +67,7 @@ TestCase { Component { id: twoChildrenFrame - GroupBox { + Frame { Item { implicitWidth: 100 implicitHeight: 30 @@ -79,6 +79,16 @@ TestCase { } } + Component { + id: contentFrame + Frame { + contentItem: Item { + implicitWidth: 100 + implicitHeight: 30 + } + } + } + function test_empty() { var control = frame.createObject(testCase) verify(control) @@ -113,4 +123,16 @@ TestCase { control.destroy() } + + function test_contentItem() { + var control = contentFrame.createObject(testCase) + verify(control) + + compare(control.contentWidth, 100) + compare(control.contentHeight, 30) + verify(control.implicitWidth > 100) + verify(control.implicitHeight > 30) + + control.destroy() + } } diff --git a/tests/auto/controls/data/tst_groupbox.qml b/tests/auto/controls/data/tst_groupbox.qml index 55568923..0f0e33fb 100644 --- a/tests/auto/controls/data/tst_groupbox.qml +++ b/tests/auto/controls/data/tst_groupbox.qml @@ -79,6 +79,16 @@ TestCase { } } + Component { + id: contentBox + GroupBox { + contentItem: Item { + implicitWidth: 100 + implicitHeight: 30 + } + } + } + function test_empty() { var control = groupBox.createObject(testCase) verify(control) @@ -113,4 +123,16 @@ TestCase { control.destroy() } + + function test_contentItem() { + var control = contentBox.createObject(testCase) + verify(control) + + compare(control.contentWidth, 100) + compare(control.contentHeight, 30) + verify(control.implicitWidth > 100) + verify(control.implicitHeight > 30) + + control.destroy() + } } diff --git a/tests/auto/controls/data/tst_pane.qml b/tests/auto/controls/data/tst_pane.qml index 18fd1cf0..1fdec049 100644 --- a/tests/auto/controls/data/tst_pane.qml +++ b/tests/auto/controls/data/tst_pane.qml @@ -57,7 +57,7 @@ TestCase { Component { id: oneChildPane - GroupBox { + Pane { Item { implicitWidth: 100 implicitHeight: 30 @@ -67,7 +67,7 @@ TestCase { Component { id: twoChildrenPane - GroupBox { + Pane { Item { implicitWidth: 100 implicitHeight: 30 @@ -80,6 +80,16 @@ TestCase { } Component { + id: contentPane + Pane { + contentItem: Item { + implicitWidth: 100 + implicitHeight: 30 + } + } + } + + Component { id: pressPane MouseArea { width: 200 @@ -127,6 +137,18 @@ TestCase { control.destroy() } + function test_contentItem() { + var control = contentPane.createObject(testCase) + verify(control) + + compare(control.contentWidth, 100) + compare(control.contentHeight, 30) + verify(control.implicitWidth > 100) + verify(control.implicitHeight > 30) + + control.destroy() + } + function test_press() { var control = pressPane.createObject(testCase) verify(control) diff --git a/tests/auto/controls/data/tst_toolbar.qml b/tests/auto/controls/data/tst_toolbar.qml index ac116a86..128aa403 100644 --- a/tests/auto/controls/data/tst_toolbar.qml +++ b/tests/auto/controls/data/tst_toolbar.qml @@ -57,7 +57,7 @@ TestCase { Component { id: oneChildBar - GroupBox { + ToolBar { Item { implicitWidth: 100 implicitHeight: 30 @@ -67,7 +67,7 @@ TestCase { Component { id: twoChildrenBar - GroupBox { + ToolBar { Item { implicitWidth: 100 implicitHeight: 30 @@ -79,6 +79,16 @@ TestCase { } } + Component { + id: contentBar + ToolBar { + contentItem: Item { + implicitWidth: 100 + implicitHeight: 30 + } + } + } + function test_empty() { var control = toolBar.createObject(testCase) verify(control) @@ -96,8 +106,8 @@ TestCase { compare(control.contentWidth, 100) compare(control.contentHeight, 30) - verify(control.implicitWidth > 100) - verify(control.implicitHeight > 30) + verify(control.implicitWidth >= 100) + verify(control.implicitHeight >= 30) control.destroy() } @@ -108,8 +118,20 @@ TestCase { compare(control.contentWidth, 0) compare(control.contentHeight, 0) - verify(control.implicitWidth > 0) - verify(control.implicitHeight > 0) + verify(control.implicitWidth >= 0) + verify(control.implicitHeight >= 0) + + control.destroy() + } + + function test_contentItem() { + var control = contentBar.createObject(testCase) + verify(control) + + compare(control.contentWidth, 100) + compare(control.contentHeight, 30) + verify(control.implicitWidth >= 100) + verify(control.implicitHeight >= 30) control.destroy() } |