aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/controls/data/tst_abstractbutton.qml2
-rw-r--r--tests/auto/controls/data/tst_control.qml484
-rw-r--r--tests/auto/controls/data/tst_dial.qml99
-rw-r--r--tests/auto/controls/data/tst_dialogbuttonbox.qml52
-rw-r--r--tests/auto/controls/data/tst_frame.qml8
-rw-r--r--tests/auto/controls/data/tst_groupbox.qml8
-rw-r--r--tests/auto/controls/data/tst_label.qml152
-rw-r--r--tests/auto/controls/data/tst_page.qml8
-rw-r--r--tests/auto/controls/data/tst_pane.qml19
-rw-r--r--tests/auto/controls/data/tst_popup.qml77
-rw-r--r--tests/auto/controls/data/tst_rangeslider.qml153
-rw-r--r--tests/auto/controls/data/tst_slider.qml62
-rw-r--r--tests/auto/controls/data/tst_swipeview.qml31
-rw-r--r--tests/auto/controls/data/tst_tabbar.qml24
-rw-r--r--tests/auto/controls/data/tst_textarea.qml228
-rw-r--r--tests/auto/controls/data/tst_textfield.qml218
-rw-r--r--tests/auto/controls/data/tst_toolbar.qml8
-rw-r--r--tests/auto/controls/data/tst_tooltip.qml18
-rw-r--r--tests/auto/controls/data/tst_tumbler.qml68
-rw-r--r--tests/auto/font/tst_font.cpp133
-rw-r--r--tests/auto/palette/tst_palette.cpp179
-rw-r--r--tests/auto/qquickapplicationwindow/tst_qquickapplicationwindow.cpp18
-rw-r--r--tests/auto/qquickmaterialstyleconf/data/applicationwindow.qml5
-rw-r--r--tests/auto/qquickmaterialstyleconf/qquickmaterialstyleconf.qrc10
-rw-r--r--tests/auto/qquickmaterialstyleconf/tst_qquickmaterialstyleconf.cpp42
-rw-r--r--tests/auto/qquickmaterialstyleconf/variant-dense.conf6
-rw-r--r--tests/auto/qquickmaterialstyleconf/variant-normal.conf6
-rw-r--r--tests/auto/qquickninepatchimage/tst_qquickninepatchimage.cpp17
-rw-r--r--tests/auto/qquickstyle/qquickstyle.pro8
-rw-r--r--tests/auto/qquickstyle/qrcStyles1/QrcStyle1/Button.qml2
-rw-r--r--tests/auto/qquickstyle/qrcStyles2/QrcStyle2/Button.qml2
-rw-r--r--tests/auto/qquickstyle/tst_qquickstyle.cpp41
-rw-r--r--tests/auto/qquickstyleselector/tst_qquickstyleselector.cpp11
-rw-r--r--tests/auto/sanity/sanity.pro2
-rw-r--r--tests/auto/sanity/tst_sanity.cpp49
-rw-r--r--tests/auto/shared/util.pri1
-rw-r--r--tests/auto/shared/visualtestutil.cpp41
-rw-r--r--tests/auto/shared/visualtestutil.h2
38 files changed, 1993 insertions, 301 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 559e3b59..3106b22f 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 49fd78cc..f62c62c2 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
}
@@ -1016,8 +1035,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);
@@ -1113,6 +1132,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
diff --git a/tests/auto/font/tst_font.cpp b/tests/auto/font/tst_font.cpp
index 75942286..84f6334b 100644
--- a/tests/auto/font/tst_font.cpp
+++ b/tests/auto/font/tst_font.cpp
@@ -45,7 +45,7 @@
#include <QtQuickTemplates2/private/qquickapplicationwindow_p.h>
#include <QtQuickTemplates2/private/qquickcontrol_p.h>
#include <QtQuickTemplates2/private/qquickpopup_p.h>
-#include <QtQuickControls2/private/qquickproxytheme_p.h>
+#include <QtQuickTemplates2/private/qquicktheme_p_p.h>
using namespace QQuickVisualTestUtil;
@@ -217,95 +217,85 @@ void tst_font::inheritance()
QCOMPARE(grandChild->property("font").value<QFont>(), windowFont);
}
-class TestFontTheme : public QQuickProxyTheme
+class TestFontTheme : public QQuickTheme
{
public:
- TestFontTheme(QPlatformTheme *theme) : QQuickProxyTheme(theme)
- {
- std::fill(fonts, fonts + QPlatformTheme::NFonts, static_cast<QFont *>(0));
+ static const int NFonts = QQuickTheme::Tumbler + 1;
- for (int i = QPlatformTheme::SystemFont; i < QPlatformTheme::NFonts; ++i) {
+ TestFontTheme()
+ {
+ for (int i = 0; i < NFonts; ++i) {
QFont font = QFont();
font.setPixelSize(i + 10);
- fonts[i] = new QFont(font);
+ setFont(static_cast<Scope>(i), font);
}
-
- QGuiApplicationPrivate::platform_theme = this;
- }
-
- const QFont *font(Font type = SystemFont) const override
- {
- return fonts[type];
}
-
-private:
- QFont *fonts[QPlatformTheme::NFonts];
};
-Q_DECLARE_METATYPE(QPlatformTheme::Font)
+Q_DECLARE_METATYPE(QQuickTheme::Scope)
void tst_font::defaultFont_data()
{
QTest::addColumn<QString>("control");
- QTest::addColumn<QPlatformTheme::Font>("fontType");
-
- QTest::newRow("AbstractButton") << "AbstractButton" << QPlatformTheme::SystemFont;
- QTest::newRow("ApplicationWindow") << "ApplicationWindow" << QPlatformTheme::SystemFont;
- QTest::newRow("Button") << "Button" << QPlatformTheme::PushButtonFont;
- QTest::newRow("CheckBox") << "CheckBox" << QPlatformTheme::CheckBoxFont;
- QTest::newRow("CheckDelegate") << "CheckDelegate" << QPlatformTheme::ListViewFont;
- QTest::newRow("ComboBox") << "ComboBox" << QPlatformTheme::ComboMenuItemFont;
- QTest::newRow("Container") << "Container" << QPlatformTheme::SystemFont;
- QTest::newRow("Control") << "Control" << QPlatformTheme::SystemFont;
- QTest::newRow("Dial") << "Dial" << QPlatformTheme::SystemFont;
- QTest::newRow("Dialog") << "Dialog" << QPlatformTheme::SystemFont;
- QTest::newRow("DialogButtonBox") << "DialogButtonBox" << QPlatformTheme::SystemFont;
- QTest::newRow("Drawer") << "Drawer" << QPlatformTheme::SystemFont;
- QTest::newRow("Frame") << "Frame" << QPlatformTheme::SystemFont;
- QTest::newRow("GroupBox") << "GroupBox" << QPlatformTheme::GroupBoxTitleFont;
- QTest::newRow("ItemDelegate") << "ItemDelegate" << QPlatformTheme::ItemViewFont;
- QTest::newRow("Label") << "Label" << QPlatformTheme::LabelFont;
- QTest::newRow("Menu") << "Menu" << QPlatformTheme::MenuFont;
- QTest::newRow("MenuItem") << "MenuItem" << QPlatformTheme::MenuItemFont;
- QTest::newRow("MenuSeparator") << "MenuSeparator" << QPlatformTheme::SystemFont;
- QTest::newRow("Page") << "Page" << QPlatformTheme::SystemFont;
- QTest::newRow("Pane") << "Pane" << QPlatformTheme::SystemFont;
- QTest::newRow("Popup") << "Popup" << QPlatformTheme::SystemFont;
- QTest::newRow("ProgressBar") << "ProgressBar" << QPlatformTheme::SystemFont;
- QTest::newRow("RadioButton") << "RadioButton" << QPlatformTheme::RadioButtonFont;
- QTest::newRow("RadioDelegate") << "RadioDelegate" << QPlatformTheme::ListViewFont;
- QTest::newRow("RangeSlider") << "RangeSlider" << QPlatformTheme::SystemFont;
- QTest::newRow("RoundButton") << "RoundButton" << QPlatformTheme::PushButtonFont;
- QTest::newRow("ScrollBar") << "ScrollBar" << QPlatformTheme::SystemFont;
- QTest::newRow("ScrollIndicator") << "ScrollIndicator" << QPlatformTheme::SystemFont;
- QTest::newRow("Slider") << "Slider" << QPlatformTheme::SystemFont;
- QTest::newRow("SpinBox") << "SpinBox" << QPlatformTheme::EditorFont;
- QTest::newRow("SwipeDelegate") << "SwipeDelegate" << QPlatformTheme::ListViewFont;
- QTest::newRow("Switch") << "Switch" << QPlatformTheme::SystemFont; // ### TODO: add QPlatformTheme::SwitchFont
- QTest::newRow("SwitchDelegate") << "SwitchDelegate" << QPlatformTheme::ListViewFont;
- QTest::newRow("TabBar") << "TabBar" << QPlatformTheme::SystemFont;
- QTest::newRow("TabButton") << "TabButton" << QPlatformTheme::TabButtonFont;
- QTest::newRow("TextArea") << "TextArea" << QPlatformTheme::EditorFont;
- QTest::newRow("TextField") << "TextField" << QPlatformTheme::EditorFont;
- QTest::newRow("ToolBar") << "ToolBar" << QPlatformTheme::SystemFont;
- QTest::newRow("ToolButton") << "ToolButton" << QPlatformTheme::ToolButtonFont;
- QTest::newRow("ToolSeparator") << "ToolSeparator" << QPlatformTheme::SystemFont;
- QTest::newRow("ToolTip") << "ToolTip" << QPlatformTheme::TipLabelFont;
- QTest::newRow("Tumbler") << "Tumbler" << QPlatformTheme::ItemViewFont;
+ QTest::addColumn<QQuickTheme::Scope>("scope");
+
+ QTest::newRow("AbstractButton") << "AbstractButton" << QQuickTheme::System;
+ QTest::newRow("ApplicationWindow") << "ApplicationWindow" << QQuickTheme::System;
+ QTest::newRow("Button") << "Button" << QQuickTheme::Button;
+ QTest::newRow("CheckBox") << "CheckBox" << QQuickTheme::CheckBox;
+ QTest::newRow("CheckDelegate") << "CheckDelegate" << QQuickTheme::ListView;
+ QTest::newRow("ComboBox") << "ComboBox" << QQuickTheme::ComboBox;
+ QTest::newRow("Container") << "Container" << QQuickTheme::System;
+ QTest::newRow("Control") << "Control" << QQuickTheme::System;
+ QTest::newRow("Dial") << "Dial" << QQuickTheme::System;
+ QTest::newRow("Dialog") << "Dialog" << QQuickTheme::System;
+ QTest::newRow("DialogButtonBox") << "DialogButtonBox" << QQuickTheme::System;
+ QTest::newRow("Drawer") << "Drawer" << QQuickTheme::System;
+ QTest::newRow("Frame") << "Frame" << QQuickTheme::System;
+ QTest::newRow("GroupBox") << "GroupBox" << QQuickTheme::GroupBox;
+ QTest::newRow("ItemDelegate") << "ItemDelegate" << QQuickTheme::ItemView;
+ QTest::newRow("Label") << "Label" << QQuickTheme::Label;
+ QTest::newRow("Menu") << "Menu" << QQuickTheme::Menu;
+ QTest::newRow("MenuItem") << "MenuItem" << QQuickTheme::Menu;
+ QTest::newRow("MenuSeparator") << "MenuSeparator" << QQuickTheme::Menu;
+ QTest::newRow("Page") << "Page" << QQuickTheme::System;
+ QTest::newRow("Pane") << "Pane" << QQuickTheme::System;
+ QTest::newRow("Popup") << "Popup" << QQuickTheme::System;
+ QTest::newRow("ProgressBar") << "ProgressBar" << QQuickTheme::System;
+ QTest::newRow("RadioButton") << "RadioButton" << QQuickTheme::RadioButton;
+ QTest::newRow("RadioDelegate") << "RadioDelegate" << QQuickTheme::ListView;
+ QTest::newRow("RangeSlider") << "RangeSlider" << QQuickTheme::System;
+ QTest::newRow("RoundButton") << "RoundButton" << QQuickTheme::Button;
+ QTest::newRow("ScrollBar") << "ScrollBar" << QQuickTheme::System;
+ QTest::newRow("ScrollIndicator") << "ScrollIndicator" << QQuickTheme::System;
+ QTest::newRow("Slider") << "Slider" << QQuickTheme::System;
+ QTest::newRow("SpinBox") << "SpinBox" << QQuickTheme::SpinBox;
+ QTest::newRow("SwipeDelegate") << "SwipeDelegate" << QQuickTheme::ListView;
+ QTest::newRow("Switch") << "Switch" << QQuickTheme::Switch;
+ QTest::newRow("SwitchDelegate") << "SwitchDelegate" << QQuickTheme::ListView;
+ QTest::newRow("TabBar") << "TabBar" << QQuickTheme::TabBar;
+ QTest::newRow("TabButton") << "TabButton" << QQuickTheme::TabBar;
+ QTest::newRow("TextArea") << "TextArea" << QQuickTheme::TextArea;
+ QTest::newRow("TextField") << "TextField" << QQuickTheme::TextField;
+ QTest::newRow("ToolBar") << "ToolBar" << QQuickTheme::ToolBar;
+ QTest::newRow("ToolButton") << "ToolButton" << QQuickTheme::ToolBar;
+ QTest::newRow("ToolSeparator") << "ToolSeparator" << QQuickTheme::ToolBar;
+ QTest::newRow("ToolTip") << "ToolTip" << QQuickTheme::ToolTip;
+ QTest::newRow("Tumbler") << "Tumbler" << QQuickTheme::Tumbler;
}
void tst_font::defaultFont()
{
QFETCH(QString, control);
- QFETCH(QPlatformTheme::Font, fontType);
+ QFETCH(QQuickTheme::Scope, scope);
QQmlEngine engine;
QQmlComponent component(&engine);
component.setData(QString("import QtQuick.Controls 2.2; %1 { }").arg(control).toUtf8(), QUrl());
- // The call to setData() above causes QQuickDefaultTheme to be set as the platform theme,
+ // The call to setData() above causes QQuickDefaultTheme to be set as the current theme,
// so we must make sure we only set our theme afterwards.
- TestFontTheme theme(QGuiApplicationPrivate::platform_theme);
+ QQuickThemePrivate::instance.reset(new TestFontTheme);
QScopedPointer<QObject> object(component.create());
QVERIFY2(!object.isNull(), qPrintable(component.errorString()));
@@ -313,16 +303,9 @@ void tst_font::defaultFont()
QVariant var = object->property("font");
QVERIFY(var.isValid());
- const QFont *expectedFont = theme.font(fontType);
- QVERIFY(expectedFont);
-
+ QFont expectedFont = QQuickTheme::font(scope);
QFont actualFont = var.value<QFont>();
-
- if (actualFont != *expectedFont) {
- qDebug() << QTest::currentDataTag() << actualFont << *expectedFont;
- }
-
- QCOMPARE(actualFont, *expectedFont);
+ QCOMPARE(actualFont, expectedFont);
}
void tst_font::listView_data()
diff --git a/tests/auto/palette/tst_palette.cpp b/tests/auto/palette/tst_palette.cpp
index f74e358a..e91fd732 100644
--- a/tests/auto/palette/tst_palette.cpp
+++ b/tests/auto/palette/tst_palette.cpp
@@ -38,7 +38,6 @@
#include "../shared/visualtestutil.h"
#include <QtGui/qpalette.h>
-#include <QtGui/qpa/qplatformtheme.h>
#include <QtGui/private/qguiapplication_p.h>
#include <QtQml/qqmlengine.h>
#include <QtQml/qqmlcomponent.h>
@@ -46,7 +45,7 @@
#include <QtQuickTemplates2/private/qquickcontrol_p.h>
#include <QtQuickTemplates2/private/qquickcontrol_p_p.h>
#include <QtQuickTemplates2/private/qquickpopup_p.h>
-#include <QtQuickControls2/private/qquickproxytheme_p.h>
+#include <QtQuickTemplates2/private/qquicktheme_p_p.h>
using namespace QQuickVisualTestUtil;
@@ -88,7 +87,7 @@ void tst_palette::palette_data()
QTest::addColumn<QString>("testFile");
QTest::addColumn<QPalette>("expectedPalette");
- QPalette defaultPalette = QQuickControlPrivate::themePalette(QPlatformTheme::SystemPalette);
+ QPalette defaultPalette = QQuickTheme::palette(QQuickTheme::System);
defaultPalette.setColor(QPalette::Base, QColor("#efefef"));
defaultPalette.setColor(QPalette::Text, QColor("#101010"));
@@ -172,7 +171,7 @@ void tst_palette::inheritance()
QObject *grandChild = window->property("grandChild").value<QObject *>();
QVERIFY(control && child && grandChild);
- QPalette defaultPalette = QQuickControlPrivate::themePalette(QPlatformTheme::SystemPalette);
+ QPalette defaultPalette = QQuickTheme::palette(QQuickTheme::System);
defaultPalette.setColor(QPalette::Base, QColor("#efefef"));
defaultPalette.setColor(QPalette::Text, QColor("#101010"));
@@ -217,148 +216,92 @@ void tst_palette::inheritance()
QCOMPARE(grandChild->property("palette").value<QPalette>(), windowPalette);
}
-class TestTheme : public QQuickProxyTheme
+class TestTheme : public QQuickTheme
{
public:
- TestTheme(QPlatformTheme *theme) : QQuickProxyTheme(theme)
- {
- std::fill(palettes, palettes + QPlatformTheme::NPalettes, static_cast<QPalette *>(0));
-
- QPalette palette = QPalette();
- palette.setColor(QPalette::Window, Qt::gray);
- palettes[QPlatformTheme::SystemPalette] = new QPalette(palette);
-
- palette.setColor(QPalette::ToolTipBase, Qt::yellow);
- palettes[QPlatformTheme::ToolTipPalette] = new QPalette(palette);
-
- palette.setColor(QPalette::ButtonText, Qt::blue);
- palettes[QPlatformTheme::ToolButtonPalette] = new QPalette(palette);
-
- palette.setColor(QPalette::Button, Qt::red);
- palettes[QPlatformTheme::ButtonPalette] = new QPalette(palette);
-
- palette.setColor(QPalette::Text, Qt::green);
- palettes[QPlatformTheme::CheckBoxPalette] = new QPalette(palette);
-
- palette.setColor(QPalette::Text, Qt::blue);
- palettes[QPlatformTheme::RadioButtonPalette] = new QPalette(palette);
-
- // HeaderPalette unused
-
- palette.setColor(QPalette::Base, Qt::darkGray);
- palettes[QPlatformTheme::ComboBoxPalette] = new QPalette(palette);
-
- palette.setColor(QPalette::Base, Qt::lightGray);
- palettes[QPlatformTheme::ItemViewPalette] = new QPalette(palette);
-
- // MessageBoxLabelPalette unused
-
- palette.setColor(QPalette::ButtonText, Qt::white);
- palettes[QPlatformTheme::TabBarPalette] = new QPalette(palette);
-
- palette.setColor(QPalette::WindowText, Qt::darkGray);
- palettes[QPlatformTheme::LabelPalette] = new QPalette(palette);
+ static const int NPalettes = QQuickTheme::Tumbler + 1;
- palette.setColor(QPalette::Mid, Qt::gray);
- palettes[QPlatformTheme::GroupBoxPalette] = new QPalette(palette);
-
- palette.setColor(QPalette::Shadow, Qt::darkYellow);
- palettes[QPlatformTheme::MenuPalette] = new QPalette(palette);
-
- // MenuBarPalette unused
-
- palette.setColor(QPalette::Base, Qt::cyan);
- palettes[QPlatformTheme::TextEditPalette] = new QPalette(palette);
-
- palette.setColor(QPalette::Base, Qt::magenta);
- palettes[QPlatformTheme::TextLineEditPalette] = new QPalette(palette);
-
- QGuiApplicationPrivate::platform_theme = this;
- }
-
- const QPalette *palette(Palette type = SystemPalette) const override
+ TestTheme()
{
- return palettes[type];
+ for (int i = 0; i < NPalettes; ++i)
+ setPalette(static_cast<Scope>(i), QPalette(QColor::fromRgb(i)));
}
-
-private:
- QPalette *palettes[QPlatformTheme::NPalettes];
};
-Q_DECLARE_METATYPE(QPlatformTheme::Palette)
+Q_DECLARE_METATYPE(QQuickTheme::Scope)
void tst_palette::defaultPalette_data()
{
QTest::addColumn<QString>("control");
- QTest::addColumn<QPlatformTheme::Palette>("paletteType");
-
- QTest::newRow("AbstractButton") << "AbstractButton" << QPlatformTheme::SystemPalette;
- QTest::newRow("ApplicationWindow") << "ApplicationWindow" << QPlatformTheme::SystemPalette;
- QTest::newRow("Button") << "Button" << QPlatformTheme::ButtonPalette;
- QTest::newRow("CheckBox") << "CheckBox" << QPlatformTheme::CheckBoxPalette;
- QTest::newRow("CheckDelegate") << "CheckDelegate" << QPlatformTheme::ItemViewPalette;
- QTest::newRow("ComboBox") << "ComboBox" << QPlatformTheme::ComboBoxPalette;
- QTest::newRow("Container") << "Container" << QPlatformTheme::SystemPalette;
- QTest::newRow("Control") << "Control" << QPlatformTheme::SystemPalette;
- QTest::newRow("Dial") << "Dial" << QPlatformTheme::SystemPalette;
- QTest::newRow("Dialog") << "Dialog" << QPlatformTheme::SystemPalette;
- QTest::newRow("DialogButtonBox") << "DialogButtonBox" << QPlatformTheme::SystemPalette;
- QTest::newRow("Drawer") << "Drawer" << QPlatformTheme::SystemPalette;
- QTest::newRow("Frame") << "Frame" << QPlatformTheme::SystemPalette;
- QTest::newRow("GroupBox") << "GroupBox" << QPlatformTheme::GroupBoxPalette;
- QTest::newRow("ItemDelegate") << "ItemDelegate" << QPlatformTheme::ItemViewPalette;
- QTest::newRow("Label") << "Label" << QPlatformTheme::LabelPalette;
- QTest::newRow("Menu") << "Menu" << QPlatformTheme::MenuPalette;
- QTest::newRow("MenuItem") << "MenuItem" << QPlatformTheme::MenuPalette;
- QTest::newRow("MenuSeparator") << "MenuSeparator" << QPlatformTheme::MenuPalette;
- QTest::newRow("Page") << "Page" << QPlatformTheme::SystemPalette;
- QTest::newRow("Pane") << "Pane" << QPlatformTheme::SystemPalette;
- QTest::newRow("Popup") << "Popup" << QPlatformTheme::SystemPalette;
- QTest::newRow("ProgressBar") << "ProgressBar" << QPlatformTheme::SystemPalette;
- QTest::newRow("RadioButton") << "RadioButton" << QPlatformTheme::RadioButtonPalette;
- QTest::newRow("RadioDelegate") << "RadioDelegate" << QPlatformTheme::ItemViewPalette;
- QTest::newRow("RangeSlider") << "RangeSlider" << QPlatformTheme::SystemPalette;
- QTest::newRow("RoundButton") << "RoundButton" << QPlatformTheme::ButtonPalette;
- QTest::newRow("ScrollBar") << "ScrollBar" << QPlatformTheme::SystemPalette;
- QTest::newRow("ScrollIndicator") << "ScrollIndicator" << QPlatformTheme::SystemPalette;
- QTest::newRow("Slider") << "Slider" << QPlatformTheme::SystemPalette;
- QTest::newRow("SpinBox") << "SpinBox" << QPlatformTheme::TextLineEditPalette;
- QTest::newRow("SwipeDelegate") << "SwipeDelegate" << QPlatformTheme::ItemViewPalette;
- QTest::newRow("Switch") << "Switch" << QPlatformTheme::CheckBoxPalette; // ### TODO: add QPlatformTheme::SwitchPalette
- QTest::newRow("SwitchDelegate") << "SwitchDelegate" << QPlatformTheme::ItemViewPalette;
- QTest::newRow("TabBar") << "TabBar" << QPlatformTheme::TabBarPalette;
- QTest::newRow("TabButton") << "TabButton" << QPlatformTheme::TabBarPalette;
- QTest::newRow("TextArea") << "TextArea" << QPlatformTheme::TextEditPalette;
- QTest::newRow("TextField") << "TextField" << QPlatformTheme::TextLineEditPalette;
- QTest::newRow("ToolBar") << "ToolBar" << QPlatformTheme::ToolButtonPalette;
- QTest::newRow("ToolButton") << "ToolButton" << QPlatformTheme::ToolButtonPalette;
- QTest::newRow("ToolSeparator") << "ToolSeparator" << QPlatformTheme::ToolButtonPalette;
- QTest::newRow("ToolTip") << "ToolTip" << QPlatformTheme::ToolTipPalette;
- QTest::newRow("Tumbler") << "Tumbler" << QPlatformTheme::ItemViewPalette;
+ QTest::addColumn<QQuickTheme::Scope>("scope");
+
+ QTest::newRow("AbstractButton") << "AbstractButton" << QQuickTheme::System;
+ QTest::newRow("ApplicationWindow") << "ApplicationWindow" << QQuickTheme::System;
+ QTest::newRow("Button") << "Button" << QQuickTheme::Button;
+ QTest::newRow("CheckBox") << "CheckBox" << QQuickTheme::CheckBox;
+ QTest::newRow("CheckDelegate") << "CheckDelegate" << QQuickTheme::ListView;
+ QTest::newRow("ComboBox") << "ComboBox" << QQuickTheme::ComboBox;
+ QTest::newRow("Container") << "Container" << QQuickTheme::System;
+ QTest::newRow("Control") << "Control" << QQuickTheme::System;
+ QTest::newRow("Dial") << "Dial" << QQuickTheme::System;
+ QTest::newRow("Dialog") << "Dialog" << QQuickTheme::System;
+ QTest::newRow("DialogButtonBox") << "DialogButtonBox" << QQuickTheme::System;
+ QTest::newRow("Drawer") << "Drawer" << QQuickTheme::System;
+ QTest::newRow("Frame") << "Frame" << QQuickTheme::System;
+ QTest::newRow("GroupBox") << "GroupBox" << QQuickTheme::GroupBox;
+ QTest::newRow("ItemDelegate") << "ItemDelegate" << QQuickTheme::ItemView;
+ QTest::newRow("Label") << "Label" << QQuickTheme::Label;
+ QTest::newRow("Menu") << "Menu" << QQuickTheme::Menu;
+ QTest::newRow("MenuItem") << "MenuItem" << QQuickTheme::Menu;
+ QTest::newRow("MenuSeparator") << "MenuSeparator" << QQuickTheme::Menu;
+ QTest::newRow("Page") << "Page" << QQuickTheme::System;
+ QTest::newRow("Pane") << "Pane" << QQuickTheme::System;
+ QTest::newRow("Popup") << "Popup" << QQuickTheme::System;
+ QTest::newRow("ProgressBar") << "ProgressBar" << QQuickTheme::System;
+ QTest::newRow("RadioButton") << "RadioButton" << QQuickTheme::RadioButton;
+ QTest::newRow("RadioDelegate") << "RadioDelegate" << QQuickTheme::ListView;
+ QTest::newRow("RangeSlider") << "RangeSlider" << QQuickTheme::System;
+ QTest::newRow("RoundButton") << "RoundButton" << QQuickTheme::Button;
+ QTest::newRow("ScrollBar") << "ScrollBar" << QQuickTheme::System;
+ QTest::newRow("ScrollIndicator") << "ScrollIndicator" << QQuickTheme::System;
+ QTest::newRow("Slider") << "Slider" << QQuickTheme::System;
+ QTest::newRow("SpinBox") << "SpinBox" << QQuickTheme::SpinBox;
+ QTest::newRow("SwipeDelegate") << "SwipeDelegate" << QQuickTheme::ListView;
+ QTest::newRow("Switch") << "Switch" << QQuickTheme::Switch;
+ QTest::newRow("SwitchDelegate") << "SwitchDelegate" << QQuickTheme::ListView;
+ QTest::newRow("TabBar") << "TabBar" << QQuickTheme::TabBar;
+ QTest::newRow("TabButton") << "TabButton" << QQuickTheme::TabBar;
+ QTest::newRow("TextArea") << "TextArea" << QQuickTheme::TextArea;
+ QTest::newRow("TextField") << "TextField" << QQuickTheme::TextField;
+ QTest::newRow("ToolBar") << "ToolBar" << QQuickTheme::ToolBar;
+ QTest::newRow("ToolButton") << "ToolButton" << QQuickTheme::ToolBar;
+ QTest::newRow("ToolSeparator") << "ToolSeparator" << QQuickTheme::ToolBar;
+ QTest::newRow("ToolTip") << "ToolTip" << QQuickTheme::ToolTip;
+ QTest::newRow("Tumbler") << "Tumbler" << QQuickTheme::Tumbler;
}
void tst_palette::defaultPalette()
{
QFETCH(QString, control);
- QFETCH(QPlatformTheme::Palette, paletteType);
-
- TestTheme theme(QGuiApplicationPrivate::platform_theme);
+ QFETCH(QQuickTheme::Scope, scope);
QQmlEngine engine;
QQmlComponent component(&engine);
component.setData(QString("import QtQuick.Controls 2.3; %1 { }").arg(control).toUtf8(), QUrl());
+ // The call to setData() above causes QQuickDefaultTheme to be set as the current theme,
+ // so we must make sure we only set our theme afterwards.
+ QQuickThemePrivate::instance.reset(new TestTheme);
+
QScopedPointer<QObject> object(component.create());
QVERIFY2(!object.isNull(), qPrintable(component.errorString()));
QVariant var = object->property("palette");
QVERIFY(var.isValid());
- const QPalette *expectedPalette = theme.palette(paletteType);
- QVERIFY(expectedPalette);
-
+ QPalette expectedPalette = QQuickTheme::palette(scope);
QPalette actualPalette = var.value<QPalette>();
- QCOMPARE(actualPalette, *expectedPalette);
+ QCOMPARE(actualPalette, expectedPalette);
}
void tst_palette::listView_data()
diff --git a/tests/auto/qquickapplicationwindow/tst_qquickapplicationwindow.cpp b/tests/auto/qquickapplicationwindow/tst_qquickapplicationwindow.cpp
index aeeddb10..dec32e36 100644
--- a/tests/auto/qquickapplicationwindow/tst_qquickapplicationwindow.cpp
+++ b/tests/auto/qquickapplicationwindow/tst_qquickapplicationwindow.cpp
@@ -50,7 +50,7 @@
#include <QtQuickTemplates2/private/qquickpopup_p.h>
#include <QtQuickTemplates2/private/qquicktextarea_p.h>
#include <QtQuickTemplates2/private/qquicktextfield_p.h>
-#include <QtQuickControls2/private/qquickproxytheme_p.h>
+#include <QtQuickTemplates2/private/qquicktheme_p_p.h>
#include "../shared/util.h"
#include "../shared/visualtestutil.h"
@@ -555,24 +555,18 @@ void tst_QQuickApplicationWindow::font()
QCOMPARE(item6->font(), font);
}
-class TestTheme : public QQuickProxyTheme
+class TestTheme : public QQuickTheme
{
public:
- TestTheme(QPlatformTheme *theme) : QQuickProxyTheme(theme), m_font("Courier")
- { QGuiApplicationPrivate::platform_theme = this; }
-
- const QFont *font(Font type = SystemFont) const override
+ TestTheme()
{
- Q_UNUSED(type);
- return &m_font;
+ setFont(System, QFont("Courier"));
}
-
- QFont m_font;
};
void tst_QQuickApplicationWindow::defaultFont()
{
- TestTheme theme(QGuiApplicationPrivate::platform_theme);
+ QQuickThemePrivate::instance.reset(new TestTheme);
QQmlEngine engine;
QQmlComponent component(&engine);
@@ -581,7 +575,7 @@ void tst_QQuickApplicationWindow::defaultFont()
QScopedPointer<QQuickApplicationWindow> window;
window.reset(static_cast<QQuickApplicationWindow *>(component.create()));
QVERIFY(!window.isNull());
- QCOMPARE(window->font(), *theme.font());
+ QCOMPARE(window->font(), QQuickTheme::font(QQuickTheme::System));
}
void tst_QQuickApplicationWindow::locale()
diff --git a/tests/auto/qquickmaterialstyleconf/data/applicationwindow.qml b/tests/auto/qquickmaterialstyleconf/data/applicationwindow.qml
index 65196393..9a31966f 100644
--- a/tests/auto/qquickmaterialstyleconf/data/applicationwindow.qml
+++ b/tests/auto/qquickmaterialstyleconf/data/applicationwindow.qml
@@ -57,8 +57,13 @@ ApplicationWindow {
height: 400
property alias label: label
+ property alias button: button
Label {
id: label
}
+
+ Button {
+ id: button
+ }
}
diff --git a/tests/auto/qquickmaterialstyleconf/qquickmaterialstyleconf.qrc b/tests/auto/qquickmaterialstyleconf/qquickmaterialstyleconf.qrc
index 53ba6450..49219139 100644
--- a/tests/auto/qquickmaterialstyleconf/qquickmaterialstyleconf.qrc
+++ b/tests/auto/qquickmaterialstyleconf/qquickmaterialstyleconf.qrc
@@ -1,5 +1,7 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource>
- <file>qtquickcontrols2.conf</file>
-</qresource>
+<RCC>
+ <qresource prefix="/">
+ <file>qtquickcontrols2.conf</file>
+ <file>variant-dense.conf</file>
+ <file>variant-normal.conf</file>
+ </qresource>
</RCC>
diff --git a/tests/auto/qquickmaterialstyleconf/tst_qquickmaterialstyleconf.cpp b/tests/auto/qquickmaterialstyleconf/tst_qquickmaterialstyleconf.cpp
index 17d1ea6d..72136445 100644
--- a/tests/auto/qquickmaterialstyleconf/tst_qquickmaterialstyleconf.cpp
+++ b/tests/auto/qquickmaterialstyleconf/tst_qquickmaterialstyleconf.cpp
@@ -36,6 +36,7 @@
#include <qtest.h>
#include <QtQuick/private/qquickitem_p.h>
+#include <QtQuickControls2/private/qquickstyle_p.h>
#include "../shared/util.h"
#include "../shared/visualtestutil.h"
@@ -49,6 +50,8 @@ public:
private slots:
void conf();
+ void variants_data();
+ void variants();
};
void tst_qquickmaterialstyleconf::conf()
@@ -73,6 +76,45 @@ void tst_qquickmaterialstyleconf::conf()
QCOMPARE(label->property("font").value<QFont>(), customFont);
}
+void tst_qquickmaterialstyleconf::variants_data()
+{
+ QTest::addColumn<QByteArray>("confPath");
+ QTest::addColumn<int>("expectedButtonHeight");
+ // Just to ensure that the correct conf is loaded.
+ QTest::addColumn<QColor>("expectedColor");
+
+ // (36 button height + 12 touchable area)
+ QTest::newRow("normal") << QByteArray(":/variant-normal.conf") << 48 << QColor::fromRgb(0x123456);
+ // We specified a custom variant (dense), so the button should be small.
+ // (32 button height + 12 touchable area)
+ QTest::newRow("dense") << QByteArray(":/variant-dense.conf") << 44 << QColor::fromRgb(0x789abc);
+}
+
+void tst_qquickmaterialstyleconf::variants()
+{
+ QFETCH(QByteArray, confPath);
+ QFETCH(int, expectedButtonHeight);
+ QFETCH(QColor, expectedColor);
+
+ qmlClearTypeRegistrations();
+ QQuickStylePrivate::reset();
+ qputenv("QT_QUICK_CONTROLS_CONF", confPath);
+
+ QQuickApplicationHelper helper(this, QLatin1String("applicationwindow.qml"));
+
+ QQuickApplicationWindow *window = helper.appWindow;
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window));
+
+ QQuickItem *label = window->property("label").value<QQuickItem*>();
+ QVERIFY(label);
+ QCOMPARE(label->property("color").value<QColor>(), expectedColor);
+
+ QQuickItem *button = window->property("button").value<QQuickItem*>();
+ QVERIFY(button);
+ QCOMPARE(button->height(), expectedButtonHeight);
+}
+
QTEST_MAIN(tst_qquickmaterialstyleconf)
#include "tst_qquickmaterialstyleconf.moc"
diff --git a/tests/auto/qquickmaterialstyleconf/variant-dense.conf b/tests/auto/qquickmaterialstyleconf/variant-dense.conf
new file mode 100644
index 00000000..6636894e
--- /dev/null
+++ b/tests/auto/qquickmaterialstyleconf/variant-dense.conf
@@ -0,0 +1,6 @@
+[Controls]
+Style=Material
+
+[Material]
+Variant=Dense
+Foreground=#789abc
diff --git a/tests/auto/qquickmaterialstyleconf/variant-normal.conf b/tests/auto/qquickmaterialstyleconf/variant-normal.conf
new file mode 100644
index 00000000..08778e92
--- /dev/null
+++ b/tests/auto/qquickmaterialstyleconf/variant-normal.conf
@@ -0,0 +1,6 @@
+[Controls]
+Style=Material
+
+[Material]
+Variant=Normal
+Foreground=#123456
diff --git a/tests/auto/qquickninepatchimage/tst_qquickninepatchimage.cpp b/tests/auto/qquickninepatchimage/tst_qquickninepatchimage.cpp
index b5dd7f2f..5a62c00a 100644
--- a/tests/auto/qquickninepatchimage/tst_qquickninepatchimage.cpp
+++ b/tests/auto/qquickninepatchimage/tst_qquickninepatchimage.cpp
@@ -210,11 +210,20 @@ void tst_qquickninepatchimage::implicitSize_data()
QTest::addColumn<QString>("file");
QTest::addColumn<QSizeF>("implicitSize");
- const QStringList files = QStringList() << "foo.9.png" << "padding.9.png" << "inset-all.9.png" << "inset-topleft.9.png" << "inset-bottomright.9.png";
-
- for (const QString &file : files) {
+ const struct TestFile {
+ QString name;
+ QSizeF sizeHint;
+ } testFiles [] = {
+ { "foo.9.png", QSizeF(40, 40) },
+ { "padding.9.png", QSizeF(40, 40) },
+ { "inset-all.9.png", QSizeF(45, 45) },
+ { "inset-topleft.9.png", QSizeF(42, 41) },
+ { "inset-bottomright.9.png", QSizeF(43, 44) }
+ };
+
+ for (const TestFile &file : testFiles) {
for (int dpr = 1; dpr <= 4; ++dpr)
- QTest::newRow(qPrintable(QString::fromLatin1("%1 DPR=%2").arg(file).arg(dpr))) << dpr << file << QSizeF(40, 40);
+ QTest::newRow(qPrintable(QString::fromLatin1("%1 DPR=%2").arg(file.name).arg(dpr))) << dpr << file.name << file.sizeHint;
}
}
diff --git a/tests/auto/qquickstyle/qquickstyle.pro b/tests/auto/qquickstyle/qquickstyle.pro
index da74b6cd..983e5438 100644
--- a/tests/auto/qquickstyle/qquickstyle.pro
+++ b/tests/auto/qquickstyle/qquickstyle.pro
@@ -10,3 +10,11 @@ QT_PRIVATE += core-private gui-private quickcontrols2-private
include (../shared/util.pri)
TESTDATA = $$PWD/data/*
+
+qrcStyles1.files = $$files(qrcStyles1/QrcStyle1/*.qml)
+qrcStyles1.prefix = /
+RESOURCES += qrcStyles1
+
+qrcStyles2.files = $$files(qrcStyles2/QrcStyle2/*.qml)
+qrcStyles2.prefix = /
+RESOURCES += qrcStyles2
diff --git a/tests/auto/qquickstyle/qrcStyles1/QrcStyle1/Button.qml b/tests/auto/qquickstyle/qrcStyles1/QrcStyle1/Button.qml
new file mode 100644
index 00000000..5b08222c
--- /dev/null
+++ b/tests/auto/qquickstyle/qrcStyles1/QrcStyle1/Button.qml
@@ -0,0 +1,2 @@
+import QtQuick.Templates 2.0 as T
+T.Button { }
diff --git a/tests/auto/qquickstyle/qrcStyles2/QrcStyle2/Button.qml b/tests/auto/qquickstyle/qrcStyles2/QrcStyle2/Button.qml
new file mode 100644
index 00000000..5b08222c
--- /dev/null
+++ b/tests/auto/qquickstyle/qrcStyles2/QrcStyle2/Button.qml
@@ -0,0 +1,2 @@
+import QtQuick.Templates 2.0 as T
+T.Button { }
diff --git a/tests/auto/qquickstyle/tst_qquickstyle.cpp b/tests/auto/qquickstyle/tst_qquickstyle.cpp
index 4a34f24a..324d0b08 100644
--- a/tests/auto/qquickstyle/tst_qquickstyle.cpp
+++ b/tests/auto/qquickstyle/tst_qquickstyle.cpp
@@ -55,6 +55,8 @@ private slots:
void commandLineArgument();
void environmentVariables();
void availableStyles();
+ void qrcStylePaths_data();
+ void qrcStylePaths();
private:
void loadControls();
@@ -151,8 +153,8 @@ void tst_QQuickStyle::availableStyles()
{
QString path = QFINDTESTDATA("data");
QVERIFY(!path.isEmpty());
- qputenv("QT_QUICK_CONTROLS_STYLE_PATH", path.toLocal8Bit());
+ QQuickStyle::addStylePath(path);
QStringList paths = QQuickStylePrivate::stylePaths();
QVERIFY(paths.contains(path));
@@ -167,6 +169,43 @@ void tst_QQuickStyle::availableStyles()
}
}
+void tst_QQuickStyle::qrcStylePaths_data()
+{
+ QTest::addColumn<QString>("stylePath");
+ QTest::addColumn<QString>("expectedStyleName");
+
+ QTest::addRow("qrc:/qrcStyles1") << QString::fromLatin1("qrc:/qrcStyles1") << QString::fromLatin1("QrcStyle1");
+ QTest::addRow(":/qrcStyles2") << QString::fromLatin1(":/qrcStyles2") << QString::fromLatin1("QrcStyle2");
+}
+
+void tst_QQuickStyle::qrcStylePaths()
+{
+ QFETCH(QString, stylePath);
+ QFETCH(QString, expectedStyleName);
+
+ QQuickStyle::addStylePath(stylePath);
+
+ const QStringList paths = QQuickStylePrivate::stylePaths();
+ QString expectedStylePath = stylePath;
+ if (expectedStylePath.startsWith(QLatin1String("qrc")))
+ expectedStylePath.remove(0, 3);
+ if (!paths.contains(expectedStylePath)) {
+ QString message;
+ QDebug stream(&message);
+ stream.nospace() << "QQuickStylePrivate::stylePaths() doesn't contain " << expectedStylePath << ":\n" << paths;
+ QFAIL(qPrintable(message));
+ }
+
+ const QStringList styles = QQuickStyle::availableStyles();
+ QVERIFY(!styles.isEmpty());
+ if (!styles.contains(expectedStyleName)) {
+ QString message;
+ QDebug stream(&message);
+ stream.nospace() << "QQuickStyle::availableStyles() doesn't contain " << expectedStyleName << ":\n" << styles;
+ QFAIL(qPrintable(message));
+ }
+}
+
QTEST_MAIN(tst_QQuickStyle)
#include "tst_qquickstyle.moc"
diff --git a/tests/auto/qquickstyleselector/tst_qquickstyleselector.cpp b/tests/auto/qquickstyleselector/tst_qquickstyleselector.cpp
index e90a8bd9..ce2e2e99 100644
--- a/tests/auto/qquickstyleselector/tst_qquickstyleselector.cpp
+++ b/tests/auto/qquickstyleselector/tst_qquickstyleselector.cpp
@@ -96,7 +96,7 @@ void tst_QQuickStyleSelector::select_data()
QTest::newRow("nosuch/label") << "Label.qml" << "NoSuchStyle" << "data" << "" << testFileUrl("Label.qml").toString();
QTest::newRow("/nosuch/label") << "Label.qml" << "NoSuchStyle" << dataDirectory() << "" << testFileUrl("Label.qml").toString();
- QTest::newRow("label->base") << "Label.qml" << "" << "data" << "FallbackStyle" << testFileUrl("FallbackStyle/Label.qml").toString();
+ QTest::newRow("label->base") << "Label.qml" << "" << "data" << "FallbackStyle" << testFileUrl("Label.qml").toString();
QTest::newRow("/label->base") << "Label.qml" << "" << dataDirectory() << "FallbackStyle" << testFileUrl("Label.qml").toString();
QTest::newRow("fs/label->base") << "Label.qml" << "FileSystemStyle" << "data" << "FallbackStyle" << testFileUrl("FallbackStyle/Label.qml").toString();
QTest::newRow("/fs/label->base") << "Label.qml" << "FileSystemStyle" << dataDirectory() << "FallbackStyle" << testFileUrl("FallbackStyle/Label.qml").toString();
@@ -115,7 +115,7 @@ void tst_QQuickStyleSelector::select_data()
QTest::newRow("nosuch/button") << "Button.qml" << "NoSuchStyle" << "data" << "" << testFileUrl("Button.qml").toString();
QTest::newRow("/nosuch/button") << "Button.qml" << "NoSuchStyle" << dataDirectory() << "" << testFileUrl("Button.qml").toString();
- QTest::newRow("button->base") << "Button.qml" << "" << "data" << "FallbackStyle" << testFileUrl("FallbackStyle/Button.qml").toString();
+ QTest::newRow("button->base") << "Button.qml" << "" << "data" << "FallbackStyle" << testFileUrl("Button.qml").toString();
QTest::newRow("/button->base") << "Button.qml" << "" << dataDirectory() << "FallbackStyle" << testFileUrl("Button.qml").toString();
QTest::newRow("fs/button->base") << "Button.qml" << "FileSystemStyle" << "data" << "FallbackStyle" << testFileUrl("FileSystemStyle/Button.qml").toString();
QTest::newRow("/fs/button->base") << "Button.qml" << "FileSystemStyle" << dataDirectory() << "FallbackStyle" << testFileUrl("FileSystemStyle/Button.qml").toString();
@@ -137,7 +137,9 @@ void tst_QQuickStyleSelector::select()
QQuickStyle::setFallbackStyle(fallback);
QQuickStyleSelector selector;
- selector.setBaseUrl(dataDirectoryUrl());
+ selector.addSelector(style);
+ selector.addSelector(fallback);
+ selector.setPaths(QStringList() << dataDirectory() << ":/");
QCOMPARE(selector.select(file), expected);
}
@@ -146,7 +148,8 @@ void tst_QQuickStyleSelector::platformSelectors()
QQuickStyle::setStyle(QDir(dataDirectory()).filePath("PlatformStyle"));
QQuickStyleSelector selector;
- selector.setBaseUrl(dataDirectoryUrl());
+ selector.addSelector("PlatformStyle");
+ selector.setPaths(QStringList() << dataDirectory());
#if defined(Q_OS_LINUX)
QCOMPARE(selector.select("Button.qml"), testFileUrl("PlatformStyle/+linux/Button.qml").toString());
diff --git a/tests/auto/sanity/sanity.pro b/tests/auto/sanity/sanity.pro
index 50030e80..c792c073 100644
--- a/tests/auto/sanity/sanity.pro
+++ b/tests/auto/sanity/sanity.pro
@@ -5,7 +5,7 @@ QT += qml testlib core-private qml-private
CONFIG += testcase
macos:CONFIG -= app_bundle
-DEFINES += QQC2_IMPORT_PATH=\\\"$$QQC2_SOURCE_TREE/src/imports\\\"
+include(../../auto/shared/util.pri)
SOURCES += \
$$PWD/tst_sanity.cpp
diff --git a/tests/auto/sanity/tst_sanity.cpp b/tests/auto/sanity/tst_sanity.cpp
index df440ebd..69553d93 100644
--- a/tests/auto/sanity/tst_sanity.cpp
+++ b/tests/auto/sanity/tst_sanity.cpp
@@ -43,6 +43,9 @@
#include <QtQml/private/qqmljsast_p.h>
#include <QtQml/private/qqmljsastvisitor_p.h>
#include <QtQml/private/qqmlmetatype_p.h>
+#include "../../auto/shared/visualtestutil.h"
+
+using namespace QQuickVisualTestUtil;
Q_GLOBAL_STATIC(QObjectList, qt_qobjects)
@@ -329,42 +332,6 @@ void tst_Sanity::ids_data()
QTest::newRow(qPrintable(it.key())) << it.key() << it.value();
}
-static void addTestRows(QQmlEngine *engine, const QString &sourcePath, const QString &targetPath, const QStringList &skiplist = QStringList())
-{
- // We cannot use QQmlComponent to load QML files directly from the source tree.
- // For styles that use internal QML types (eg. material/Ripple.qml), the source
- // dir would be added as an "implicit" import path overriding the actual import
- // path (qtbase/qml/QtQuick/Controls.2/Material). => The QML engine fails to load
- // the style C++ plugin from the implicit import path (the source dir).
- //
- // Therefore we only use the source tree for finding out the set of QML files that
- // a particular style implements, and then we locate the respective QML files in
- // the engine's import path. This way we can use QQmlComponent to load each QML file
- // for benchmarking.
-
- const QFileInfoList entries = QDir(QQC2_IMPORT_PATH "/" + sourcePath).entryInfoList(QStringList("*.qml"), QDir::Files);
- for (const QFileInfo &entry : entries) {
- QString name = entry.baseName();
- if (!skiplist.contains(name)) {
- const auto importPathList = engine->importPathList();
- for (const QString &importPath : importPathList) {
- QString name = entry.dir().dirName() + "/" + entry.fileName();
- QString filePath = importPath + "/" + targetPath + "/" + entry.fileName();
- if (QFile::exists(filePath)) {
- QTest::newRow(qPrintable(name)) << QUrl::fromLocalFile(filePath);
- break;
- } else {
- filePath = QQmlFile::urlToLocalFileOrQrc(filePath);
- if (!filePath.isEmpty() && QFile::exists(filePath)) {
- QTest::newRow(qPrintable(name)) << QUrl(filePath);
- break;
- }
- }
- }
- }
- }
-}
-
void tst_Sanity::attachedObjects()
{
QFETCH(QUrl, url);
@@ -388,11 +355,11 @@ void tst_Sanity::attachedObjects()
void tst_Sanity::attachedObjects_data()
{
QTest::addColumn<QUrl>("url");
- addTestRows(&engine, "calendar", "Qt/labs/calendar");
- addTestRows(&engine, "controls", "QtQuick/Controls.2");
- addTestRows(&engine, "controls/fusion", "QtQuick/Controls.2", QStringList() << "CheckIndicator" << "RadioIndicator" << "SliderGroove" << "SliderHandle" << "SwitchIndicator");
- addTestRows(&engine, "controls/material", "QtQuick/Controls.2/Material", QStringList() << "Ripple" << "SliderHandle" << "CheckIndicator" << "RadioIndicator" << "SwitchIndicator" << "BoxShadow" << "ElevationEffect" << "CursorDelegate");
- addTestRows(&engine, "controls/universal", "QtQuick/Controls.2/Universal", QStringList() << "CheckIndicator" << "RadioIndicator" << "SwitchIndicator");
+ addTestRowForEachControl(&engine, "calendar", "Qt/labs/calendar");
+ addTestRowForEachControl(&engine, "controls", "QtQuick/Controls.2");
+ addTestRowForEachControl(&engine, "controls/fusion", "QtQuick/Controls.2", QStringList() << "CheckIndicator" << "RadioIndicator" << "SliderGroove" << "SliderHandle" << "SwitchIndicator");
+ addTestRowForEachControl(&engine, "controls/material", "QtQuick/Controls.2/Material", QStringList() << "Ripple" << "SliderHandle" << "CheckIndicator" << "RadioIndicator" << "SwitchIndicator" << "BoxShadow" << "ElevationEffect" << "CursorDelegate");
+ addTestRowForEachControl(&engine, "controls/universal", "QtQuick/Controls.2/Universal", QStringList() << "CheckIndicator" << "RadioIndicator" << "SwitchIndicator");
}
QTEST_MAIN(tst_Sanity)
diff --git a/tests/auto/shared/util.pri b/tests/auto/shared/util.pri
index 77c2cc59..16f37f8a 100644
--- a/tests/auto/shared/util.pri
+++ b/tests/auto/shared/util.pri
@@ -7,3 +7,4 @@ SOURCES += $$PWD/visualtestutil.cpp \
$$PWD/util.cpp
DEFINES += QT_QMLTEST_DATADIR=\\\"$${_PRO_FILE_PWD_}/data\\\"
+DEFINES += QQC2_IMPORT_PATH=\\\"$$QQC2_SOURCE_TREE/src/imports\\\"
diff --git a/tests/auto/shared/visualtestutil.cpp b/tests/auto/shared/visualtestutil.cpp
index c5e69812..3eaaa588 100644
--- a/tests/auto/shared/visualtestutil.cpp
+++ b/tests/auto/shared/visualtestutil.cpp
@@ -40,6 +40,8 @@
#include <QtCore/QDebug>
#include <QtGui/QCursor>
#include <QtCore/QCoreApplication>
+#include <QtQml/QQmlFile>
+#include <QtTest/QTest>
bool QQuickVisualTestUtil::delegateVisible(QQuickItem *item)
{
@@ -92,3 +94,42 @@ void QQuickVisualTestUtil::centerOnScreen(QQuickWindow *window)
const QPoint offset = QPoint(window->width() / 2, window->height() / 2);
window->setFramePosition(screenGeometry.center() - offset);
}
+
+void QQuickVisualTestUtil::addTestRowForEachControl(QQmlEngine *engine, const QString &sourcePath, const QString &targetPath, const QStringList &skiplist)
+{
+ // We cannot use QQmlComponent to load QML files directly from the source tree.
+ // For styles that use internal QML types (eg. material/Ripple.qml), the source
+ // dir would be added as an "implicit" import path overriding the actual import
+ // path (qtbase/qml/QtQuick/Controls.2/Material). => The QML engine fails to load
+ // the style C++ plugin from the implicit import path (the source dir).
+ //
+ // Therefore we only use the source tree for finding out the set of QML files that
+ // a particular style implements, and then we locate the respective QML files in
+ // the engine's import path. This way we can use QQmlComponent to load each QML file
+ // for benchmarking.
+
+ const QFileInfoList entries = QDir(QQC2_IMPORT_PATH "/" + sourcePath).entryInfoList(QStringList("*.qml"), QDir::Files);
+ for (const QFileInfo &entry : entries) {
+ QString name = entry.baseName();
+ if (!skiplist.contains(name)) {
+ const auto importPathList = engine->importPathList();
+ for (const QString &importPath : importPathList) {
+ QString name = entry.dir().dirName() + "/" + entry.fileName();
+ QString filePath = importPath + "/" + targetPath + "/" + entry.fileName();
+ if (filePath.startsWith(":"))
+ filePath.prepend("qrc");
+ if (QFile::exists(filePath)) {
+ QTest::newRow(qPrintable(name)) << QUrl::fromLocalFile(filePath);
+ break;
+ } else {
+ QUrl url(filePath);
+ filePath = QQmlFile::urlToLocalFileOrQrc(filePath);
+ if (!filePath.isEmpty() && QFile::exists(filePath)) {
+ QTest::newRow(qPrintable(name)) << url;
+ break;
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/tests/auto/shared/visualtestutil.h b/tests/auto/shared/visualtestutil.h
index a6b52fef..d5e651c5 100644
--- a/tests/auto/shared/visualtestutil.h
+++ b/tests/auto/shared/visualtestutil.h
@@ -136,6 +136,8 @@ namespace QQuickVisualTestUtil
QQuickApplicationWindow *appWindow;
QQuickWindow *window;
};
+
+ void addTestRowForEachControl(QQmlEngine *engine, const QString &sourcePath, const QString &targetPath, const QStringList &skiplist = QStringList());
}
#define QQUICK_VERIFY_POLISH(item) \