aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/controls/data/tst_control.qml213
-rw-r--r--tests/auto/controls/data/tst_dialogbuttonbox.qml25
-rw-r--r--tests/auto/controls/data/tst_slider.qml60
-rw-r--r--tests/auto/controls/data/tst_textarea.qml16
-rw-r--r--tests/auto/controls/data/tst_textfield.qml17
-rw-r--r--tests/auto/controls/data/tst_tooltip.qml18
-rw-r--r--tests/auto/controls/data/tst_tumbler.qml64
-rw-r--r--tests/auto/font/tst_font.cpp123
-rw-r--r--tests/auto/palette/tst_palette.cpp147
-rw-r--r--tests/auto/qquickapplicationwindow/tst_qquickapplicationwindow.cpp11
-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/manual/screenshots/qtquickcontrols2.conf3
-rw-r--r--tests/manual/screenshots/screenshots.qml2
17 files changed, 615 insertions, 153 deletions
diff --git a/tests/auto/controls/data/tst_control.qml b/tests/auto/controls/data/tst_control.qml
index a4d06fc1..30feb4be 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() {
diff --git a/tests/auto/controls/data/tst_dialogbuttonbox.qml b/tests/auto/controls/data/tst_dialogbuttonbox.qml
index 6faf0db4..27989703 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 },
diff --git a/tests/auto/controls/data/tst_slider.qml b/tests/auto/controls/data/tst_slider.qml
index a831e402..39e0ea17 100644
--- a/tests/auto/controls/data/tst_slider.qml
+++ b/tests/auto/controls/data/tst_slider.qml
@@ -804,4 +804,64 @@ 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)
+ }
}
diff --git a/tests/auto/controls/data/tst_textarea.qml b/tests/auto/controls/data/tst_textarea.qml
index 7c47aa25..ea30c8d6 100644
--- a/tests/auto/controls/data/tst_textarea.qml
+++ b/tests/auto/controls/data/tst_textarea.qml
@@ -465,4 +465,20 @@ 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
+ }
+ }
+
}
diff --git a/tests/auto/controls/data/tst_textfield.qml b/tests/auto/controls/data/tst_textfield.qml
index 0fee7363..1bdf5151 100644
--- a/tests/auto/controls/data/tst_textfield.qml
+++ b/tests/auto/controls/data/tst_textfield.qml
@@ -435,4 +435,21 @@ 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
+ }
+
+ }
}
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 058cbeca..d64f7c9c 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
}
@@ -1112,4 +1131,49 @@ TestCase {
var label = row.label;
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)
+ }
+ }
}
diff --git a/tests/auto/font/tst_font.cpp b/tests/auto/font/tst_font.cpp
index 75942286..65dd4971 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.h>
using namespace QQuickVisualTestUtil;
@@ -217,20 +217,18 @@ 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)
+ TestFontTheme()
{
- std::fill(fonts, fonts + QPlatformTheme::NFonts, static_cast<QFont *>(0));
+ std::fill(fonts, fonts + QQuickTheme::NFonts, static_cast<QFont *>(0));
- for (int i = QPlatformTheme::SystemFont; i < QPlatformTheme::NFonts; ++i) {
+ for (int i = QQuickTheme::SystemFont; i < QQuickTheme::NFonts; ++i) {
QFont font = QFont();
font.setPixelSize(i + 10);
fonts[i] = new QFont(font);
}
-
- QGuiApplicationPrivate::platform_theme = this;
}
const QFont *font(Font type = SystemFont) const override
@@ -239,73 +237,73 @@ public:
}
private:
- QFont *fonts[QPlatformTheme::NFonts];
+ QFont *fonts[QQuickTheme::NFonts];
};
-Q_DECLARE_METATYPE(QPlatformTheme::Font)
+Q_DECLARE_METATYPE(QQuickTheme::Font)
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::Font>("fontType");
+
+ QTest::newRow("AbstractButton") << "AbstractButton" << QQuickTheme::SystemFont;
+ QTest::newRow("ApplicationWindow") << "ApplicationWindow" << QQuickTheme::SystemFont;
+ QTest::newRow("Button") << "Button" << QQuickTheme::PushButtonFont;
+ QTest::newRow("CheckBox") << "CheckBox" << QQuickTheme::CheckBoxFont;
+ QTest::newRow("CheckDelegate") << "CheckDelegate" << QQuickTheme::ListViewFont;
+ QTest::newRow("ComboBox") << "ComboBox" << QQuickTheme::ComboMenuItemFont;
+ QTest::newRow("Container") << "Container" << QQuickTheme::SystemFont;
+ QTest::newRow("Control") << "Control" << QQuickTheme::SystemFont;
+ QTest::newRow("Dial") << "Dial" << QQuickTheme::SystemFont;
+ QTest::newRow("Dialog") << "Dialog" << QQuickTheme::SystemFont;
+ QTest::newRow("DialogButtonBox") << "DialogButtonBox" << QQuickTheme::SystemFont;
+ QTest::newRow("Drawer") << "Drawer" << QQuickTheme::SystemFont;
+ QTest::newRow("Frame") << "Frame" << QQuickTheme::SystemFont;
+ QTest::newRow("GroupBox") << "GroupBox" << QQuickTheme::GroupBoxTitleFont;
+ QTest::newRow("ItemDelegate") << "ItemDelegate" << QQuickTheme::ItemViewFont;
+ QTest::newRow("Label") << "Label" << QQuickTheme::LabelFont;
+ QTest::newRow("Menu") << "Menu" << QQuickTheme::MenuFont;
+ QTest::newRow("MenuItem") << "MenuItem" << QQuickTheme::MenuItemFont;
+ QTest::newRow("MenuSeparator") << "MenuSeparator" << QQuickTheme::SystemFont;
+ QTest::newRow("Page") << "Page" << QQuickTheme::SystemFont;
+ QTest::newRow("Pane") << "Pane" << QQuickTheme::SystemFont;
+ QTest::newRow("Popup") << "Popup" << QQuickTheme::SystemFont;
+ QTest::newRow("ProgressBar") << "ProgressBar" << QQuickTheme::SystemFont;
+ QTest::newRow("RadioButton") << "RadioButton" << QQuickTheme::RadioButtonFont;
+ QTest::newRow("RadioDelegate") << "RadioDelegate" << QQuickTheme::ListViewFont;
+ QTest::newRow("RangeSlider") << "RangeSlider" << QQuickTheme::SystemFont;
+ QTest::newRow("RoundButton") << "RoundButton" << QQuickTheme::PushButtonFont;
+ QTest::newRow("ScrollBar") << "ScrollBar" << QQuickTheme::SystemFont;
+ QTest::newRow("ScrollIndicator") << "ScrollIndicator" << QQuickTheme::SystemFont;
+ QTest::newRow("Slider") << "Slider" << QQuickTheme::SystemFont;
+ QTest::newRow("SpinBox") << "SpinBox" << QQuickTheme::EditorFont;
+ QTest::newRow("SwipeDelegate") << "SwipeDelegate" << QQuickTheme::ListViewFont;
+ QTest::newRow("Switch") << "Switch" << QQuickTheme::SystemFont; // ### TODO: add QQuickTheme::SwitchFont
+ QTest::newRow("SwitchDelegate") << "SwitchDelegate" << QQuickTheme::ListViewFont;
+ QTest::newRow("TabBar") << "TabBar" << QQuickTheme::SystemFont;
+ QTest::newRow("TabButton") << "TabButton" << QQuickTheme::TabButtonFont;
+ QTest::newRow("TextArea") << "TextArea" << QQuickTheme::EditorFont;
+ QTest::newRow("TextField") << "TextField" << QQuickTheme::EditorFont;
+ QTest::newRow("ToolBar") << "ToolBar" << QQuickTheme::SystemFont;
+ QTest::newRow("ToolButton") << "ToolButton" << QQuickTheme::ToolButtonFont;
+ QTest::newRow("ToolSeparator") << "ToolSeparator" << QQuickTheme::SystemFont;
+ QTest::newRow("ToolTip") << "ToolTip" << QQuickTheme::TipLabelFont;
+ QTest::newRow("Tumbler") << "Tumbler" << QQuickTheme::ItemViewFont;
}
void tst_font::defaultFont()
{
QFETCH(QString, control);
- QFETCH(QPlatformTheme::Font, fontType);
+ QFETCH(QQuickTheme::Font, fontType);
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);
+ QQuickTheme::setCurrent(new TestFontTheme);
QScopedPointer<QObject> object(component.create());
QVERIFY2(!object.isNull(), qPrintable(component.errorString()));
@@ -313,16 +311,9 @@ void tst_font::defaultFont()
QVariant var = object->property("font");
QVERIFY(var.isValid());
- const QFont *expectedFont = theme.font(fontType);
- QVERIFY(expectedFont);
-
+ QFont expectedFont = QQuickTheme::themeFont(fontType);
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..f0ce77f0 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.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::themePalette(QQuickTheme::SystemPalette);
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::themePalette(QQuickTheme::SystemPalette);
defaultPalette.setColor(QPalette::Base, QColor("#efefef"));
defaultPalette.setColor(QPalette::Text, QColor("#101010"));
@@ -217,63 +216,61 @@ 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)
+ TestTheme()
{
- std::fill(palettes, palettes + QPlatformTheme::NPalettes, static_cast<QPalette *>(0));
+ std::fill(palettes, palettes + QQuickTheme::NPalettes, static_cast<QPalette *>(0));
QPalette palette = QPalette();
palette.setColor(QPalette::Window, Qt::gray);
- palettes[QPlatformTheme::SystemPalette] = new QPalette(palette);
+ palettes[QQuickTheme::SystemPalette] = new QPalette(palette);
palette.setColor(QPalette::ToolTipBase, Qt::yellow);
- palettes[QPlatformTheme::ToolTipPalette] = new QPalette(palette);
+ palettes[QQuickTheme::ToolTipPalette] = new QPalette(palette);
palette.setColor(QPalette::ButtonText, Qt::blue);
- palettes[QPlatformTheme::ToolButtonPalette] = new QPalette(palette);
+ palettes[QQuickTheme::ToolButtonPalette] = new QPalette(palette);
palette.setColor(QPalette::Button, Qt::red);
- palettes[QPlatformTheme::ButtonPalette] = new QPalette(palette);
+ palettes[QQuickTheme::ButtonPalette] = new QPalette(palette);
palette.setColor(QPalette::Text, Qt::green);
- palettes[QPlatformTheme::CheckBoxPalette] = new QPalette(palette);
+ palettes[QQuickTheme::CheckBoxPalette] = new QPalette(palette);
palette.setColor(QPalette::Text, Qt::blue);
- palettes[QPlatformTheme::RadioButtonPalette] = new QPalette(palette);
+ palettes[QQuickTheme::RadioButtonPalette] = new QPalette(palette);
// HeaderPalette unused
palette.setColor(QPalette::Base, Qt::darkGray);
- palettes[QPlatformTheme::ComboBoxPalette] = new QPalette(palette);
+ palettes[QQuickTheme::ComboBoxPalette] = new QPalette(palette);
palette.setColor(QPalette::Base, Qt::lightGray);
- palettes[QPlatformTheme::ItemViewPalette] = new QPalette(palette);
+ palettes[QQuickTheme::ItemViewPalette] = new QPalette(palette);
// MessageBoxLabelPalette unused
palette.setColor(QPalette::ButtonText, Qt::white);
- palettes[QPlatformTheme::TabBarPalette] = new QPalette(palette);
+ palettes[QQuickTheme::TabBarPalette] = new QPalette(palette);
palette.setColor(QPalette::WindowText, Qt::darkGray);
- palettes[QPlatformTheme::LabelPalette] = new QPalette(palette);
+ palettes[QQuickTheme::LabelPalette] = new QPalette(palette);
palette.setColor(QPalette::Mid, Qt::gray);
- palettes[QPlatformTheme::GroupBoxPalette] = new QPalette(palette);
+ palettes[QQuickTheme::GroupBoxPalette] = new QPalette(palette);
palette.setColor(QPalette::Shadow, Qt::darkYellow);
- palettes[QPlatformTheme::MenuPalette] = new QPalette(palette);
+ palettes[QQuickTheme::MenuPalette] = new QPalette(palette);
// MenuBarPalette unused
palette.setColor(QPalette::Base, Qt::cyan);
- palettes[QPlatformTheme::TextEditPalette] = new QPalette(palette);
+ palettes[QQuickTheme::TextEditPalette] = new QPalette(palette);
palette.setColor(QPalette::Base, Qt::magenta);
- palettes[QPlatformTheme::TextLineEditPalette] = new QPalette(palette);
-
- QGuiApplicationPrivate::platform_theme = this;
+ palettes[QQuickTheme::TextLineEditPalette] = new QPalette(palette);
}
const QPalette *palette(Palette type = SystemPalette) const override
@@ -282,67 +279,67 @@ public:
}
private:
- QPalette *palettes[QPlatformTheme::NPalettes];
+ QPalette *palettes[QQuickTheme::NPalettes];
};
-Q_DECLARE_METATYPE(QPlatformTheme::Palette)
+Q_DECLARE_METATYPE(QQuickTheme::Palette)
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::Palette>("paletteType");
+
+ QTest::newRow("AbstractButton") << "AbstractButton" << QQuickTheme::SystemPalette;
+ QTest::newRow("ApplicationWindow") << "ApplicationWindow" << QQuickTheme::SystemPalette;
+ QTest::newRow("Button") << "Button" << QQuickTheme::ButtonPalette;
+ QTest::newRow("CheckBox") << "CheckBox" << QQuickTheme::CheckBoxPalette;
+ QTest::newRow("CheckDelegate") << "CheckDelegate" << QQuickTheme::ItemViewPalette;
+ QTest::newRow("ComboBox") << "ComboBox" << QQuickTheme::ComboBoxPalette;
+ QTest::newRow("Container") << "Container" << QQuickTheme::SystemPalette;
+ QTest::newRow("Control") << "Control" << QQuickTheme::SystemPalette;
+ QTest::newRow("Dial") << "Dial" << QQuickTheme::SystemPalette;
+ QTest::newRow("Dialog") << "Dialog" << QQuickTheme::SystemPalette;
+ QTest::newRow("DialogButtonBox") << "DialogButtonBox" << QQuickTheme::SystemPalette;
+ QTest::newRow("Drawer") << "Drawer" << QQuickTheme::SystemPalette;
+ QTest::newRow("Frame") << "Frame" << QQuickTheme::SystemPalette;
+ QTest::newRow("GroupBox") << "GroupBox" << QQuickTheme::GroupBoxPalette;
+ QTest::newRow("ItemDelegate") << "ItemDelegate" << QQuickTheme::ItemViewPalette;
+ QTest::newRow("Label") << "Label" << QQuickTheme::LabelPalette;
+ QTest::newRow("Menu") << "Menu" << QQuickTheme::MenuPalette;
+ QTest::newRow("MenuItem") << "MenuItem" << QQuickTheme::MenuPalette;
+ QTest::newRow("MenuSeparator") << "MenuSeparator" << QQuickTheme::MenuPalette;
+ QTest::newRow("Page") << "Page" << QQuickTheme::SystemPalette;
+ QTest::newRow("Pane") << "Pane" << QQuickTheme::SystemPalette;
+ QTest::newRow("Popup") << "Popup" << QQuickTheme::SystemPalette;
+ QTest::newRow("ProgressBar") << "ProgressBar" << QQuickTheme::SystemPalette;
+ QTest::newRow("RadioButton") << "RadioButton" << QQuickTheme::RadioButtonPalette;
+ QTest::newRow("RadioDelegate") << "RadioDelegate" << QQuickTheme::ItemViewPalette;
+ QTest::newRow("RangeSlider") << "RangeSlider" << QQuickTheme::SystemPalette;
+ QTest::newRow("RoundButton") << "RoundButton" << QQuickTheme::ButtonPalette;
+ QTest::newRow("ScrollBar") << "ScrollBar" << QQuickTheme::SystemPalette;
+ QTest::newRow("ScrollIndicator") << "ScrollIndicator" << QQuickTheme::SystemPalette;
+ QTest::newRow("Slider") << "Slider" << QQuickTheme::SystemPalette;
+ QTest::newRow("SpinBox") << "SpinBox" << QQuickTheme::TextLineEditPalette;
+ QTest::newRow("SwipeDelegate") << "SwipeDelegate" << QQuickTheme::ItemViewPalette;
+ QTest::newRow("Switch") << "Switch" << QQuickTheme::CheckBoxPalette; // ### TODO: add QQuickTheme::SwitchPalette
+ QTest::newRow("SwitchDelegate") << "SwitchDelegate" << QQuickTheme::ItemViewPalette;
+ QTest::newRow("TabBar") << "TabBar" << QQuickTheme::TabBarPalette;
+ QTest::newRow("TabButton") << "TabButton" << QQuickTheme::TabBarPalette;
+ QTest::newRow("TextArea") << "TextArea" << QQuickTheme::TextEditPalette;
+ QTest::newRow("TextField") << "TextField" << QQuickTheme::TextLineEditPalette;
+ QTest::newRow("ToolBar") << "ToolBar" << QQuickTheme::ToolButtonPalette;
+ QTest::newRow("ToolButton") << "ToolButton" << QQuickTheme::ToolButtonPalette;
+ QTest::newRow("ToolSeparator") << "ToolSeparator" << QQuickTheme::ToolButtonPalette;
+ QTest::newRow("ToolTip") << "ToolTip" << QQuickTheme::ToolTipPalette;
+ QTest::newRow("Tumbler") << "Tumbler" << QQuickTheme::ItemViewPalette;
}
void tst_palette::defaultPalette()
{
QFETCH(QString, control);
- QFETCH(QPlatformTheme::Palette, paletteType);
+ QFETCH(QQuickTheme::Palette, paletteType);
- TestTheme theme(QGuiApplicationPrivate::platform_theme);
+ QQuickTheme::setCurrent(new TestTheme);
QQmlEngine engine;
QQmlComponent component(&engine);
@@ -354,11 +351,9 @@ void tst_palette::defaultPalette()
QVariant var = object->property("palette");
QVERIFY(var.isValid());
- const QPalette *expectedPalette = theme.palette(paletteType);
- QVERIFY(expectedPalette);
-
+ QPalette expectedPalette = QQuickTheme::themePalette(paletteType);
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..6228a15d 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.h>
#include "../shared/util.h"
#include "../shared/visualtestutil.h"
@@ -555,11 +555,10 @@ 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; }
+ TestTheme() : m_font("Courier") { }
const QFont *font(Font type = SystemFont) const override
{
@@ -572,7 +571,7 @@ public:
void tst_QQuickApplicationWindow::defaultFont()
{
- TestTheme theme(QGuiApplicationPrivate::platform_theme);
+ QQuickTheme::setCurrent(new TestTheme);
QQmlEngine engine;
QQmlComponent component(&engine);
@@ -581,7 +580,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::themeFont(QQuickTheme::SystemFont));
}
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/manual/screenshots/qtquickcontrols2.conf b/tests/manual/screenshots/qtquickcontrols2.conf
index b6c7c87e..d2081db1 100644
--- a/tests/manual/screenshots/qtquickcontrols2.conf
+++ b/tests/manual/screenshots/qtquickcontrols2.conf
@@ -1,2 +1,5 @@
[Controls]
Style=Material
+
+[Material]
+;Variant=Dense
diff --git a/tests/manual/screenshots/screenshots.qml b/tests/manual/screenshots/screenshots.qml
index 2b031dce..20275b17 100644
--- a/tests/manual/screenshots/screenshots.qml
+++ b/tests/manual/screenshots/screenshots.qml
@@ -58,7 +58,7 @@ ApplicationWindow {
title: "Qt Quick Controls 2 - Screenshots"
visible: true
width: Math.max(600, loader.implicitWidth)
- height: Math.max(600, loader.implicitHeight)
+ height: Math.max(600, loader.implicitHeight + header.implicitHeight + footer.implicitHeight)
property string currentFilePath
property url lastSaveUrl