diff options
Diffstat (limited to 'tests/auto/controls/data')
19 files changed, 1678 insertions, 41 deletions
diff --git a/tests/auto/controls/data/tst_abstractbutton.qml b/tests/auto/controls/data/tst_abstractbutton.qml index d611a45a..1ed5e45d 100644 --- a/tests/auto/controls/data/tst_abstractbutton.qml +++ b/tests/auto/controls/data/tst_abstractbutton.qml @@ -744,7 +744,7 @@ TestCase { } function test_trigger(data) { - var control = createTemporaryObject(actionButton, testCase, {"enabled": data.button, "action.enabled": data.action}) + var control = createTemporaryObject(actionButton, testCase, {"action.enabled": data.action, "enabled": data.button}) verify(control) compare(control.enabled, data.button) diff --git a/tests/auto/controls/data/tst_control.qml b/tests/auto/controls/data/tst_control.qml index a4d06fc1..5c66bd04 100644 --- a/tests/auto/controls/data/tst_control.qml +++ b/tests/auto/controls/data/tst_control.qml @@ -85,11 +85,42 @@ TestCase { var control = createTemporaryObject(component, testCase) verify(control) + var paddingSpy = createTemporaryObject(signalSpy, testCase, {target: control, signalName: "paddingChanged"}) + verify(paddingSpy.valid) + + var topPaddingSpy = createTemporaryObject(signalSpy, testCase, {target: control, signalName: "topPaddingChanged"}) + verify(topPaddingSpy.valid) + + var leftPaddingSpy = createTemporaryObject(signalSpy, testCase, {target: control, signalName: "leftPaddingChanged"}) + verify(leftPaddingSpy.valid) + + var rightPaddingSpy = createTemporaryObject(signalSpy, testCase, {target: control, signalName: "rightPaddingChanged"}) + verify(rightPaddingSpy.valid) + + var bottomPaddingSpy = createTemporaryObject(signalSpy, testCase, {target: control, signalName: "bottomPaddingChanged"}) + verify(bottomPaddingSpy.valid) + + var horizontalPaddingSpy = createTemporaryObject(signalSpy, testCase, {target: control, signalName: "horizontalPaddingChanged"}) + verify(horizontalPaddingSpy.valid) + + var verticalPaddingSpy = createTemporaryObject(signalSpy, testCase, {target: control, signalName: "verticalPaddingChanged"}) + verify(verticalPaddingSpy.valid) + + var paddingChanges = 0 + var topPaddingChanges = 0 + var leftPaddingChanges = 0 + var rightPaddingChanges = 0 + var bottomPaddingChanges = 0 + var horizontalPaddingChanges = 0 + var verticalPaddingChanges = 0 + compare(control.padding, 0) compare(control.topPadding, 0) compare(control.leftPadding, 0) compare(control.rightPadding, 0) compare(control.bottomPadding, 0) + compare(control.horizontalPadding, 0) + compare(control.verticalPadding, 0) compare(control.availableWidth, 0) compare(control.availableHeight, 0) @@ -102,6 +133,15 @@ TestCase { compare(control.leftPadding, 10) compare(control.rightPadding, 10) compare(control.bottomPadding, 10) + compare(control.horizontalPadding, 10) + compare(control.verticalPadding, 10) + compare(paddingSpy.count, ++paddingChanges) + compare(topPaddingSpy.count, ++topPaddingChanges) + compare(leftPaddingSpy.count, ++leftPaddingChanges) + compare(rightPaddingSpy.count, ++rightPaddingChanges) + compare(bottomPaddingSpy.count, ++bottomPaddingChanges) + compare(horizontalPaddingSpy.count, ++horizontalPaddingChanges) + compare(verticalPaddingSpy.count, ++verticalPaddingChanges) control.topPadding = 20 compare(control.padding, 10) @@ -109,6 +149,15 @@ TestCase { compare(control.leftPadding, 10) compare(control.rightPadding, 10) compare(control.bottomPadding, 10) + compare(control.horizontalPadding, 10) + compare(control.verticalPadding, 10) + compare(paddingSpy.count, paddingChanges) + compare(topPaddingSpy.count, ++topPaddingChanges) + compare(leftPaddingSpy.count, leftPaddingChanges) + compare(rightPaddingSpy.count, rightPaddingChanges) + compare(bottomPaddingSpy.count, bottomPaddingChanges) + compare(horizontalPaddingSpy.count, horizontalPaddingChanges) + compare(verticalPaddingSpy.count, verticalPaddingChanges) control.leftPadding = 30 compare(control.padding, 10) @@ -116,6 +165,15 @@ TestCase { compare(control.leftPadding, 30) compare(control.rightPadding, 10) compare(control.bottomPadding, 10) + compare(control.horizontalPadding, 10) + compare(control.verticalPadding, 10) + compare(paddingSpy.count, paddingChanges) + compare(topPaddingSpy.count, topPaddingChanges) + compare(leftPaddingSpy.count, ++leftPaddingChanges) + compare(rightPaddingSpy.count, rightPaddingChanges) + compare(bottomPaddingSpy.count, bottomPaddingChanges) + compare(horizontalPaddingSpy.count, horizontalPaddingChanges) + compare(verticalPaddingSpy.count, verticalPaddingChanges) control.rightPadding = 40 compare(control.padding, 10) @@ -123,6 +181,15 @@ TestCase { compare(control.leftPadding, 30) compare(control.rightPadding, 40) compare(control.bottomPadding, 10) + compare(control.horizontalPadding, 10) + compare(control.verticalPadding, 10) + compare(paddingSpy.count, paddingChanges) + compare(topPaddingSpy.count, topPaddingChanges) + compare(leftPaddingSpy.count, leftPaddingChanges) + compare(rightPaddingSpy.count, ++rightPaddingChanges) + compare(bottomPaddingSpy.count, bottomPaddingChanges) + compare(horizontalPaddingSpy.count, horizontalPaddingChanges) + compare(verticalPaddingSpy.count, verticalPaddingChanges) control.bottomPadding = 50 compare(control.padding, 10) @@ -130,6 +197,15 @@ TestCase { compare(control.leftPadding, 30) compare(control.rightPadding, 40) compare(control.bottomPadding, 50) + compare(control.horizontalPadding, 10) + compare(control.verticalPadding, 10) + compare(paddingSpy.count, paddingChanges) + compare(topPaddingSpy.count, topPaddingChanges) + compare(leftPaddingSpy.count, leftPaddingChanges) + compare(rightPaddingSpy.count, rightPaddingChanges) + compare(bottomPaddingSpy.count, ++bottomPaddingChanges) + compare(horizontalPaddingSpy.count, horizontalPaddingChanges) + compare(verticalPaddingSpy.count, verticalPaddingChanges) control.padding = 60 compare(control.padding, 60) @@ -137,6 +213,143 @@ TestCase { compare(control.leftPadding, 30) compare(control.rightPadding, 40) compare(control.bottomPadding, 50) + compare(control.horizontalPadding, 60) + compare(control.verticalPadding, 60) + compare(paddingSpy.count, ++paddingChanges) + compare(topPaddingSpy.count, topPaddingChanges) + compare(leftPaddingSpy.count, leftPaddingChanges) + compare(rightPaddingSpy.count, rightPaddingChanges) + compare(bottomPaddingSpy.count, bottomPaddingChanges) + compare(horizontalPaddingSpy.count, ++horizontalPaddingChanges) + compare(verticalPaddingSpy.count, ++verticalPaddingChanges) + + control.horizontalPadding = 80 + compare(control.padding, 60) + compare(control.topPadding, 20) + compare(control.leftPadding, 30) + compare(control.rightPadding, 40) + compare(control.bottomPadding, 50) + compare(control.horizontalPadding, 80) + compare(control.verticalPadding, 60) + compare(paddingSpy.count, paddingChanges) + compare(topPaddingSpy.count, topPaddingChanges) + compare(leftPaddingSpy.count, leftPaddingChanges) + compare(rightPaddingSpy.count, rightPaddingChanges) + compare(bottomPaddingSpy.count, bottomPaddingChanges) + compare(horizontalPaddingSpy.count, ++horizontalPaddingChanges) + compare(verticalPaddingSpy.count, verticalPaddingChanges) + + control.verticalPadding = 90 + compare(control.padding, 60) + compare(control.topPadding, 20) + compare(control.leftPadding, 30) + compare(control.rightPadding, 40) + compare(control.bottomPadding, 50) + compare(control.horizontalPadding, 80) + compare(control.verticalPadding, 90) + compare(paddingSpy.count, paddingChanges) + compare(topPaddingSpy.count, topPaddingChanges) + compare(leftPaddingSpy.count, leftPaddingChanges) + compare(rightPaddingSpy.count, rightPaddingChanges) + compare(bottomPaddingSpy.count, bottomPaddingChanges) + compare(horizontalPaddingSpy.count, horizontalPaddingChanges) + compare(verticalPaddingSpy.count, ++verticalPaddingChanges) + + control.leftPadding = undefined + compare(control.padding, 60) + compare(control.topPadding, 20) + compare(control.leftPadding, 80) + compare(control.rightPadding, 40) + compare(control.bottomPadding, 50) + compare(control.horizontalPadding, 80) + compare(control.verticalPadding, 90) + compare(paddingSpy.count, paddingChanges) + compare(topPaddingSpy.count, topPaddingChanges) + compare(leftPaddingSpy.count, ++leftPaddingChanges) + compare(rightPaddingSpy.count, rightPaddingChanges) + compare(bottomPaddingSpy.count, bottomPaddingChanges) + compare(horizontalPaddingSpy.count, horizontalPaddingChanges) + compare(verticalPaddingSpy.count, verticalPaddingChanges) + + control.rightPadding = undefined + compare(control.padding, 60) + compare(control.topPadding, 20) + compare(control.leftPadding, 80) + compare(control.rightPadding, 80) + compare(control.bottomPadding, 50) + compare(control.horizontalPadding, 80) + compare(control.verticalPadding, 90) + compare(paddingSpy.count, paddingChanges) + compare(topPaddingSpy.count, topPaddingChanges) + compare(leftPaddingSpy.count, leftPaddingChanges) + compare(rightPaddingSpy.count, ++rightPaddingChanges) + compare(bottomPaddingSpy.count, bottomPaddingChanges) + compare(horizontalPaddingSpy.count, horizontalPaddingChanges) + compare(verticalPaddingSpy.count, verticalPaddingChanges) + + control.topPadding = undefined + compare(control.padding, 60) + compare(control.topPadding, 90) + compare(control.leftPadding, 80) + compare(control.rightPadding, 80) + compare(control.bottomPadding, 50) + compare(control.horizontalPadding, 80) + compare(control.verticalPadding, 90) + compare(paddingSpy.count, paddingChanges) + compare(topPaddingSpy.count, ++topPaddingChanges) + compare(leftPaddingSpy.count, leftPaddingChanges) + compare(rightPaddingSpy.count, rightPaddingChanges) + compare(bottomPaddingSpy.count, bottomPaddingChanges) + compare(horizontalPaddingSpy.count, horizontalPaddingChanges) + compare(verticalPaddingSpy.count, verticalPaddingChanges) + + control.bottomPadding = undefined + compare(control.padding, 60) + compare(control.topPadding, 90) + compare(control.leftPadding, 80) + compare(control.rightPadding, 80) + compare(control.bottomPadding, 90) + compare(control.horizontalPadding, 80) + compare(control.verticalPadding, 90) + compare(paddingSpy.count, paddingChanges) + compare(topPaddingSpy.count, topPaddingChanges) + compare(leftPaddingSpy.count, leftPaddingChanges) + compare(rightPaddingSpy.count, rightPaddingChanges) + compare(bottomPaddingSpy.count, ++bottomPaddingChanges) + compare(horizontalPaddingSpy.count, horizontalPaddingChanges) + compare(verticalPaddingSpy.count, verticalPaddingChanges) + + control.horizontalPadding = undefined + compare(control.padding, 60) + compare(control.topPadding, 90) + compare(control.leftPadding, 60) + compare(control.rightPadding, 60) + compare(control.bottomPadding, 90) + compare(control.horizontalPadding, 60) + compare(control.verticalPadding, 90) + compare(paddingSpy.count, paddingChanges) + compare(topPaddingSpy.count, topPaddingChanges) + compare(leftPaddingSpy.count, ++leftPaddingChanges) + compare(rightPaddingSpy.count, ++rightPaddingChanges) + compare(bottomPaddingSpy.count, bottomPaddingChanges) + compare(horizontalPaddingSpy.count, ++horizontalPaddingChanges) + compare(verticalPaddingSpy.count, verticalPaddingChanges) + + control.verticalPadding = undefined + compare(control.padding, 60) + compare(control.topPadding, 60) + compare(control.leftPadding, 60) + compare(control.rightPadding, 60) + compare(control.bottomPadding, 60) + compare(control.horizontalPadding, 60) + compare(control.verticalPadding, 60) + compare(paddingSpy.count, paddingChanges) + compare(topPaddingSpy.count, ++topPaddingChanges) + compare(leftPaddingSpy.count, leftPaddingChanges) + compare(rightPaddingSpy.count, rightPaddingChanges) + compare(bottomPaddingSpy.count, ++bottomPaddingChanges) + compare(horizontalPaddingSpy.count, horizontalPaddingChanges) + compare(verticalPaddingSpy.count, ++verticalPaddingChanges) } function test_availableSize() { @@ -252,6 +465,12 @@ TestCase { compare(control.background.height, control.height) control.height = 240 + // change implicit size (QTBUG-66455) + control.background.implicitWidth = 160 + control.background.implicitHeight = 120 + compare(control.background.width, control.width) + compare(control.background.height, control.height) + // has width => width does not follow control.background.width /= 2 control.width += 20 @@ -921,19 +1140,278 @@ TestCase { var control = createTemporaryObject(component, testCase) verify(control) + var implicitWidthSpy = createTemporaryObject(signalSpy, testCase, {target: control, signalName: "implicitWidthChanged"}) + verify(implicitWidthSpy.valid) + + var implicitHeightSpy = createTemporaryObject(signalSpy, testCase, {target: control, signalName: "implicitHeightChanged"}) + verify(implicitHeightSpy.valid) + + var implicitContentWidthSpy = createTemporaryObject(signalSpy, testCase, {target: control, signalName: "implicitContentWidthChanged"}) + verify(implicitContentWidthSpy.valid) + + var implicitContentHeightSpy = createTemporaryObject(signalSpy, testCase, {target: control, signalName: "implicitContentHeightChanged"}) + verify(implicitContentHeightSpy.valid) + + var implicitBackgroundWidthSpy = createTemporaryObject(signalSpy, testCase, {target: control, signalName: "implicitBackgroundWidthChanged"}) + verify(implicitBackgroundWidthSpy.valid) + + var implicitBackgroundHeightSpy = createTemporaryObject(signalSpy, testCase, {target: control, signalName: "implicitBackgroundHeightChanged"}) + verify(implicitBackgroundHeightSpy.valid) + + var implicitWidthChanges = 0 + var implicitHeightChanges = 0 + var implicitContentWidthChanges = 0 + var implicitContentHeightChanges = 0 + var implicitBackgroundWidthChanges = 0 + var implicitBackgroundHeightChanges = 0 + compare(control.implicitWidth, 0) compare(control.implicitHeight, 0) + compare(control.implicitContentWidth, 0) + compare(control.implicitContentHeight, 0) + compare(control.implicitBackgroundWidth, 0) + compare(control.implicitBackgroundHeight, 0) control.contentItem = rectangle.createObject(control, {implicitWidth: 10, implicitHeight: 20}) compare(control.implicitWidth, 10) compare(control.implicitHeight, 20) + compare(control.implicitContentWidth, 10) + compare(control.implicitContentHeight, 20) + compare(control.implicitBackgroundWidth, 0) + compare(control.implicitBackgroundHeight, 0) + compare(implicitWidthSpy.count, ++implicitWidthChanges) + compare(implicitHeightSpy.count, ++implicitHeightChanges) + compare(implicitBackgroundWidthSpy.count, implicitBackgroundWidthChanges) + compare(implicitBackgroundHeightSpy.count, implicitBackgroundHeightChanges) + compare(implicitContentWidthSpy.count, ++implicitContentWidthChanges) + compare(implicitContentHeightSpy.count, ++implicitContentHeightChanges) + + control.contentItem.implicitWidth += 1 + control.contentItem.implicitHeight += 1 + compare(control.implicitWidth, 11) + compare(control.implicitHeight, 21) + compare(control.implicitContentWidth, 11) + compare(control.implicitContentHeight, 21) + compare(control.implicitBackgroundWidth, 0) + compare(control.implicitBackgroundHeight, 0) + compare(implicitWidthSpy.count, ++implicitWidthChanges) + compare(implicitHeightSpy.count, ++implicitHeightChanges) + compare(implicitContentWidthSpy.count, ++implicitContentWidthChanges) + compare(implicitContentHeightSpy.count, ++implicitContentHeightChanges) + compare(implicitBackgroundWidthSpy.count, implicitBackgroundWidthChanges) + compare(implicitBackgroundHeightSpy.count, implicitBackgroundHeightChanges) control.background = rectangle.createObject(control, {implicitWidth: 20, implicitHeight: 30}) compare(control.implicitWidth, 20) compare(control.implicitHeight, 30) + compare(control.implicitContentWidth,11) + compare(control.implicitContentHeight, 21) + compare(control.implicitBackgroundWidth, 20) + compare(control.implicitBackgroundHeight, 30) + compare(implicitWidthSpy.count, ++implicitWidthChanges) + compare(implicitHeightSpy.count, ++implicitHeightChanges) + compare(implicitContentWidthSpy.count, implicitContentWidthChanges) + compare(implicitContentHeightSpy.count, implicitContentHeightChanges) + compare(implicitBackgroundWidthSpy.count, ++implicitBackgroundWidthChanges) + compare(implicitBackgroundHeightSpy.count, ++implicitBackgroundHeightChanges) + + control.background.implicitWidth += 1 + control.background.implicitHeight += 1 + compare(control.implicitWidth, 21) + compare(control.implicitHeight, 31) + compare(control.implicitContentWidth, 11) + compare(control.implicitContentHeight, 21) + compare(control.implicitBackgroundWidth, 21) + compare(control.implicitBackgroundHeight, 31) + compare(implicitWidthSpy.count, ++implicitWidthChanges) + compare(implicitHeightSpy.count, ++implicitHeightChanges) + compare(implicitContentWidthSpy.count, implicitContentWidthChanges) + compare(implicitContentHeightSpy.count, implicitContentHeightChanges) + compare(implicitBackgroundWidthSpy.count, ++implicitBackgroundWidthChanges) + compare(implicitBackgroundHeightSpy.count, ++implicitBackgroundHeightChanges) + } + + function test_baseline() { + var control = createTemporaryObject(component, testCase) + verify(control) + + compare(control.baselineOffset, 0) + + var baselineSpy = signalSpy.createObject(control, {target: control, signalName: "baselineOffsetChanged"}) + verify(baselineSpy.valid) + + control.contentItem = rectangle.createObject(control, {baselineOffset: 12}) + compare(control.baselineOffset, 12) + compare(baselineSpy.count, 1) + + control.padding = 6 + compare(control.baselineOffset, 18) + compare(baselineSpy.count, 2) - control.padding = 100 - compare(control.implicitWidth, 210) - compare(control.implicitHeight, 220) + control.baselineOffset = 3 + compare(control.baselineOffset, 3) + compare(baselineSpy.count, 3) + + control.padding = 9 + compare(control.baselineOffset, 3) + compare(baselineSpy.count, 3) + + control.baselineOffset = undefined + compare(control.baselineOffset, 21) + compare(baselineSpy.count, 4) + + control.contentItem.baselineOffset = 3 + compare(control.baselineOffset, 12) + compare(baselineSpy.count, 5) + + control.contentItem = null + compare(control.baselineOffset, 0) + compare(baselineSpy.count, 6) + } + + function test_inset() { + var control = createTemporaryObject(component, testCase, {background: rectangle.createObject(control)}) + verify(control) + + var topInsetSpy = createTemporaryObject(signalSpy, testCase, {target: control, signalName: "topInsetChanged"}) + verify(topInsetSpy.valid) + + var leftInsetSpy = createTemporaryObject(signalSpy, testCase, {target: control, signalName: "leftInsetChanged"}) + verify(leftInsetSpy.valid) + + var rightInsetSpy = createTemporaryObject(signalSpy, testCase, {target: control, signalName: "rightInsetChanged"}) + verify(rightInsetSpy.valid) + + var bottomInsetSpy = createTemporaryObject(signalSpy, testCase, {target: control, signalName: "bottomInsetChanged"}) + verify(bottomInsetSpy.valid) + + var topInsetChanges = 0 + var leftInsetChanges = 0 + var rightInsetChanges = 0 + var bottomInsetChanges = 0 + + compare(control.topInset, 0) + compare(control.leftInset, 0) + compare(control.rightInset, 0) + compare(control.bottomInset, 0) + + control.width = 100 + control.height = 100 + compare(control.background.x, 0) + compare(control.background.y, 0) + compare(control.background.width, 100) + compare(control.background.height, 100) + + control.topInset = 10 + compare(control.topInset, 10) + compare(control.leftInset, 0) + compare(control.rightInset, 0) + compare(control.bottomInset, 0) + compare(topInsetSpy.count, ++topInsetChanges) + compare(leftInsetSpy.count, leftInsetChanges) + compare(rightInsetSpy.count, rightInsetChanges) + compare(bottomInsetSpy.count, bottomInsetChanges) + compare(control.background.x, 0) + compare(control.background.y, 10) + compare(control.background.width, 100) + compare(control.background.height, 90) + + control.leftInset = 20 + compare(control.topInset, 10) + compare(control.leftInset, 20) + compare(control.rightInset, 0) + compare(control.bottomInset, 0) + compare(topInsetSpy.count, topInsetChanges) + compare(leftInsetSpy.count, ++leftInsetChanges) + compare(rightInsetSpy.count, rightInsetChanges) + compare(bottomInsetSpy.count, bottomInsetChanges) + compare(control.background.x, 20) + compare(control.background.y, 10) + compare(control.background.width, 80) + compare(control.background.height, 90) + + control.rightInset = 30 + compare(control.topInset, 10) + compare(control.leftInset, 20) + compare(control.rightInset, 30) + compare(control.bottomInset, 0) + compare(topInsetSpy.count, topInsetChanges) + compare(leftInsetSpy.count, leftInsetChanges) + compare(rightInsetSpy.count, ++rightInsetChanges) + compare(bottomInsetSpy.count, bottomInsetChanges) + compare(control.background.x, 20) + compare(control.background.y, 10) + compare(control.background.width, 50) + compare(control.background.height, 90) + + control.bottomInset = 40 + compare(control.topInset, 10) + compare(control.leftInset, 20) + compare(control.rightInset, 30) + compare(control.bottomInset, 40) + compare(topInsetSpy.count, topInsetChanges) + compare(leftInsetSpy.count, leftInsetChanges) + compare(rightInsetSpy.count, rightInsetChanges) + compare(bottomInsetSpy.count, ++bottomInsetChanges) + compare(control.background.x, 20) + compare(control.background.y, 10) + compare(control.background.width, 50) + compare(control.background.height, 50) + + control.topInset = undefined + compare(control.topInset, 0) + compare(control.leftInset, 20) + compare(control.rightInset, 30) + compare(control.bottomInset, 40) + compare(topInsetSpy.count, ++topInsetChanges) + compare(leftInsetSpy.count, leftInsetChanges) + compare(rightInsetSpy.count, rightInsetChanges) + compare(bottomInsetSpy.count, bottomInsetChanges) + compare(control.background.x, 20) + compare(control.background.y, 0) + compare(control.background.width, 50) + compare(control.background.height, 60) + + control.leftInset = undefined + compare(control.topInset, 0) + compare(control.leftInset, 0) + compare(control.rightInset, 30) + compare(control.bottomInset, 40) + compare(topInsetSpy.count, topInsetChanges) + compare(leftInsetSpy.count, ++leftInsetChanges) + compare(rightInsetSpy.count, rightInsetChanges) + compare(bottomInsetSpy.count, bottomInsetChanges) + compare(control.background.x, 0) + compare(control.background.y, 0) + compare(control.background.width, 70) + compare(control.background.height, 60) + + control.rightInset = undefined + compare(control.topInset, 0) + compare(control.leftInset, 0) + compare(control.rightInset, 0) + compare(control.bottomInset, 40) + compare(topInsetSpy.count, topInsetChanges) + compare(leftInsetSpy.count, leftInsetChanges) + compare(rightInsetSpy.count, ++rightInsetChanges) + compare(bottomInsetSpy.count, bottomInsetChanges) + compare(control.background.x, 0) + compare(control.background.y, 0) + compare(control.background.width, 100) + compare(control.background.height, 60) + + control.bottomInset = undefined + compare(control.topInset, 0) + compare(control.leftInset, 0) + compare(control.rightInset, 0) + compare(control.bottomInset, 0) + compare(topInsetSpy.count, topInsetChanges) + compare(leftInsetSpy.count, leftInsetChanges) + compare(rightInsetSpy.count, rightInsetChanges) + compare(bottomInsetSpy.count, ++bottomInsetChanges) + compare(control.background.x, 0) + compare(control.background.y, 0) + compare(control.background.width, 100) + compare(control.background.height, 100) } } diff --git a/tests/auto/controls/data/tst_dial.qml b/tests/auto/controls/data/tst_dial.qml index 33b0dbea..a2d32347 100644 --- a/tests/auto/controls/data/tst_dial.qml +++ b/tests/auto/controls/data/tst_dial.qml @@ -54,15 +54,19 @@ import QtQuick.Controls 2.2 TestCase { id: testCase - width: 200 - height: 200 + width: 450 + height: 450 visible: true when: windowShown name: "Dial" Component { id: dialComponent - Dial {} + Dial { + width: 100 + height: 100 + anchors.centerIn: parent + } } Component { @@ -592,4 +596,93 @@ TestCase { mouseRelease(control) compare(control.pressed, false) } + + function move(inputEventType, control, x, y) { + if (inputEventType === "mouseInput") { + mouseMove(control, x, y); + } else { + var touch = touchEvent(control); + touch.move(0, control, x, y).commit(); + } + } + + function press(inputEventType, control, x, y) { + if (inputEventType === "mouseInput") { + mousePress(control, x, y); + } else { + var touch = touchEvent(control); + touch.press(0, control, x, y).commit(); + } + } + + function release(inputEventType, control, x, y) { + if (inputEventType === "mouseInput") { + mouseRelease(control, x, y); + } else { + var touch = touchEvent(control); + touch.release(0, control, x, y).commit(); + } + } + + function test_horizontalAndVertical_data() { + var data = [ + { eventType: "mouseInput", inputMode: Dial.Vertical, moveToX: 0.5, moveToY: 0.25, expectedPosition: 0.125 }, + // Horizontal movement should have no effect on a vertical dial. + { eventType: "mouseInput", inputMode: Dial.Vertical, moveToX: 2.0, moveToY: 0.25, expectedPosition: 0.125 }, + { eventType: "mouseInput", inputMode: Dial.Vertical, moveToX: 0.5, moveToY: 0.0, expectedPosition: 0.25 }, + { eventType: "mouseInput", inputMode: Dial.Vertical, moveToX: 0.5, moveToY: -1.5, expectedPosition: 1.0 }, + // Going above the drag area shouldn't make the position higher than 1.0. + { eventType: "mouseInput", inputMode: Dial.Vertical, moveToX: 0.5, moveToY: -2.0, expectedPosition: 1.0 }, + // Try to decrease the position by moving the mouse down. + // The dial's position is 0 before the press event, so nothing should happen. + { eventType: "mouseInput", inputMode: Dial.Vertical, moveToX: 0.5, moveToY: 1.25, expectedPosition: 0.0 }, + + { eventType: "mouseInput", inputMode: Dial.Horizontal, moveToX: 0.75, moveToY: 0.5, expectedPosition: 0.125 }, + // Vertical movement should have no effect on a horizontal dial. + { eventType: "mouseInput", inputMode: Dial.Horizontal, moveToX: 0.75, moveToY: 2.0, expectedPosition: 0.125 }, + { eventType: "mouseInput", inputMode: Dial.Horizontal, moveToX: 1.0, moveToY: 0.5, expectedPosition: 0.25 }, + { eventType: "mouseInput", inputMode: Dial.Horizontal, moveToX: 1.5, moveToY: 0.5, expectedPosition: 0.5 }, + { eventType: "mouseInput", inputMode: Dial.Horizontal, moveToX: 2.5, moveToY: 0.5, expectedPosition: 1.0 }, + // Going above the drag area shouldn't make the position higher than 1.0. + { eventType: "mouseInput", inputMode: Dial.Horizontal, moveToX: 2.525, moveToY: 0.5, expectedPosition: 1.0 }, + // Try to decrease the position by moving the mouse to the left. + // The dial's position is 0 before the press event, so nothing should happen. + { eventType: "mouseInput", inputMode: Dial.Vertical, moveToX: 0.25, moveToY: 0.5, expectedPosition: 0.0 } + ]; + + // Do the same tests for touch by copying the mouse tests and adding them to the end of the array. + var mouseTestCount = data.length; + for (var i = mouseTestCount; i < mouseTestCount * 2; ++i) { + // Shallow-copy the object. + data[i] = JSON.parse(JSON.stringify(data[i - mouseTestCount])); + data[i].eventType = "touchInput"; + } + + for (i = 0; i < data.length; ++i) { + var row = data[i]; + row.tag = "eventType=" + row.eventType + ", " + + "inputMode=" + (row.inputMode === Dial.Vertical ? "Vertical" : "Horizontal") + ", " + + "moveToX=" + row.moveToX + ", moveToY=" + row.moveToY + ", " + + "expectedPosition=" + row.expectedPosition; + } + + return data; + } + + function test_horizontalAndVertical(data) { + var control = createTemporaryObject(dialComponent, testCase, { inputMode: data.inputMode }); + verify(control); + + press(data.eventType, control); + compare(control.pressed, true); + // The position shouldn't change until the mouse has actually moved. + compare(control.position, 0); + + move(data.eventType, control, control.width * data.moveToX, control.width * data.moveToY); + compare(control.position, data.expectedPosition); + + release(data.eventType, control, control.width * data.moveToX, control.width * data.moveToY); + compare(control.pressed, false); + compare(control.position, data.expectedPosition); + } } diff --git a/tests/auto/controls/data/tst_dialogbuttonbox.qml b/tests/auto/controls/data/tst_dialogbuttonbox.qml index 6faf0db4..ed181c5b 100644 --- a/tests/auto/controls/data/tst_dialogbuttonbox.qml +++ b/tests/auto/controls/data/tst_dialogbuttonbox.qml @@ -196,6 +196,31 @@ TestCase { compare(roleSpy.count, 1) } + function test_buttonLayout_data() { + return [ + { tag: "WinLayout", buttonLayout: DialogButtonBox.WinLayout, button1Role: DialogButtonBox.AcceptRole, button2Role: DialogButtonBox.RejectRole }, + { tag: "MacLayout", buttonLayout: DialogButtonBox.MacLayout, button1Role: DialogButtonBox.RejectRole, button2Role: DialogButtonBox.AcceptRole }, + { tag: "KdeLayout", buttonLayout: DialogButtonBox.KdeLayout, button1Role: DialogButtonBox.AcceptRole, button2Role: DialogButtonBox.RejectRole }, + { tag: "GnomeLayout", buttonLayout: DialogButtonBox.GnomeLayout, button1Role: DialogButtonBox.RejectRole, button2Role: DialogButtonBox.AcceptRole }, + { tag: "AndroidLayout", buttonLayout: DialogButtonBox.AndroidLayout, button1Role: DialogButtonBox.RejectRole, button2Role: DialogButtonBox.AcceptRole } + ] + } + + function test_buttonLayout(data) { + var control = createTemporaryObject(buttonBox, testCase, {buttonLayout: data.buttonLayout, standardButtons: DialogButtonBox.Ok|DialogButtonBox.Cancel}) + verify(control) + + compare(control.count, 2) + + var button1 = control.itemAt(0) + verify(button1) + compare(button1.DialogButtonBox.buttonRole, data.button1Role) + + var button2 = control.itemAt(1) + verify(button2) + compare(button2.DialogButtonBox.buttonRole, data.button2Role) + } + function test_implicitSize_data() { return [ { tag: "Ok", standardButtons: DialogButtonBox.Ok }, @@ -223,4 +248,31 @@ TestCase { verify(implicitContentWidth > control.leftPadding + control.rightPadding) verify(control.implicitWidth >= implicitContentWidth, qsTr("implicit width (%1) is less than content width (%2)").arg(control.implicitWidth).arg(implicitContentWidth)) } + + Component { + id: okCancelBox + DialogButtonBox { + Button { + text: qsTr("OK") + } + Button { + text: qsTr("Cancel") + } + } + } + + function test_buttonSize() { + var control = createTemporaryObject(okCancelBox, testCase) + verify(control) + + var okButton = control.itemAt(0) + verify(okButton) + verify(okButton.width > 0) + + var cancelButton = control.itemAt(1) + verify(cancelButton) + verify(cancelButton.width > 0) + + compare(okButton.width + cancelButton.width, control.availableWidth - control.spacing) + } } diff --git a/tests/auto/controls/data/tst_frame.qml b/tests/auto/controls/data/tst_frame.qml index c6ecdb43..95838155 100644 --- a/tests/auto/controls/data/tst_frame.qml +++ b/tests/auto/controls/data/tst_frame.qml @@ -106,6 +106,8 @@ TestCase { verify(control.contentItem) compare(control.contentWidth, 0) compare(control.contentHeight, 0) + compare(control.implicitContentWidth, 0) + compare(control.implicitContentHeight, 0) } function test_oneChild() { @@ -114,6 +116,8 @@ TestCase { compare(control.contentWidth, 100) compare(control.contentHeight, 30) + compare(control.implicitContentWidth, 100) + compare(control.implicitContentHeight, 30) verify(control.implicitWidth > 100) verify(control.implicitHeight > 30) } @@ -124,6 +128,8 @@ TestCase { compare(control.contentWidth, 0) compare(control.contentHeight, 0) + compare(control.implicitContentWidth, 0) + compare(control.implicitContentHeight, 0) verify(control.implicitWidth > 0) verify(control.implicitHeight > 0) } @@ -134,6 +140,8 @@ TestCase { compare(control.contentWidth, 100) compare(control.contentHeight, 30) + compare(control.implicitContentWidth, 100) + compare(control.implicitContentHeight, 30) verify(control.implicitWidth > 100) verify(control.implicitHeight > 30) } diff --git a/tests/auto/controls/data/tst_groupbox.qml b/tests/auto/controls/data/tst_groupbox.qml index 28de0479..446283d8 100644 --- a/tests/auto/controls/data/tst_groupbox.qml +++ b/tests/auto/controls/data/tst_groupbox.qml @@ -106,6 +106,8 @@ TestCase { verify(control.contentItem) compare(control.contentWidth, 0) compare(control.contentHeight, 0) + compare(control.implicitContentWidth, 0) + compare(control.implicitContentHeight, 0) } function test_oneChild() { @@ -114,6 +116,8 @@ TestCase { compare(control.contentWidth, 100) compare(control.contentHeight, 30) + compare(control.implicitContentWidth, 100) + compare(control.implicitContentHeight, 30) verify(control.implicitWidth > 100) verify(control.implicitHeight > 30) } @@ -124,6 +128,8 @@ TestCase { compare(control.contentWidth, 0) compare(control.contentHeight, 0) + compare(control.implicitContentWidth, 0) + compare(control.implicitContentHeight, 0) verify(control.implicitWidth > 0) verify(control.implicitHeight > 0) } @@ -134,6 +140,8 @@ TestCase { compare(control.contentWidth, 100) compare(control.contentHeight, 30) + compare(control.implicitContentWidth, 100) + compare(control.implicitContentHeight, 30) verify(control.implicitWidth > 100) verify(control.implicitHeight > 30) } diff --git a/tests/auto/controls/data/tst_label.qml b/tests/auto/controls/data/tst_label.qml index 69d273a7..8183f088 100644 --- a/tests/auto/controls/data/tst_label.qml +++ b/tests/auto/controls/data/tst_label.qml @@ -138,5 +138,157 @@ TestCase { control.background = rectangle.createObject(control) compare(control.background.width, control.width) compare(control.background.height, control.height) + + // change implicit size (QTBUG-66455) + control.background.implicitWidth = 160 + control.background.implicitHeight = 120 + compare(control.background.width, control.width) + compare(control.background.height, control.height) + } + + function test_inset() { + var control = createTemporaryObject(label, testCase, {background: rectangle.createObject(control)}) + verify(control) + + var topInsetSpy = createTemporaryObject(signalSpy, testCase, {target: control, signalName: "topInsetChanged"}) + verify(topInsetSpy.valid) + + var leftInsetSpy = createTemporaryObject(signalSpy, testCase, {target: control, signalName: "leftInsetChanged"}) + verify(leftInsetSpy.valid) + + var rightInsetSpy = createTemporaryObject(signalSpy, testCase, {target: control, signalName: "rightInsetChanged"}) + verify(rightInsetSpy.valid) + + var bottomInsetSpy = createTemporaryObject(signalSpy, testCase, {target: control, signalName: "bottomInsetChanged"}) + verify(bottomInsetSpy.valid) + + var topInsetChanges = 0 + var leftInsetChanges = 0 + var rightInsetChanges = 0 + var bottomInsetChanges = 0 + + compare(control.topInset, 0) + compare(control.leftInset, 0) + compare(control.rightInset, 0) + compare(control.bottomInset, 0) + + control.width = 100 + control.height = 100 + compare(control.background.x, 0) + compare(control.background.y, 0) + compare(control.background.width, 100) + compare(control.background.height, 100) + + control.topInset = 10 + compare(control.topInset, 10) + compare(control.leftInset, 0) + compare(control.rightInset, 0) + compare(control.bottomInset, 0) + compare(topInsetSpy.count, ++topInsetChanges) + compare(leftInsetSpy.count, leftInsetChanges) + compare(rightInsetSpy.count, rightInsetChanges) + compare(bottomInsetSpy.count, bottomInsetChanges) + compare(control.background.x, 0) + compare(control.background.y, 10) + compare(control.background.width, 100) + compare(control.background.height, 90) + + control.leftInset = 20 + compare(control.topInset, 10) + compare(control.leftInset, 20) + compare(control.rightInset, 0) + compare(control.bottomInset, 0) + compare(topInsetSpy.count, topInsetChanges) + compare(leftInsetSpy.count, ++leftInsetChanges) + compare(rightInsetSpy.count, rightInsetChanges) + compare(bottomInsetSpy.count, bottomInsetChanges) + compare(control.background.x, 20) + compare(control.background.y, 10) + compare(control.background.width, 80) + compare(control.background.height, 90) + + control.rightInset = 30 + compare(control.topInset, 10) + compare(control.leftInset, 20) + compare(control.rightInset, 30) + compare(control.bottomInset, 0) + compare(topInsetSpy.count, topInsetChanges) + compare(leftInsetSpy.count, leftInsetChanges) + compare(rightInsetSpy.count, ++rightInsetChanges) + compare(bottomInsetSpy.count, bottomInsetChanges) + compare(control.background.x, 20) + compare(control.background.y, 10) + compare(control.background.width, 50) + compare(control.background.height, 90) + + control.bottomInset = 40 + compare(control.topInset, 10) + compare(control.leftInset, 20) + compare(control.rightInset, 30) + compare(control.bottomInset, 40) + compare(topInsetSpy.count, topInsetChanges) + compare(leftInsetSpy.count, leftInsetChanges) + compare(rightInsetSpy.count, rightInsetChanges) + compare(bottomInsetSpy.count, ++bottomInsetChanges) + compare(control.background.x, 20) + compare(control.background.y, 10) + compare(control.background.width, 50) + compare(control.background.height, 50) + + control.topInset = undefined + compare(control.topInset, 0) + compare(control.leftInset, 20) + compare(control.rightInset, 30) + compare(control.bottomInset, 40) + compare(topInsetSpy.count, ++topInsetChanges) + compare(leftInsetSpy.count, leftInsetChanges) + compare(rightInsetSpy.count, rightInsetChanges) + compare(bottomInsetSpy.count, bottomInsetChanges) + compare(control.background.x, 20) + compare(control.background.y, 0) + compare(control.background.width, 50) + compare(control.background.height, 60) + + control.leftInset = undefined + compare(control.topInset, 0) + compare(control.leftInset, 0) + compare(control.rightInset, 30) + compare(control.bottomInset, 40) + compare(topInsetSpy.count, topInsetChanges) + compare(leftInsetSpy.count, ++leftInsetChanges) + compare(rightInsetSpy.count, rightInsetChanges) + compare(bottomInsetSpy.count, bottomInsetChanges) + compare(control.background.x, 0) + compare(control.background.y, 0) + compare(control.background.width, 70) + compare(control.background.height, 60) + + control.rightInset = undefined + compare(control.topInset, 0) + compare(control.leftInset, 0) + compare(control.rightInset, 0) + compare(control.bottomInset, 40) + compare(topInsetSpy.count, topInsetChanges) + compare(leftInsetSpy.count, leftInsetChanges) + compare(rightInsetSpy.count, ++rightInsetChanges) + compare(bottomInsetSpy.count, bottomInsetChanges) + compare(control.background.x, 0) + compare(control.background.y, 0) + compare(control.background.width, 100) + compare(control.background.height, 60) + + control.bottomInset = undefined + compare(control.topInset, 0) + compare(control.leftInset, 0) + compare(control.rightInset, 0) + compare(control.bottomInset, 0) + compare(topInsetSpy.count, topInsetChanges) + compare(leftInsetSpy.count, leftInsetChanges) + compare(rightInsetSpy.count, rightInsetChanges) + compare(bottomInsetSpy.count, ++bottomInsetChanges) + compare(control.background.x, 0) + compare(control.background.y, 0) + compare(control.background.width, 100) + compare(control.background.height, 100) } } diff --git a/tests/auto/controls/data/tst_page.qml b/tests/auto/controls/data/tst_page.qml index 8fe4414b..c709c216 100644 --- a/tests/auto/controls/data/tst_page.qml +++ b/tests/auto/controls/data/tst_page.qml @@ -132,6 +132,8 @@ TestCase { verify(control.contentItem) compare(control.contentWidth, 0) compare(control.contentHeight, 0) + compare(control.implicitContentWidth, 0) + compare(control.implicitContentHeight, 0) } function test_oneChild() { @@ -140,6 +142,8 @@ TestCase { compare(control.contentWidth, 100) compare(control.contentHeight, 30) + compare(control.implicitContentWidth, 100) + compare(control.implicitContentHeight, 30) compare(control.implicitWidth, 100 + control.leftPadding + control.rightPadding) compare(control.implicitHeight, 30 + control.topPadding + control.bottomPadding) } @@ -150,6 +154,8 @@ TestCase { compare(control.contentWidth, 0) compare(control.contentHeight, 0) + compare(control.implicitContentWidth, 0) + compare(control.implicitContentHeight, 0) compare(control.implicitWidth, Math.max(control.leftPadding + control.rightPadding, control.background ? control.background.implicitWidth : 0)) compare(control.implicitHeight, Math.max(control.topPadding + control.bottomPadding, @@ -162,6 +168,8 @@ TestCase { compare(control.contentWidth, 100) compare(control.contentHeight, 30) + compare(control.implicitContentWidth, 100) + compare(control.implicitContentHeight, 30) compare(control.implicitWidth, 100 + control.leftPadding + control.rightPadding) compare(control.implicitHeight, 30 + control.topPadding + control.bottomPadding) } diff --git a/tests/auto/controls/data/tst_pane.qml b/tests/auto/controls/data/tst_pane.qml index 0d7e6536..8976d4f9 100644 --- a/tests/auto/controls/data/tst_pane.qml +++ b/tests/auto/controls/data/tst_pane.qml @@ -119,6 +119,8 @@ TestCase { verify(control.contentItem) compare(control.contentWidth, 0) compare(control.contentHeight, 0) + compare(control.implicitContentWidth, 0) + compare(control.implicitContentHeight, 0) } function test_oneChild() { @@ -127,8 +129,21 @@ TestCase { compare(control.contentWidth, 100) compare(control.contentHeight, 30) + compare(control.implicitContentWidth, 100) + compare(control.implicitContentHeight, 30) verify(control.implicitWidth > 100) verify(control.implicitHeight > 30) + + compare(control.contentChildren.length, 1) + control.contentChildren[0].implicitWidth = 200 + control.contentChildren[0].implicitHeight = 40 + + compare(control.contentWidth, 200) + compare(control.contentHeight, 40) + compare(control.implicitContentWidth, 200) + compare(control.implicitContentHeight, 40) + verify(control.implicitWidth > 200) + verify(control.implicitHeight > 40) } function test_twoChildren() { @@ -137,6 +152,8 @@ TestCase { compare(control.contentWidth, 0) compare(control.contentHeight, 0) + compare(control.implicitContentWidth, 0) + compare(control.implicitContentHeight, 0) verify(control.implicitWidth > 0) verify(control.implicitHeight > 0) } @@ -147,6 +164,8 @@ TestCase { compare(control.contentWidth, 100) compare(control.contentHeight, 30) + compare(control.implicitContentWidth, 100) + compare(control.implicitContentHeight, 30) verify(control.implicitWidth > 100) verify(control.implicitHeight > 30) } diff --git a/tests/auto/controls/data/tst_popup.qml b/tests/auto/controls/data/tst_popup.qml index 4951c13c..962feae2 100644 --- a/tests/auto/controls/data/tst_popup.qml +++ b/tests/auto/controls/data/tst_popup.qml @@ -48,10 +48,10 @@ ** ****************************************************************************/ -import QtQuick 2.11 +import QtQuick 2.12 import QtTest 1.0 -import QtQuick.Controls 2.3 -import QtQuick.Templates 2.3 as T +import QtQuick.Controls 2.5 +import QtQuick.Templates 2.5 as T TestCase { id: testCase @@ -1270,6 +1270,77 @@ TestCase { compare(control.background.height, 100 + (control.background.topInset || 0) + (control.background.bottomInset || 0)) } + function test_anchors() { + var control = createTemporaryObject(popupControl, applicationWindow.contentItem.Overlay.overlay, + { visible: true, width: 100, height: 100 }) + verify(control) + verify(control.visible) + compare(control.parent, control.Overlay.overlay) + compare(control.x, 0) + compare(control.y, 0) + + var overlay = control.Overlay.overlay + verify(overlay) + + var centerInSpy = createTemporaryObject(signalSpy, testCase, { target: control.anchors, signalName: "centerInChanged" }) + verify(centerInSpy.valid) + + applicationWindow.visible = true + verify(waitForRendering(applicationWindow.contentItem)) + verify(overlay.width > 0) + verify(overlay.height > 0) + + // Center the popup in the window via the overlay. + control.anchors.centerIn = Qt.binding(function() { return control.parent; }) + compare(centerInSpy.count, 1) + compare(control.x, (overlay.width - control.width) / 2) + compare(control.y, (overlay.height - control.height) / 2) + + // Ensure that it warns when trying to set it to an item that's not its parent. + var anotherItem = createTemporaryObject(rect, applicationWindow.contentItem, { x: 100, y: 100, width: 50, height: 50 }) + verify(anotherItem) + + ignoreWarning(Qt.resolvedUrl("tst_popup.qml") + ":77:9: QML Popup: Popup can only be centered within its immediate parent or Overlay.overlay") + control.anchors.centerIn = anotherItem + // The property will change, because we can't be sure that the parent + // in QQuickPopupAnchors::setCenterIn() is the final parent, as some reparenting can happen. + // We still expect the warning from QQuickPopupPositioner::reposition() though. + compare(centerInSpy.count, 2) + compare(control.anchors.centerIn, anotherItem) + + // The binding to the popup's parent was broken above, so restore it. + control.anchors.centerIn = Qt.binding(function() { return control.parent; }) + compare(centerInSpy.count, 3) + + // Change the popup's parent and ensure that it's anchored accordingly. + control.parent = Qt.binding(function() { return anotherItem; }) + compare(control.parent, anotherItem) + compare(control.anchors.centerIn, anotherItem) + compare(centerInSpy.count, 4) + compare(control.x, (anotherItem.width - control.width) / 2) + compare(control.y, (anotherItem.height - control.height) / 2) + + // Check that anchors.centerIn beats x and y coordinates as it does in QQuickItem. + control.x = 33; + control.y = 44; + compare(control.x, (anotherItem.width - control.width) / 2) + compare(control.y, (anotherItem.height - control.height) / 2) + + // Check that the popup's x and y coordinates are restored when it's no longer centered. + control.anchors.centerIn = undefined + compare(centerInSpy.count, 5) + compare(control.x, 33) + compare(control.y, 44) + + // Test centering in the overlay while having a different parent (anotherItem). + control.anchors.centerIn = overlay + compare(centerInSpy.count, 6) + compare(control.x, (overlay.width - control.width) / 2) + compare(control.y, (overlay.height - control.height) / 2) + + // TODO: do this properly by creating a component or something + applicationWindow.visible = false + } Component { id: shortcutWindowComponent diff --git a/tests/auto/controls/data/tst_rangeslider.qml b/tests/auto/controls/data/tst_rangeslider.qml index 39b0c4b0..03b34a2a 100644 --- a/tests/auto/controls/data/tst_rangeslider.qml +++ b/tests/auto/controls/data/tst_rangeslider.qml @@ -291,12 +291,21 @@ TestCase { var firstPressedSpy = signalSpy.createObject(control, {target: control.first, signalName: "pressedChanged"}) verify(firstPressedSpy.valid) + var firstMovedSpy = signalSpy.createObject(control, {target: control.first, signalName: "moved"}) + verify(firstMovedSpy.valid) + var secondPressedSpy = signalSpy.createObject(control, {target: control.second, signalName: "pressedChanged"}) verify(secondPressedSpy.valid) + var secondMovedSpy = signalSpy.createObject(control, {target: control.second, signalName: "moved"}) + verify(secondMovedSpy.valid) + + // Press and release the first handle without moving it. mousePress(control, control.leftPadding, control.height - control.bottomPadding, Qt.LeftButton) compare(firstPressedSpy.count, 1) + compare(firstMovedSpy.count, 0) compare(secondPressedSpy.count, 0) + compare(secondMovedSpy.count, 0) compare(control.first.pressed, true) compare(control.first.value, 0.0) compare(control.first.position, 0.0) @@ -306,7 +315,9 @@ TestCase { mouseRelease(control, control.leftPadding, control.height - control.bottomPadding, Qt.LeftButton) compare(firstPressedSpy.count, 2) + compare(firstMovedSpy.count, 0) compare(secondPressedSpy.count, 0) + compare(secondMovedSpy.count, 0) compare(control.first.pressed, false) compare(control.first.value, 0.0) compare(control.first.position, 0.0) @@ -314,9 +325,12 @@ TestCase { compare(control.second.value, 1.0) compare(control.second.position, 1.0) + // Press and release the second handle without moving it. mousePress(control, control.width - control.rightPadding, control.topPadding, Qt.LeftButton) compare(firstPressedSpy.count, 2) + compare(firstMovedSpy.count, 0) compare(secondPressedSpy.count, 1) + compare(secondMovedSpy.count, 0) compare(control.first.pressed, false) compare(control.first.value, 0.0) compare(control.first.position, 0.0) @@ -326,7 +340,9 @@ TestCase { mouseRelease(control, control.width - control.rightPadding, control.topPadding, Qt.LeftButton) compare(firstPressedSpy.count, 2) + compare(firstMovedSpy.count, 0) compare(secondPressedSpy.count, 2) + compare(secondMovedSpy.count, 0) compare(control.first.pressed, false) compare(control.first.value, 0.0) compare(control.first.position, 0.0) @@ -334,9 +350,12 @@ TestCase { compare(control.second.value, 1.0) compare(control.second.position, 1.0) + // Press and release on the bottom left corner of the control without moving the handle. mousePress(control, 0, control.height, Qt.LeftButton) compare(firstPressedSpy.count, 3) + compare(firstMovedSpy.count, 0) compare(secondPressedSpy.count, 2) + compare(secondMovedSpy.count, 0) compare(control.first.pressed, true) compare(control.first.value, 0.0) compare(control.first.position, 0.0) @@ -346,7 +365,9 @@ TestCase { mouseRelease(control, 0, control.height, Qt.LeftButton) compare(firstPressedSpy.count, 4) + compare(firstMovedSpy.count, 0) compare(secondPressedSpy.count, 2) + compare(secondMovedSpy.count, 0) compare(control.first.pressed, false) compare(control.first.value, 0.0) compare(control.first.position, 0.0) @@ -354,9 +375,12 @@ TestCase { compare(control.second.value, 1.0) compare(control.second.position, 1.0) + // Drag the first handle. mousePress(control, control.leftPadding, control.height - control.bottomPadding, Qt.LeftButton) compare(firstPressedSpy.count, 5) + compare(firstMovedSpy.count, 0) compare(secondPressedSpy.count, 2) + compare(secondMovedSpy.count, 0) compare(control.first.pressed, true) compare(control.first.value, 0.0) compare(control.first.position, 0.0) @@ -369,7 +393,9 @@ TestCase { var toY = horizontal ? control.first.handle.y : control.height * 0.5 mouseMove(control, toX, toY) compare(firstPressedSpy.count, 5) + compare(firstMovedSpy.count, 1) compare(secondPressedSpy.count, 2) + compare(secondMovedSpy.count, 0) compare(control.first.pressed, true) compare(control.first.value, data.live ? 0.5 : 0.0) compare(control.first.position, 0.5) @@ -381,7 +407,9 @@ TestCase { mouseRelease(control, toX, toY, Qt.LeftButton) compare(firstPressedSpy.count, 6) + compare(firstMovedSpy.count, 1) compare(secondPressedSpy.count, 2) + compare(secondMovedSpy.count, 0) compare(control.first.pressed, false) compare(control.first.value, 0.5) compare(control.first.position, 0.5) @@ -408,13 +436,22 @@ TestCase { var firstPressedSpy = signalSpy.createObject(control, {target: control.first, signalName: "pressedChanged"}) verify(firstPressedSpy.valid) + var firstMovedSpy = signalSpy.createObject(control, {target: control.first, signalName: "moved"}) + verify(firstMovedSpy.valid) + var secondPressedSpy = signalSpy.createObject(control, {target: control.second, signalName: "pressedChanged"}) verify(secondPressedSpy.valid) + var secondMovedSpy = signalSpy.createObject(control, {target: control.second, signalName: "moved"}) + verify(secondMovedSpy.valid) + + // Press and release the first handle without moving it. var touch = touchEvent(control) touch.press(0, control, control.width * 0.25, control.height * 0.75).commit() compare(firstPressedSpy.count, 1) + compare(firstMovedSpy.count, 0) compare(secondPressedSpy.count, 0) + compare(secondMovedSpy.count, 0) compare(control.first.pressed, true) compare(control.first.value, 0.0) compare(control.first.position, 0.0) @@ -424,7 +461,9 @@ TestCase { touch.release(0, control, control.width * 0.25, control.height * 0.75).commit() compare(firstPressedSpy.count, 2) + compare(firstMovedSpy.count, 0) compare(secondPressedSpy.count, 0) + compare(secondMovedSpy.count, 0) compare(control.first.pressed, false) compare(control.first.value, 0.0) compare(control.first.position, 0.0) @@ -432,6 +471,7 @@ TestCase { compare(control.second.value, 1.0) compare(control.second.position, 1.0) + // Press and release the second handle without moving it. touch.press(0, control, control.width * 0.75, control.height * 0.25).commit() compare(firstPressedSpy.count, 2) compare(secondPressedSpy.count, 1) @@ -452,6 +492,7 @@ TestCase { compare(control.second.value, 1.0) compare(control.second.position, 1.0) + // Press and release on the bottom left corner of the control without moving the handle. touch.press(0, control, 0, control.height).commit() compare(firstPressedSpy.count, 3) compare(secondPressedSpy.count, 2) @@ -482,6 +523,7 @@ TestCase { compare(control.second.value, 1.0) compare(control.second.position, 1.0) + // Drag the first handle. var horizontal = control.orientation === Qt.Horizontal var toX = horizontal ? control.width * 0.5 : control.first.handle.x var toY = horizontal ? control.first.handle.y : control.height * 0.5 @@ -929,4 +971,115 @@ TestCase { compare(control.first.pressed, false) compare(control.second.pressed, false) } + + function test_touchDragThreshold_data() { + var d1 = 3; var d2 = 7; + return [ + { tag: "horizontal", orientation: Qt.Horizontal, dx1: d1, dy1: 0, dx2: d2, dy2: 0 }, + { tag: "vertical", orientation: Qt.Vertical, dx1: 0, dy1: -d1, dx2: 0, dy2: -d2 }, + { tag: "horizontal2", orientation: Qt.Horizontal, dx1: -d1, dy1: 0, dx2: -d2, dy2: 0 }, + { tag: "vertical2", orientation: Qt.Vertical, dx1: 0, dy1: d1, dx2: 0, dy2: d2 }, + ] + } + + function test_touchDragThreshold(data) { + var control = createTemporaryObject(sliderComponent, testCase, {touchDragThreshold: 10, live: true, orientation: data.orientation, first: {value: 0}, second: {value: 1}}) + verify(control) + compare(control.touchDragThreshold, 10) + + var valueChangedCount = 0 + var valueChangedSpy = signalSpy.createObject(control, {target: control, signalName: "touchDragThresholdChanged"}) + verify(valueChangedSpy.valid) + + control.touchDragThreshold = undefined + compare(control.touchDragThreshold, -1) // reset to -1 + compare(valueChangedSpy.count, ++valueChangedCount) + + var t = 5 + control.touchDragThreshold = t + compare(control.touchDragThreshold, t) + compare(valueChangedSpy.count, ++valueChangedCount) + + control.touchDragThreshold = t + compare(control.touchDragThreshold, t) + compare(valueChangedSpy.count, valueChangedCount) + + var pressedCount = 0 + var pressedCount2 = 0 + var visualPositionCount = 0 + var visualPositionCount2 = 0 + + var pressedSpy = signalSpy.createObject(control, {target: control.first, signalName: "pressedChanged"}) + verify(pressedSpy.valid) + var pressedSpy2 = signalSpy.createObject(control, {target: control.second, signalName: "pressedChanged"}) + verify(pressedSpy2.valid) + + var visualPositionSpy = signalSpy.createObject(control, {target: control.first, signalName: "visualPositionChanged"}) + verify(visualPositionSpy.valid) + var visualPositionSpy2 = signalSpy.createObject(control, {target: control.second, signalName: "visualPositionChanged"}) + verify(visualPositionSpy2.valid) + + var touch = touchEvent(control) + control.first.value = 0.4 + control.second.value = 1 + var x0 = control.first.handle.x + control.first.handle.width * 0.5 + var y0 = control.first.handle.y + control.first.handle.height * 0.5 + touch.press(0, control, x0, y0).commit() + compare(pressedSpy.count, ++pressedCount) + compare(control.first.pressed, true) + compare(visualPositionSpy.count, ++visualPositionCount) + + touch.move(0, control, x0 + data.dx1, y0 + data.dy1).commit() + compare(pressedSpy.count, pressedCount) + compare(control.first.pressed, true) + compare(visualPositionSpy.count, visualPositionCount) + + touch.move(0, control, x0 + data.dx2, y0 + data.dy2).commit() + compare(pressedSpy.count, pressedCount) + compare(control.first.pressed, true) + compare(visualPositionSpy.count, ++visualPositionCount) + + touch.release(0, control, x0 + data.dx2, y0 + data.dy2).commit() + + control.first.value = 0 + control.second.value = 0.6 + x0 = control.second.handle.x + control.second.handle.width * 0.5 + y0 = control.second.handle.y + control.second.handle.height * 0.5 + touch.press(0, control, x0, y0).commit() + compare(pressedSpy2.count, ++pressedCount2) + compare(control.second.pressed, true) + compare(visualPositionSpy2.count, ++visualPositionCount2) + + touch.move(0, control, x0 + data.dx1, y0 + data.dy1).commit() + compare(pressedSpy2.count, pressedCount2) + compare(control.second.pressed, true) + compare(visualPositionSpy2.count, visualPositionCount2) + + touch.move(0, control, x0 + data.dx2, y0 + data.dy2).commit() + compare(pressedSpy2.count, pressedCount2) + compare(control.second.pressed, true) + compare(visualPositionSpy2.count, ++visualPositionCount2) + touch.release(0, control, x0 + data.dx2, y0 + data.dy2).commit() + } + + function test_valueAt_data() { + return [ + { tag: "0.0..1.0", from: 0.0, to: 1.0, values: [0.0, 0.2, 0.5, 1.0] }, + { tag: "0..100", from: 0, to: 100, values: [0, 20, 50, 100] }, + { tag: "100..-100", from: 100, to: -100, values: [100, 60, 0, -100] }, + { tag: "-7..7", from: -7, to: 7, stepSize: 1.0, values: [-7.0, -4.0, 0.0, 7.0] }, + { tag: "-3..7", from: -3, to: 7, stepSize: 5.0, values: [-3.0, -3.0, 2.0, 7.0] }, + ] + } + + function test_valueAt(data) { + var control = createTemporaryObject(sliderComponent, testCase, + { from: data.from, to: data.to, stepSize: data.stepSize }) + verify(control) + + compare(control.valueAt(0.0), data.values[0]) + compare(control.valueAt(0.2), data.values[1]) + compare(control.valueAt(0.5), data.values[2]) + compare(control.valueAt(1.0), data.values[3]) + } } diff --git a/tests/auto/controls/data/tst_slider.qml b/tests/auto/controls/data/tst_slider.qml index a831e402..368bc9fd 100644 --- a/tests/auto/controls/data/tst_slider.qml +++ b/tests/auto/controls/data/tst_slider.qml @@ -804,4 +804,66 @@ TestCase { mouseRelease(control) compare(control.pressed, false) } + + function test_touchDragThreshold_data() { + var d1 = 3; var d2 = 7; + return [ + { tag: "horizontal", orientation: Qt.Horizontal, dx1: d1, dy1: 0, dx2: d2, dy2: 0 }, + { tag: "vertical", orientation: Qt.Vertical, dx1: 0, dy1: -d1, dx2: 0, dy2: -d2 }, + { tag: "horizontal2", orientation: Qt.Horizontal, dx1: -d1, dy1: 0, dx2: -d2, dy2: 0 }, + { tag: "vertical2", orientation: Qt.Vertical, dx1: 0, dy1: d1, dx2: 0, dy2: d2 } + ] + } + + function test_touchDragThreshold(data) { + var control = createTemporaryObject(slider, testCase, {touchDragThreshold: 10, live: true, orientation: data.orientation, value: 0.5}) + verify(control) + compare(control.touchDragThreshold, 10) + + var valueChangedCount = 0 + var valueChangedSpy = signalSpy.createObject(control, {target: control, signalName: "touchDragThresholdChanged"}) + verify(valueChangedSpy.valid) + + control.touchDragThreshold = undefined + compare(control.touchDragThreshold, -1) // reset to -1 + compare(valueChangedSpy.count, ++valueChangedCount) + + var t = 5 + control.touchDragThreshold = t + compare(control.touchDragThreshold, t) + compare(valueChangedSpy.count, ++valueChangedCount) + + control.touchDragThreshold = t + compare(control.touchDragThreshold, t) + compare(valueChangedSpy.count, valueChangedCount) + + var pressedCount = 0 + var movedCount = 0 + + var pressedSpy = signalSpy.createObject(control, {target: control, signalName: "pressedChanged"}) + verify(pressedSpy.valid) + + var movedSpy = signalSpy.createObject(control, {target: control, signalName: "moved"}) + verify(movedSpy.valid) + + var touch = touchEvent(control) + var x0 = control.handle.x + control.handle.width * 0.5 + var y0 = control.handle.y + control.handle.height * 0.5 + touch.press(0, control, x0, y0).commit() + compare(pressedSpy.count, ++pressedCount) + compare(movedSpy.count, movedCount) + compare(control.pressed, true) + + touch.move(0, control, x0 + data.dx1, y0 + data.dy1).commit() + compare(pressedSpy.count, pressedCount) + compare(movedSpy.count, movedCount) // shouldn't move + compare(control.pressed, true) + + touch.move(0, control, x0 + data.dx2, y0 + data.dy2).commit() + compare(pressedSpy.count, pressedCount) + compare(movedSpy.count, ++movedCount) + compare(control.pressed, true) + + touch.release(0, control, x0 + data.dx2, y0 + data.dy2).commit() + } } diff --git a/tests/auto/controls/data/tst_swipeview.qml b/tests/auto/controls/data/tst_swipeview.qml index 39311877..1f92bba4 100644 --- a/tests/auto/controls/data/tst_swipeview.qml +++ b/tests/auto/controls/data/tst_swipeview.qml @@ -85,43 +85,60 @@ TestCase { compare(control.currentIndex, -1) compare(control.currentItem, null) - control.addItem(page.createObject(control, {text: "0"})) + var item0 = page.createObject(control, {text: "0"}) + control.addItem(item0) compare(control.count, 1) compare(control.currentIndex, 0) compare(control.currentItem.text, "0") compare(currentItemChangedSpy.count, 1); + compare(control.contentWidth, item0.implicitWidth) + compare(control.contentHeight, item0.implicitHeight) - control.addItem(page.createObject(control, {text: "1"})) + var item1 = page.createObject(control, {text: "11"}) + control.addItem(item1) compare(control.count, 2) compare(control.currentIndex, 0) compare(control.currentItem.text, "0") compare(currentItemChangedSpy.count, 1); + compare(control.contentWidth, item0.implicitWidth) + compare(control.contentHeight, item0.implicitHeight) - control.addItem(page.createObject(control, {text: "2"})) + var item2 = page.createObject(control, {text: "222"}) + control.addItem(item2) compare(control.count, 3) compare(control.currentIndex, 0) compare(control.currentItem.text, "0") compare(currentItemChangedSpy.count, 1); + compare(control.contentWidth, item0.implicitWidth) + compare(control.contentHeight, item0.implicitHeight) control.currentIndex = 1 compare(control.currentIndex, 1) - compare(control.currentItem.text, "1") + compare(control.currentItem.text, "11") compare(currentItemChangedSpy.count, 2); + compare(control.contentWidth, item1.implicitWidth) + compare(control.contentHeight, item1.implicitHeight) control.currentIndex = 2 compare(control.currentIndex, 2) - compare(control.currentItem.text, "2") + compare(control.currentItem.text, "222") compare(currentItemChangedSpy.count, 3); + compare(control.contentWidth, item2.implicitWidth) + compare(control.contentHeight, item2.implicitHeight) control.decrementCurrentIndex() compare(control.currentIndex, 1) - compare(control.currentItem.text, "1") + compare(control.currentItem.text, "11") compare(currentItemChangedSpy.count, 4); + compare(control.contentWidth, item1.implicitWidth) + compare(control.contentHeight, item1.implicitHeight) control.incrementCurrentIndex() compare(control.currentIndex, 2) - compare(control.currentItem.text, "2") + compare(control.currentItem.text, "222") compare(currentItemChangedSpy.count, 5); + compare(control.contentWidth, item2.implicitWidth) + compare(control.contentHeight, item2.implicitHeight) } Component { diff --git a/tests/auto/controls/data/tst_tabbar.qml b/tests/auto/controls/data/tst_tabbar.qml index adb27f78..58917d84 100644 --- a/tests/auto/controls/data/tst_tabbar.qml +++ b/tests/auto/controls/data/tst_tabbar.qml @@ -514,8 +514,10 @@ TestCase { control.addItem(tab1) tryCompare(tab1, "width", control.width) compare(tab1.height, control.height) - compare(control.contentWidth, tab1.implicitWidth) - compare(control.contentHeight, tab1.implicitHeight) + compare(control.implicitContentWidth, tab1.implicitWidth) + compare(control.implicitContentHeight, tab1.implicitHeight) + compare(control.contentWidth, control.implicitContentWidth) + compare(control.contentHeight, control.implicitContentHeight) compare(control.implicitWidth, control.contentWidth + control.leftPadding + control.rightPadding) compare(control.implicitHeight, control.contentHeight + control.topPadding + control.bottomPadding) @@ -525,8 +527,10 @@ TestCase { compare(tab1.height, control.height) compare(tab2.width, (control.width - data.spacing) / 2) compare(tab2.height, control.height) - compare(control.contentWidth, tab1.implicitWidth + tab2.implicitWidth + data.spacing) - compare(control.contentHeight, tab2.implicitHeight) + compare(control.implicitContentWidth, tab1.implicitWidth + tab2.implicitWidth + data.spacing) + compare(control.implicitContentHeight, tab2.implicitHeight) + compare(control.contentWidth, control.implicitContentWidth) + compare(control.contentHeight, control.implicitContentHeight) compare(control.implicitWidth, control.contentWidth + control.leftPadding + control.rightPadding) compare(control.implicitHeight, control.contentHeight + control.topPadding + control.bottomPadding) @@ -542,8 +546,10 @@ TestCase { compare(tab3.y, (control.height - tab3.height) / 2) compare(tab3.width, 50) compare(tab3.height, tab1.implicitHeight - 10) - compare(control.contentWidth, tab1.implicitWidth + tab2.implicitWidth + tab3.width + 2 * data.spacing) - compare(control.contentHeight, tab2.implicitHeight) + compare(control.implicitContentWidth, tab1.implicitWidth + tab2.implicitWidth + tab3.width + 2 * data.spacing) + compare(control.implicitContentHeight, tab2.implicitHeight) + compare(control.contentWidth, control.implicitContentWidth) + compare(control.contentHeight, control.implicitContentHeight) compare(control.implicitWidth, control.contentWidth + control.leftPadding + control.rightPadding) compare(control.implicitHeight, control.contentHeight + control.topPadding + control.bottomPadding) @@ -556,8 +562,10 @@ TestCase { compare(tab2.height, control.height) compare(tab3.width, expectedWidth) compare(tab3.height, tab3.implicitHeight) - compare(control.contentWidth, tab1.implicitWidth + tab2.implicitWidth + tab3.implicitWidth + 2 * data.spacing) - compare(control.contentHeight, tab2.implicitHeight) + compare(control.implicitContentWidth, tab1.implicitWidth + tab2.implicitWidth + tab3.implicitWidth + 2 * data.spacing) + compare(control.implicitContentHeight, tab2.implicitHeight) + compare(control.contentWidth, control.implicitContentWidth) + compare(control.contentHeight, control.implicitContentHeight) compare(control.implicitWidth, control.contentWidth + control.leftPadding + control.rightPadding) compare(control.implicitHeight, control.contentHeight + control.topPadding + control.bottomPadding) diff --git a/tests/auto/controls/data/tst_textarea.qml b/tests/auto/controls/data/tst_textarea.qml index 2de82d85..0a50e033 100644 --- a/tests/auto/controls/data/tst_textarea.qml +++ b/tests/auto/controls/data/tst_textarea.qml @@ -79,6 +79,11 @@ TestCase { SignalSpy { } } + Component { + id: rectangle + Rectangle { } + } + function test_creation() { var control = createTemporaryObject(textArea, testCase) verify(control) @@ -86,15 +91,69 @@ TestCase { function test_implicitSize() { var control = createTemporaryObject(textArea, testCase) + verify(control) var implicitWidthSpy = signalSpy.createObject(control, { target: control, signalName: "implicitWidthChanged"} ) + verify(implicitWidthSpy.valid) + var implicitHeightSpy = signalSpy.createObject(control, { target: control, signalName: "implicitHeightChanged"} ) - control.background.implicitWidth = 400 - control.background.implicitHeight = 200 + verify(implicitHeightSpy.valid) + + var implicitBackgroundWidthSpy = createTemporaryObject(signalSpy, testCase, {target: control, signalName: "implicitBackgroundWidthChanged"}) + verify(implicitBackgroundWidthSpy.valid) + + var implicitBackgroundHeightSpy = createTemporaryObject(signalSpy, testCase, {target: control, signalName: "implicitBackgroundHeightChanged"}) + verify(implicitBackgroundHeightSpy.valid) + + var implicitWidthChanges = 0 + var implicitHeightChanges = 0 + var implicitBackgroundWidthChanges = 0 + var implicitBackgroundHeightChanges = 0 + + verify(control.implicitWidth >= control.leftPadding + control.rightPadding) + verify(control.implicitHeight >= control.contentHeight + control.topPadding + control.bottomPadding) + compare(control.implicitBackgroundWidth, 0) + compare(control.implicitBackgroundHeight, 0) + + control.background = rectangle.createObject(control, {implicitWidth: 400, implicitHeight: 200}) compare(control.implicitWidth, 400) compare(control.implicitHeight, 200) - compare(implicitWidthSpy.count, 1) - compare(implicitHeightSpy.count, 1) + compare(control.implicitBackgroundWidth, 400) + compare(control.implicitBackgroundHeight, 200) + compare(implicitWidthSpy.count, ++implicitWidthChanges) + compare(implicitHeightSpy.count, ++implicitHeightChanges) + compare(implicitBackgroundWidthSpy.count, ++implicitBackgroundWidthChanges) + compare(implicitBackgroundHeightSpy.count, ++implicitBackgroundHeightChanges) + + control.background = null + compare(control.implicitWidth, control.leftPadding + control.rightPadding) + verify(control.implicitHeight >= control.contentHeight + control.topPadding + control.bottomPadding) + compare(control.implicitBackgroundWidth, 0) + compare(control.implicitBackgroundHeight, 0) + compare(implicitWidthSpy.count, ++implicitWidthChanges) + compare(implicitHeightSpy.count, ++implicitHeightChanges) + compare(implicitBackgroundWidthSpy.count, ++implicitBackgroundWidthChanges) + compare(implicitBackgroundHeightSpy.count, ++implicitBackgroundHeightChanges) + + control.text = "TextArea" + compare(control.implicitWidth, control.contentWidth + control.leftPadding + control.rightPadding) + verify(control.implicitHeight >= control.contentHeight + control.topPadding + control.bottomPadding) + compare(control.implicitBackgroundWidth, 0) + compare(control.implicitBackgroundHeight, 0) + compare(implicitWidthSpy.count, ++implicitWidthChanges) + compare(implicitHeightSpy.count, implicitHeightChanges) + compare(implicitBackgroundWidthSpy.count, implicitBackgroundWidthChanges) + compare(implicitBackgroundHeightSpy.count, implicitBackgroundHeightChanges) + + control.placeholderText = "..." + compare(control.implicitWidth, control.contentWidth + control.leftPadding + control.rightPadding) + verify(control.implicitHeight >= control.contentHeight + control.topPadding + control.bottomPadding) + compare(control.implicitBackgroundWidth, 0) + compare(control.implicitBackgroundHeight, 0) + compare(implicitWidthSpy.count, implicitWidthChanges) + compare(implicitHeightSpy.count, implicitHeightChanges) + compare(implicitBackgroundWidthSpy.count, implicitBackgroundWidthChanges) + compare(implicitBackgroundHeightSpy.count, implicitBackgroundHeightChanges) } function test_alignment_data() { @@ -468,4 +527,165 @@ TestCase { control.destroy() wait(0) } + + function test_placeholderTextColor() { + var control = createTemporaryObject(textArea, testCase) + verify(control) + + // usually default value should not be pure opacue black + verify(control.placeholderTextColor !== "#ff000000") + control.placeholderTextColor = "#12345678" + compare(control.placeholderTextColor, "#12345678") + + for (var i = 0; i < control.children.length; ++i) { + if (control.children[i].hasOwnProperty("text")) + compare(control.children[i].color, control.placeholderTextColor) // placeholder.color + } + } + + function test_inset() { + var control = createTemporaryObject(textArea, testCase, {background: rectangle.createObject(control)}) + verify(control) + + var topInsetSpy = createTemporaryObject(signalSpy, testCase, {target: control, signalName: "topInsetChanged"}) + verify(topInsetSpy.valid) + + var leftInsetSpy = createTemporaryObject(signalSpy, testCase, {target: control, signalName: "leftInsetChanged"}) + verify(leftInsetSpy.valid) + + var rightInsetSpy = createTemporaryObject(signalSpy, testCase, {target: control, signalName: "rightInsetChanged"}) + verify(rightInsetSpy.valid) + + var bottomInsetSpy = createTemporaryObject(signalSpy, testCase, {target: control, signalName: "bottomInsetChanged"}) + verify(bottomInsetSpy.valid) + + var topInsetChanges = 0 + var leftInsetChanges = 0 + var rightInsetChanges = 0 + var bottomInsetChanges = 0 + + compare(control.topInset, 0) + compare(control.leftInset, 0) + compare(control.rightInset, 0) + compare(control.bottomInset, 0) + + control.width = 100 + control.height = 100 + compare(control.background.x, 0) + compare(control.background.y, 0) + compare(control.background.width, 100) + compare(control.background.height, 100) + + control.topInset = 10 + compare(control.topInset, 10) + compare(control.leftInset, 0) + compare(control.rightInset, 0) + compare(control.bottomInset, 0) + compare(topInsetSpy.count, ++topInsetChanges) + compare(leftInsetSpy.count, leftInsetChanges) + compare(rightInsetSpy.count, rightInsetChanges) + compare(bottomInsetSpy.count, bottomInsetChanges) + compare(control.background.x, 0) + compare(control.background.y, 10) + compare(control.background.width, 100) + compare(control.background.height, 90) + + control.leftInset = 20 + compare(control.topInset, 10) + compare(control.leftInset, 20) + compare(control.rightInset, 0) + compare(control.bottomInset, 0) + compare(topInsetSpy.count, topInsetChanges) + compare(leftInsetSpy.count, ++leftInsetChanges) + compare(rightInsetSpy.count, rightInsetChanges) + compare(bottomInsetSpy.count, bottomInsetChanges) + compare(control.background.x, 20) + compare(control.background.y, 10) + compare(control.background.width, 80) + compare(control.background.height, 90) + + control.rightInset = 30 + compare(control.topInset, 10) + compare(control.leftInset, 20) + compare(control.rightInset, 30) + compare(control.bottomInset, 0) + compare(topInsetSpy.count, topInsetChanges) + compare(leftInsetSpy.count, leftInsetChanges) + compare(rightInsetSpy.count, ++rightInsetChanges) + compare(bottomInsetSpy.count, bottomInsetChanges) + compare(control.background.x, 20) + compare(control.background.y, 10) + compare(control.background.width, 50) + compare(control.background.height, 90) + + control.bottomInset = 40 + compare(control.topInset, 10) + compare(control.leftInset, 20) + compare(control.rightInset, 30) + compare(control.bottomInset, 40) + compare(topInsetSpy.count, topInsetChanges) + compare(leftInsetSpy.count, leftInsetChanges) + compare(rightInsetSpy.count, rightInsetChanges) + compare(bottomInsetSpy.count, ++bottomInsetChanges) + compare(control.background.x, 20) + compare(control.background.y, 10) + compare(control.background.width, 50) + compare(control.background.height, 50) + + control.topInset = undefined + compare(control.topInset, 0) + compare(control.leftInset, 20) + compare(control.rightInset, 30) + compare(control.bottomInset, 40) + compare(topInsetSpy.count, ++topInsetChanges) + compare(leftInsetSpy.count, leftInsetChanges) + compare(rightInsetSpy.count, rightInsetChanges) + compare(bottomInsetSpy.count, bottomInsetChanges) + compare(control.background.x, 20) + compare(control.background.y, 0) + compare(control.background.width, 50) + compare(control.background.height, 60) + + control.leftInset = undefined + compare(control.topInset, 0) + compare(control.leftInset, 0) + compare(control.rightInset, 30) + compare(control.bottomInset, 40) + compare(topInsetSpy.count, topInsetChanges) + compare(leftInsetSpy.count, ++leftInsetChanges) + compare(rightInsetSpy.count, rightInsetChanges) + compare(bottomInsetSpy.count, bottomInsetChanges) + compare(control.background.x, 0) + compare(control.background.y, 0) + compare(control.background.width, 70) + compare(control.background.height, 60) + + control.rightInset = undefined + compare(control.topInset, 0) + compare(control.leftInset, 0) + compare(control.rightInset, 0) + compare(control.bottomInset, 40) + compare(topInsetSpy.count, topInsetChanges) + compare(leftInsetSpy.count, leftInsetChanges) + compare(rightInsetSpy.count, ++rightInsetChanges) + compare(bottomInsetSpy.count, bottomInsetChanges) + compare(control.background.x, 0) + compare(control.background.y, 0) + compare(control.background.width, 100) + compare(control.background.height, 60) + + control.bottomInset = undefined + compare(control.topInset, 0) + compare(control.leftInset, 0) + compare(control.rightInset, 0) + compare(control.bottomInset, 0) + compare(topInsetSpy.count, topInsetChanges) + compare(leftInsetSpy.count, leftInsetChanges) + compare(rightInsetSpy.count, rightInsetChanges) + compare(bottomInsetSpy.count, ++bottomInsetChanges) + compare(control.background.x, 0) + compare(control.background.y, 0) + compare(control.background.width, 100) + compare(control.background.height, 100) + } } diff --git a/tests/auto/controls/data/tst_textfield.qml b/tests/auto/controls/data/tst_textfield.qml index 0fee7363..963046e4 100644 --- a/tests/auto/controls/data/tst_textfield.qml +++ b/tests/auto/controls/data/tst_textfield.qml @@ -82,34 +82,69 @@ TestCase { function test_implicitSize() { var control = createTemporaryObject(textField, testCase) - verify(control.implicitWidth > control.leftPadding + control.rightPadding) + verify(control) var implicitWidthSpy = signalSpy.createObject(control, { target: control, signalName: "implicitWidthChanged"} ) + verify(implicitWidthSpy.valid) + var implicitHeightSpy = signalSpy.createObject(control, { target: control, signalName: "implicitHeightChanged"} ) + verify(implicitHeightSpy.valid) + + var implicitBackgroundWidthSpy = createTemporaryObject(signalSpy, testCase, {target: control, signalName: "implicitBackgroundWidthChanged"}) + verify(implicitBackgroundWidthSpy.valid) + + var implicitBackgroundHeightSpy = createTemporaryObject(signalSpy, testCase, {target: control, signalName: "implicitBackgroundHeightChanged"}) + verify(implicitBackgroundHeightSpy.valid) + + var implicitWidthChanges = 0 + var implicitHeightChanges = 0 + var implicitBackgroundWidthChanges = 0 + var implicitBackgroundHeightChanges = 0 + + verify(control.implicitWidth >= control.leftPadding + control.rightPadding) + verify(control.implicitHeight >= control.contentHeight + control.topPadding + control.bottomPadding) + compare(control.implicitBackgroundWidth, control.background.implicitWidth) + compare(control.implicitBackgroundHeight, control.background.implicitHeight) control.background = rectangle.createObject(control, {implicitWidth: 400, implicitHeight: 200}) compare(control.implicitWidth, 400) compare(control.implicitHeight, 200) - compare(implicitWidthSpy.count, 1) - compare(implicitHeightSpy.count, 1) + compare(control.implicitBackgroundWidth, 400) + compare(control.implicitBackgroundHeight, 200) + compare(implicitWidthSpy.count, ++implicitWidthChanges) + compare(implicitHeightSpy.count, ++implicitHeightChanges) + compare(implicitBackgroundWidthSpy.count, ++implicitBackgroundWidthChanges) + compare(implicitBackgroundHeightSpy.count, ++implicitBackgroundHeightChanges) control.background = null compare(control.implicitWidth, control.leftPadding + control.rightPadding) compare(control.implicitHeight, control.contentHeight + control.topPadding + control.bottomPadding) - compare(implicitWidthSpy.count, 2) - compare(implicitHeightSpy.count, 2) + compare(control.implicitBackgroundWidth, 0) + compare(control.implicitBackgroundHeight, 0) + compare(implicitWidthSpy.count, ++implicitWidthChanges) + compare(implicitHeightSpy.count, ++implicitHeightChanges) + compare(implicitBackgroundWidthSpy.count, ++implicitBackgroundWidthChanges) + compare(implicitBackgroundHeightSpy.count, ++implicitBackgroundHeightChanges) control.text = "TextField" compare(control.implicitWidth, control.contentWidth + control.leftPadding + control.rightPadding) compare(control.implicitHeight, control.contentHeight + control.topPadding + control.bottomPadding) - compare(implicitWidthSpy.count, 3) - compare(implicitHeightSpy.count, 2) + compare(control.implicitBackgroundWidth, 0) + compare(control.implicitBackgroundHeight, 0) + compare(implicitWidthSpy.count, ++implicitWidthChanges) + compare(implicitHeightSpy.count, implicitHeightChanges) + compare(implicitBackgroundWidthSpy.count, implicitBackgroundWidthChanges) + compare(implicitBackgroundHeightSpy.count, implicitBackgroundHeightChanges) control.placeholderText = "..." - verify(control.implicitWidth < control.contentWidth + control.leftPadding + control.rightPadding) + compare(control.implicitWidth, control.contentWidth + control.leftPadding + control.rightPadding) compare(control.implicitHeight, control.contentHeight + control.topPadding + control.bottomPadding) - compare(implicitWidthSpy.count, 4) - compare(implicitHeightSpy.count, 2) + compare(control.implicitBackgroundWidth, 0) + compare(control.implicitBackgroundHeight, 0) + compare(implicitWidthSpy.count, implicitWidthChanges) + compare(implicitHeightSpy.count, implicitHeightChanges) + compare(implicitBackgroundWidthSpy.count, implicitBackgroundWidthChanges) + compare(implicitBackgroundHeightSpy.count, implicitBackgroundHeightChanges) } function test_alignment_data() { @@ -435,4 +470,167 @@ TestCase { mouseClick(control, control.width / 2, control.height / 2, Qt.LeftButton | Qt.RightButton) compare(control.selectedText, "") } + + // QTBUG-66260 + function test_placeholderTextColor() { + var control = createTemporaryObject(textField, testCase) + verify(control) + + // usually default value should not be pure opacue black + verify(control.placeholderTextColor !== "#ff000000") + control.placeholderTextColor = "#12345678" + compare(control.placeholderTextColor, "#12345678") + + for (var i = 0; i < control.children.length; ++i) { + if (control.children[i].hasOwnProperty("text")) + compare(control.children[i].color, control.placeholderTextColor) // placeholder.color + } + } + + function test_inset() { + var control = createTemporaryObject(textField, testCase, {background: rectangle.createObject(control)}) + verify(control) + + var topInsetSpy = createTemporaryObject(signalSpy, testCase, {target: control, signalName: "topInsetChanged"}) + verify(topInsetSpy.valid) + + var leftInsetSpy = createTemporaryObject(signalSpy, testCase, {target: control, signalName: "leftInsetChanged"}) + verify(leftInsetSpy.valid) + + var rightInsetSpy = createTemporaryObject(signalSpy, testCase, {target: control, signalName: "rightInsetChanged"}) + verify(rightInsetSpy.valid) + + var bottomInsetSpy = createTemporaryObject(signalSpy, testCase, {target: control, signalName: "bottomInsetChanged"}) + verify(bottomInsetSpy.valid) + + var topInsetChanges = 0 + var leftInsetChanges = 0 + var rightInsetChanges = 0 + var bottomInsetChanges = 0 + + compare(control.topInset, 0) + compare(control.leftInset, 0) + compare(control.rightInset, 0) + compare(control.bottomInset, 0) + + control.width = 100 + control.height = 100 + compare(control.background.x, 0) + compare(control.background.y, 0) + compare(control.background.width, 100) + compare(control.background.height, 100) + + control.topInset = 10 + compare(control.topInset, 10) + compare(control.leftInset, 0) + compare(control.rightInset, 0) + compare(control.bottomInset, 0) + compare(topInsetSpy.count, ++topInsetChanges) + compare(leftInsetSpy.count, leftInsetChanges) + compare(rightInsetSpy.count, rightInsetChanges) + compare(bottomInsetSpy.count, bottomInsetChanges) + compare(control.background.x, 0) + compare(control.background.y, 10) + compare(control.background.width, 100) + compare(control.background.height, 90) + + control.leftInset = 20 + compare(control.topInset, 10) + compare(control.leftInset, 20) + compare(control.rightInset, 0) + compare(control.bottomInset, 0) + compare(topInsetSpy.count, topInsetChanges) + compare(leftInsetSpy.count, ++leftInsetChanges) + compare(rightInsetSpy.count, rightInsetChanges) + compare(bottomInsetSpy.count, bottomInsetChanges) + compare(control.background.x, 20) + compare(control.background.y, 10) + compare(control.background.width, 80) + compare(control.background.height, 90) + + control.rightInset = 30 + compare(control.topInset, 10) + compare(control.leftInset, 20) + compare(control.rightInset, 30) + compare(control.bottomInset, 0) + compare(topInsetSpy.count, topInsetChanges) + compare(leftInsetSpy.count, leftInsetChanges) + compare(rightInsetSpy.count, ++rightInsetChanges) + compare(bottomInsetSpy.count, bottomInsetChanges) + compare(control.background.x, 20) + compare(control.background.y, 10) + compare(control.background.width, 50) + compare(control.background.height, 90) + + control.bottomInset = 40 + compare(control.topInset, 10) + compare(control.leftInset, 20) + compare(control.rightInset, 30) + compare(control.bottomInset, 40) + compare(topInsetSpy.count, topInsetChanges) + compare(leftInsetSpy.count, leftInsetChanges) + compare(rightInsetSpy.count, rightInsetChanges) + compare(bottomInsetSpy.count, ++bottomInsetChanges) + compare(control.background.x, 20) + compare(control.background.y, 10) + compare(control.background.width, 50) + compare(control.background.height, 50) + + control.topInset = undefined + compare(control.topInset, 0) + compare(control.leftInset, 20) + compare(control.rightInset, 30) + compare(control.bottomInset, 40) + compare(topInsetSpy.count, ++topInsetChanges) + compare(leftInsetSpy.count, leftInsetChanges) + compare(rightInsetSpy.count, rightInsetChanges) + compare(bottomInsetSpy.count, bottomInsetChanges) + compare(control.background.x, 20) + compare(control.background.y, 0) + compare(control.background.width, 50) + compare(control.background.height, 60) + + control.leftInset = undefined + compare(control.topInset, 0) + compare(control.leftInset, 0) + compare(control.rightInset, 30) + compare(control.bottomInset, 40) + compare(topInsetSpy.count, topInsetChanges) + compare(leftInsetSpy.count, ++leftInsetChanges) + compare(rightInsetSpy.count, rightInsetChanges) + compare(bottomInsetSpy.count, bottomInsetChanges) + compare(control.background.x, 0) + compare(control.background.y, 0) + compare(control.background.width, 70) + compare(control.background.height, 60) + + control.rightInset = undefined + compare(control.topInset, 0) + compare(control.leftInset, 0) + compare(control.rightInset, 0) + compare(control.bottomInset, 40) + compare(topInsetSpy.count, topInsetChanges) + compare(leftInsetSpy.count, leftInsetChanges) + compare(rightInsetSpy.count, ++rightInsetChanges) + compare(bottomInsetSpy.count, bottomInsetChanges) + compare(control.background.x, 0) + compare(control.background.y, 0) + compare(control.background.width, 100) + compare(control.background.height, 60) + + control.bottomInset = undefined + compare(control.topInset, 0) + compare(control.leftInset, 0) + compare(control.rightInset, 0) + compare(control.bottomInset, 0) + compare(topInsetSpy.count, topInsetChanges) + compare(leftInsetSpy.count, leftInsetChanges) + compare(rightInsetSpy.count, rightInsetChanges) + compare(bottomInsetSpy.count, ++bottomInsetChanges) + compare(control.background.x, 0) + compare(control.background.y, 0) + compare(control.background.width, 100) + compare(control.background.height, 100) + } + } diff --git a/tests/auto/controls/data/tst_toolbar.qml b/tests/auto/controls/data/tst_toolbar.qml index 085c491d..c0f0845c 100644 --- a/tests/auto/controls/data/tst_toolbar.qml +++ b/tests/auto/controls/data/tst_toolbar.qml @@ -106,6 +106,8 @@ TestCase { verify(control.contentItem) compare(control.contentWidth, 0) compare(control.contentHeight, 0) + compare(control.implicitContentWidth, 0) + compare(control.implicitContentHeight, 0) } function test_oneChild() { @@ -114,6 +116,8 @@ TestCase { compare(control.contentWidth, 100) compare(control.contentHeight, 30) + compare(control.implicitContentWidth, 100) + compare(control.implicitContentHeight, 30) verify(control.implicitWidth >= 100) verify(control.implicitHeight >= 30) } @@ -124,6 +128,8 @@ TestCase { compare(control.contentWidth, 0) compare(control.contentHeight, 0) + compare(control.implicitContentWidth, 0) + compare(control.implicitContentHeight, 0) verify(control.implicitWidth >= 0) verify(control.implicitHeight >= 0) } @@ -134,6 +140,8 @@ TestCase { compare(control.contentWidth, 100) compare(control.contentHeight, 30) + compare(control.implicitContentWidth, 100) + compare(control.implicitContentHeight, 30) verify(control.implicitWidth >= 100) verify(control.implicitHeight >= 30) } diff --git a/tests/auto/controls/data/tst_tooltip.qml b/tests/auto/controls/data/tst_tooltip.qml index e7cc6787..99b6ee14 100644 --- a/tests/auto/controls/data/tst_tooltip.qml +++ b/tests/auto/controls/data/tst_tooltip.qml @@ -329,4 +329,22 @@ TestCase { verify(tooltip.visible) } } + + Component { + id: nonAttachedToolTipComponent + ToolTip { } + } + + function test_nonAttachedToolTipShowAndHide() { + var tip = createTemporaryObject(nonAttachedToolTipComponent, testCase) + verify(tip) + tip.show("hello"); + verify(tip.visible) + verify(tip.text === "hello") + tip.hide() + tryCompare(tip, "visible", false) + tip.show("delay", 200) + verify(tip.visible) + tryCompare(tip, "visible", false) + } } diff --git a/tests/auto/controls/data/tst_tumbler.qml b/tests/auto/controls/data/tst_tumbler.qml index d668fac0..18f63ed4 100644 --- a/tests/auto/controls/data/tst_tumbler.qml +++ b/tests/auto/controls/data/tst_tumbler.qml @@ -107,6 +107,10 @@ TestCase { return Qt.point(tumblerXCenter(), yCenter); } + function itemTopLeftPos(visualItemIndex) { + return Qt.point(tumbler.leftPadding, tumbler.topPadding + (tumblerDelegateHeight * visualItemIndex)); + } + function checkItemSizes() { var contentChildren = tumbler.wrap ? tumblerView.children : tumblerView.contentItem.children; verify(contentChildren.length >= tumbler.count); @@ -131,6 +135,21 @@ TestCase { return null; } + function findDelegateWithText(parent, text) { + for (var i = 0; i < parent.children.length; ++i) { + var child = parent.children[i]; + if (child.hasOwnProperty("text") && child.text === text) { + return child; + } + + var grandChild = findDelegateWithText(child, text); + if (grandChild) + return grandChild; + } + + return null; + } + property Component noAttachedPropertiesDelegate: Text { text: modelData } @@ -1010,8 +1029,8 @@ TestCase { if (data.bottom !== undefined) tumbler.bottomPadding = data.bottom; - compare(tumbler.availableWidth, implicitTumblerWidth - tumbler.leftPadding - tumbler.rightPadding); - compare(tumbler.availableHeight, implicitTumblerHeight - tumbler.topPadding - tumbler.bottomPadding); + compare(tumbler.availableWidth, tumbler.implicitWidth - tumbler.leftPadding - tumbler.rightPadding); + compare(tumbler.availableHeight, tumbler.implicitHeight - tumbler.topPadding - tumbler.bottomPadding); compare(tumbler.contentItem.x, tumbler.leftPadding); compare(tumbler.contentItem.y, tumbler.topPadding); @@ -1107,6 +1126,51 @@ TestCase { compare(label.text, "2"); } + function test_positionViewAtIndex_data() { + return [ + // Should be 20, 21, ... but there is a documented limitation for this in positionViewAtIndex()'s docs. + { tag: "wrap=true, mode=Beginning", wrap: true, mode: Tumbler.Beginning, expectedVisibleIndices: [21, 22, 23, 24, 25] }, + { tag: "wrap=true, mode=Center", wrap: true, mode: Tumbler.Center, expectedVisibleIndices: [18, 19, 20, 21, 22] }, + { tag: "wrap=true, mode=End", wrap: true, mode: Tumbler.End, expectedVisibleIndices: [16, 17, 18, 19, 20] }, + // Same as Beginning; should start at 20. + { tag: "wrap=true, mode=Contain", wrap: true, mode: Tumbler.Contain, expectedVisibleIndices: [21, 22, 23, 24, 25] }, + { tag: "wrap=true, mode=SnapPosition", wrap: true, mode: Tumbler.SnapPosition, expectedVisibleIndices: [18, 19, 20, 21, 22] }, + { tag: "wrap=false, mode=Beginning", wrap: false, mode: Tumbler.Beginning, expectedVisibleIndices: [20, 21, 22, 23, 24] }, + { tag: "wrap=false, mode=Center", wrap: false, mode: Tumbler.Center, expectedVisibleIndices: [18, 19, 20, 21, 22] }, + { tag: "wrap=false, mode=End", wrap: false, mode: Tumbler.End, expectedVisibleIndices: [16, 17, 18, 19, 20] }, + { tag: "wrap=false, mode=Visible", wrap: false, mode: Tumbler.Visible, expectedVisibleIndices: [16, 17, 18, 19, 20] }, + { tag: "wrap=false, mode=Contain", wrap: false, mode: Tumbler.Contain, expectedVisibleIndices: [16, 17, 18, 19, 20] }, + { tag: "wrap=false, mode=SnapPosition", wrap: false, mode: Tumbler.SnapPosition, expectedVisibleIndices: [18, 19, 20, 21, 22] } + ] + } + + function test_positionViewAtIndex(data) { + createTumbler({ wrap: data.wrap, model: 40, visibleItemCount: 5 }) + compare(tumbler.wrap, data.wrap) + + waitForRendering(tumbler) + + tumbler.positionViewAtIndex(20, data.mode) + tryCompare(tumbler, "moving", false) + + compare(tumbler.visibleItemCount, 5) + for (var i = 0; i < 5; ++i) { + // Find the item through its text, as that's easier than child/itemAt(). + var text = data.expectedVisibleIndices[i].toString() + var item = findDelegateWithText(tumblerView, text) + verify(item, "found no item with text \"" + text + "\"") + compare(item.text, data.expectedVisibleIndices[i].toString()) + + // Ensure that it's at the position we expect. + var expectedPos = itemTopLeftPos(i) + var actualPos = testCase.mapFromItem(item, 0, 0) + compare(actualPos.x, expectedPos.x, "expected delegate with text " + item.text + + " to have an x pos of " + expectedPos.x + " but it was " + actualPos.x) + compare(actualPos.y, expectedPos.y, "expected delegate with text " + item.text + + " to have an y pos of " + expectedPos.y + " but it was " + actualPos.y) + } + } + Component { id: setCurrentIndexOnImperativeModelChangeComponent |