aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/controls
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-10-07 17:20:24 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2016-10-07 17:24:19 +0200
commita3b706531b98c64137acaebf26756828cd43a2a0 (patch)
treeb04490213d60519b8a0c90f9c166eef862ed185b /tests/auto/controls
parent2f4a059881dbec289d86abc7456b42d5eec77ceb (diff)
parentc2b7e55af43518ae1898eddf8611ef617149ca8a (diff)
Merge remote-tracking branch 'origin/5.7' into 5.8
Conflicts: src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-progressbar-disabled.qml src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-progressbar-normal.qml src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-radiobutton-checked.qml src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-radiobutton-disabled.qml src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-radiobutton-focused.qml src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-radiobutton-normal.qml src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-rangeslider-disabled.qml src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-rangeslider-first-handle-focused.qml src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-rangeslider-normal.qml src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-rangeslider-second-handle-focused.qml src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-rangeslider-second-handle.qml src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-slider-disabled.qml src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-slider-focused.qml src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-slider-normal.qml src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-tabbar-explicit.qml src/quicktemplates2/qquickmenu.cpp tests/auto/controls/data/tst_buttongroup.qml tests/auto/controls/data/tst_swipedelegate.qml Change-Id: Ib6042a0ad716f557927e7412d17ea8957d06c015
Diffstat (limited to 'tests/auto/controls')
-rw-r--r--tests/auto/controls/data/tst_button.qml9
-rw-r--r--tests/auto/controls/data/tst_buttongroup.qml40
-rw-r--r--tests/auto/controls/data/tst_combobox.qml34
-rw-r--r--tests/auto/controls/data/tst_control.qml23
-rw-r--r--tests/auto/controls/data/tst_popup.qml73
-rw-r--r--tests/auto/controls/data/tst_rangeslider.qml36
-rw-r--r--tests/auto/controls/data/tst_scrollbar.qml18
-rw-r--r--tests/auto/controls/data/tst_slider.qml22
-rw-r--r--tests/auto/controls/data/tst_spinbox.qml37
-rw-r--r--tests/auto/controls/data/tst_stackview.qml7
-rw-r--r--tests/auto/controls/data/tst_swipedelegate.qml200
-rw-r--r--tests/auto/controls/data/tst_swipeview.qml17
-rw-r--r--tests/auto/controls/data/tst_tabbar.qml20
-rw-r--r--tests/auto/controls/data/tst_toolbutton.qml40
14 files changed, 188 insertions, 388 deletions
diff --git a/tests/auto/controls/data/tst_button.qml b/tests/auto/controls/data/tst_button.qml
index cc588016..16d1bb94 100644
--- a/tests/auto/controls/data/tst_button.qml
+++ b/tests/auto/controls/data/tst_button.qml
@@ -62,6 +62,11 @@ TestCase {
}
}
+ Component {
+ id: signalSpy
+ SignalSpy { }
+ }
+
function test_text() {
var control = button.createObject(testCase)
verify(control)
@@ -179,8 +184,6 @@ TestCase {
return "actual event:" + JSON.stringify(actual) + ", expected event:" + JSON.stringify(expected)
}
- SignalSpy { id: clickSpy; signalName: "clicked" }
-
function test_autoRepeat() {
var control = button.createObject(testCase)
verify(control)
@@ -192,7 +195,7 @@ TestCase {
control.forceActiveFocus()
verify(control.activeFocus)
- clickSpy.target = control
+ var clickSpy = signalSpy.createObject(control, {target: control, signalName: "clicked"})
verify(clickSpy.valid)
var repeatCount = 2
diff --git a/tests/auto/controls/data/tst_buttongroup.qml b/tests/auto/controls/data/tst_buttongroup.qml
index 2427999a..186eb9d1 100644
--- a/tests/auto/controls/data/tst_buttongroup.qml
+++ b/tests/auto/controls/data/tst_buttongroup.qml
@@ -55,35 +55,9 @@ TestCase {
ButtonGroup { }
}
- SignalSpy {
- id: checkedButtonSpy
- signalName: "checkedButtonChanged"
- }
-
- SignalSpy {
- id: buttonsSpy
- signalName: "buttonsChanged"
- }
-
- SignalSpy {
- id: clickedSpy
- signalName: "clicked"
- }
-
- function init() {
- verify(!checkedButtonSpy.target)
- compare(checkedButtonSpy.count, 0)
-
- verify(!buttonsSpy.target)
- compare(buttonsSpy.count, 0)
- }
-
- function cleanup() {
- checkedButtonSpy.target = null
- checkedButtonSpy.clear()
-
- buttonsSpy.target = null
- buttonsSpy.clear()
+ Component {
+ id: signalSpy
+ SignalSpy { }
}
function test_null() {
@@ -110,7 +84,7 @@ TestCase {
var group = buttonGroup.createObject(testCase)
verify(group)
- checkedButtonSpy.target = group
+ var checkedButtonSpy = signalSpy.createObject(testCase, {target: group, signalName: "checkedButtonChanged"})
verify(checkedButtonSpy.valid)
verify(!group.checkedButton)
@@ -181,7 +155,7 @@ TestCase {
var group = buttonGroup.createObject(testCase)
verify(group)
- buttonsSpy.target = group
+ var buttonsSpy = signalSpy.createObject(testCase, {target: group, signalName: "buttonsChanged"})
verify(buttonsSpy.valid)
compare(group.buttons.length, 0)
@@ -226,7 +200,7 @@ TestCase {
var group = buttonGroup.createObject(testCase)
verify(group)
- clickedSpy.target = group
+ var clickedSpy = signalSpy.createObject(testCase, {target: group, signalName: "clicked"})
verify(clickedSpy.valid)
var button1 = button.createObject(testCase)
@@ -332,7 +306,7 @@ TestCase {
var group = buttonGroup.createObject(testCase)
verify(group)
- buttonsSpy.target = group
+ var buttonsSpy = signalSpy.createObject(testCase, {target: group, signalName: "buttonsChanged"})
verify(buttonsSpy.valid)
var button1 = button.createObject(testCase, {objectName: "button1", checked: true})
diff --git a/tests/auto/controls/data/tst_combobox.qml b/tests/auto/controls/data/tst_combobox.qml
index 5ae1e0a6..b74911c7 100644
--- a/tests/auto/controls/data/tst_combobox.qml
+++ b/tests/auto/controls/data/tst_combobox.qml
@@ -51,16 +51,6 @@ TestCase {
when: windowShown
name: "ComboBox"
- SignalSpy {
- id: activatedSpy
- signalName: "activated"
- }
-
- SignalSpy {
- id: highlightedSpy
- signalName: "highlighted"
- }
-
Component {
id: signalSpy
SignalSpy { }
@@ -80,22 +70,6 @@ TestCase {
}
}
- function init() {
- verify(!activatedSpy.target)
- compare(activatedSpy.count, 0)
-
- verify(!highlightedSpy.target)
- compare(highlightedSpy.count, 0)
- }
-
- function cleanup() {
- activatedSpy.target = null
- activatedSpy.clear()
-
- highlightedSpy.target = null
- highlightedSpy.clear()
- }
-
function test_defaults() {
var control = comboBox.createObject(testCase)
verify(control)
@@ -333,10 +307,10 @@ TestCase {
var control = comboBox.createObject(testCase, {model: 3})
verify(control)
- activatedSpy.target = control
+ var activatedSpy = signalSpy.createObject(control, {target: control, signalName: "activated"})
verify(activatedSpy.valid)
- highlightedSpy.target = control
+ var highlightedSpy = signalSpy.createObject(control, {target: control, signalName: "highlighted"})
verify(highlightedSpy.valid)
waitForRendering(control)
@@ -545,10 +519,10 @@ TestCase {
var control = comboBox.createObject(testCase, {model: 3})
verify(control)
- activatedSpy.target = control
+ var activatedSpy = signalSpy.createObject(control, {target: control, signalName: "activated"})
verify(activatedSpy.valid)
- highlightedSpy.target = control
+ var highlightedSpy = signalSpy.createObject(control, {target: control, signalName: "highlighted"})
verify(highlightedSpy.valid)
mouseClick(control)
diff --git a/tests/auto/controls/data/tst_control.qml b/tests/auto/controls/data/tst_control.qml
index dc84ff93..77f23fa5 100644
--- a/tests/auto/controls/data/tst_control.qml
+++ b/tests/auto/controls/data/tst_control.qml
@@ -71,21 +71,6 @@ TestCase {
SignalSpy { }
}
- SignalSpy {
- id: mirroredSpy
- signalName: "mirroredChanged"
- }
-
- SignalSpy {
- id: availableWidthSpy
- signalName: "availableWidthChanged"
- }
-
- SignalSpy {
- id: availableHeightSpy
- signalName: "availableHeightChanged"
- }
-
function test_padding() {
var control = component.createObject(testCase)
verify(control)
@@ -150,10 +135,10 @@ TestCase {
var control = component.createObject(testCase)
verify(control)
- availableWidthSpy.target = control
- availableHeightSpy.target = control
-
+ var availableWidthSpy = signalSpy.createObject(control, {target: control, signalName: "availableWidthChanged"})
verify(availableWidthSpy.valid)
+
+ var availableHeightSpy = signalSpy.createObject(control, {target: control, signalName: "availableHeightChanged"})
verify(availableHeightSpy.valid)
var availableWidthChanges = 0
@@ -222,7 +207,7 @@ TestCase {
var control = component.createObject(testCase)
verify(control)
- mirroredSpy.target = control
+ var mirroredSpy = signalSpy.createObject(control, {target: control, signalName: "mirroredChanged"})
verify(mirroredSpy.valid)
control.locale = Qt.locale("en_US")
diff --git a/tests/auto/controls/data/tst_popup.qml b/tests/auto/controls/data/tst_popup.qml
index c2a4bb2b..c81c6341 100644
--- a/tests/auto/controls/data/tst_popup.qml
+++ b/tests/auto/controls/data/tst_popup.qml
@@ -72,65 +72,28 @@ TestCase {
Rectangle { }
}
- SignalSpy {
- id: availableWidthSpy
- signalName: "availableWidthChanged"
- }
-
- SignalSpy {
- id: availableHeightSpy
- signalName: "availableHeightChanged"
- }
-
- SignalSpy {
- id: paddingSpy
- signalName: "paddingChanged"
- }
-
- SignalSpy {
- id: topPaddingSpy
- signalName: "topPaddingChanged"
- }
-
- SignalSpy {
- id: leftPaddingSpy
- signalName: "leftPaddingChanged"
- }
-
- SignalSpy {
- id: rightPaddingSpy
- signalName: "rightPaddingChanged"
- }
-
- SignalSpy {
- id: bottomPaddingSpy
- signalName: "bottomPaddingChanged"
- }
-
- SignalSpy {
- id: xSpy
- signalName: "xChanged"
- }
-
- SignalSpy {
- id: ySpy
- signalName: "yChanged"
+ Component {
+ id: signalSpy
+ SignalSpy { }
}
function test_padding() {
var control = popupTemplate.createObject(testCase)
verify(control)
- paddingSpy.target = control
- topPaddingSpy.target = control
- leftPaddingSpy.target = control
- rightPaddingSpy.target = control
- bottomPaddingSpy.target = control
-
+ var paddingSpy = signalSpy.createObject(testCase, {target: control, signalName: "paddingChanged"})
verify(paddingSpy.valid)
+
+ var topPaddingSpy = signalSpy.createObject(testCase, {target: control, signalName: "topPaddingChanged"})
verify(topPaddingSpy.valid)
+
+ var leftPaddingSpy = signalSpy.createObject(testCase, {target: control, signalName: "leftPaddingChanged"})
verify(leftPaddingSpy.valid)
+
+ var rightPaddingSpy = signalSpy.createObject(testCase, {target: control, signalName: "rightPaddingChanged"})
verify(rightPaddingSpy.valid)
+
+ var bottomPaddingSpy = signalSpy.createObject(testCase, {target: control, signalName: "bottomPaddingChanged"})
verify(bottomPaddingSpy.valid)
var paddingChanges = 0
@@ -229,10 +192,10 @@ TestCase {
var control = popupTemplate.createObject(testCase)
verify(control)
- availableWidthSpy.target = control
- availableHeightSpy.target = control
-
+ var availableWidthSpy = signalSpy.createObject(testCase, {target: control, signalName: "availableWidthChanged"})
verify(availableWidthSpy.valid)
+
+ var availableHeightSpy = signalSpy.createObject(testCase, {target: control, signalName: "availableHeightChanged"})
verify(availableHeightSpy.valid)
var availableWidthChanges = 0
@@ -302,10 +265,10 @@ TestCase {
verify(control)
verify(control.visible)
- xSpy.target = control
- ySpy.target = control
-
+ var xSpy = signalSpy.createObject(testCase, {target: control, signalName: "xChanged"})
verify(xSpy.valid)
+
+ var ySpy = signalSpy.createObject(testCase, {target: control, signalName: "yChanged"})
verify(ySpy.valid)
// moving outside margins does not trigger change notifiers
diff --git a/tests/auto/controls/data/tst_rangeslider.qml b/tests/auto/controls/data/tst_rangeslider.qml
index 392be018..eb654bbc 100644
--- a/tests/auto/controls/data/tst_rangeslider.qml
+++ b/tests/auto/controls/data/tst_rangeslider.qml
@@ -50,14 +50,9 @@ TestCase {
when: windowShown
name: "RangeSlider"
- SignalSpy {
- id: firstPressedSpy
- signalName: "pressedChanged"
- }
-
- SignalSpy {
- id: secondPressedSpy
- signalName: "pressedChanged"
+ Component {
+ id: signalSpy
+ SignalSpy { }
}
Component {
@@ -84,21 +79,6 @@ TestCase {
}
}
- function init() {
- verify(!firstPressedSpy.target)
- compare(firstPressedSpy.count, 0)
-
- verify(!secondPressedSpy.target)
- compare(secondPressedSpy.count, 0)
- }
-
- function cleanup() {
- firstPressedSpy.target = null
- firstPressedSpy.clear()
- secondPressedSpy.target = null
- secondPressedSpy.clear()
- }
-
function test_defaults() {
var control = sliderComponent.createObject(testCase)
verify(control)
@@ -303,10 +283,10 @@ TestCase {
var control = sliderComponent.createObject(testCase, { orientation: data.orientation })
verify(control)
- firstPressedSpy.target = control.first
+ var firstPressedSpy = signalSpy.createObject(control, {target: control.first, signalName: "pressedChanged"})
verify(firstPressedSpy.valid)
- secondPressedSpy.target = control.second
+ var secondPressedSpy = signalSpy.createObject(control, {target: control.second, signalName: "pressedChanged"})
verify(secondPressedSpy.valid)
mousePress(control, control.width * 0.25, control.height * 0.75, Qt.LeftButton)
@@ -473,7 +453,7 @@ TestCase {
var pressedCount = 0
- firstPressedSpy.target = control.first
+ var firstPressedSpy = signalSpy.createObject(control, {target: control.first, signalName: "pressedChanged"})
verify(firstPressedSpy.valid)
control.first.handle.forceActiveFocus()
@@ -511,7 +491,7 @@ TestCase {
control.stepSize = 0.25
pressedCount = 0;
- secondPressedSpy.target = control.second
+ var secondPressedSpy = signalSpy.createObject(control, {target: control.second, signalName: "pressedChanged"})
verify(secondPressedSpy.valid)
control.second.handle.forceActiveFocus()
@@ -553,7 +533,7 @@ TestCase {
var control = sliderComponent.createObject(testCase, { leftPadding: 10, rightPadding: 20 })
verify(control)
- firstPressedSpy.target = control.first
+ var firstPressedSpy = signalSpy.createObject(control, {target: control.first, signalName: "pressedChanged"})
verify(firstPressedSpy.valid)
mousePress(control, control.first.handle.x, control.first.handle.y, Qt.LeftButton)
diff --git a/tests/auto/controls/data/tst_scrollbar.qml b/tests/auto/controls/data/tst_scrollbar.qml
index 643dbe33..d7bc792d 100644
--- a/tests/auto/controls/data/tst_scrollbar.qml
+++ b/tests/auto/controls/data/tst_scrollbar.qml
@@ -50,9 +50,9 @@ TestCase {
when: windowShown
name: "ScrollBar"
- SignalSpy{
- id: pressedSpy
- signalName: "pressedChanged"
+ Component {
+ id: signalSpy
+ SignalSpy { }
}
Component {
@@ -72,16 +72,6 @@ TestCase {
}
}
- function init() {
- verify(!pressedSpy.target)
- compare(pressedSpy.count, 0)
- }
-
- function cleanup() {
- pressedSpy.target = null
- pressedSpy.clear()
- }
-
function test_attach() {
var container = flickable.createObject(testCase)
verify(container)
@@ -179,7 +169,7 @@ TestCase {
var control = scrollBar.createObject(testCase, data.properties)
verify(control)
- pressedSpy.target = control
+ var pressedSpy = signalSpy.createObject(control, {target: control, signalName: "pressedChanged"})
verify(pressedSpy.valid)
mousePress(control, 0, 0, Qt.LeftButton)
diff --git a/tests/auto/controls/data/tst_slider.qml b/tests/auto/controls/data/tst_slider.qml
index f91760e4..029aff14 100644
--- a/tests/auto/controls/data/tst_slider.qml
+++ b/tests/auto/controls/data/tst_slider.qml
@@ -50,9 +50,9 @@ TestCase {
when: windowShown
name: "Slider"
- SignalSpy{
- id: pressedSpy
- signalName: "pressedChanged"
+ Component {
+ id: signalSpy
+ SignalSpy { }
}
Component {
@@ -60,16 +60,6 @@ TestCase {
Slider { }
}
- function init() {
- verify(!pressedSpy.target)
- compare(pressedSpy.count, 0)
- }
-
- function cleanup() {
- pressedSpy.target = null
- pressedSpy.clear()
- }
-
function test_defaults() {
var control = slider.createObject(testCase)
verify(control)
@@ -232,7 +222,7 @@ TestCase {
var control = slider.createObject(testCase, {orientation: data.orientation})
verify(control)
- pressedSpy.target = control
+ var pressedSpy = signalSpy.createObject(control, {target: control, signalName: "pressedChanged"})
verify(pressedSpy.valid)
mousePress(control, 0, 0, Qt.LeftButton)
@@ -308,7 +298,7 @@ TestCase {
var pressedCount = 0
- pressedSpy.target = control
+ var pressedSpy = signalSpy.createObject(control, {target: control, signalName: "pressedChanged"})
verify(pressedSpy.valid)
control.forceActiveFocus()
@@ -380,7 +370,7 @@ TestCase {
var control = slider.createObject(testCase, {leftPadding: 10, rightPadding: 20})
verify(control)
- pressedSpy.target = control
+ var pressedSpy = signalSpy.createObject(control, {target: control, signalName: "pressedChanged"})
verify(pressedSpy.valid)
mousePress(control, 0, 0, Qt.LeftButton)
diff --git a/tests/auto/controls/data/tst_spinbox.qml b/tests/auto/controls/data/tst_spinbox.qml
index 81c67681..30db246f 100644
--- a/tests/auto/controls/data/tst_spinbox.qml
+++ b/tests/auto/controls/data/tst_spinbox.qml
@@ -50,14 +50,9 @@ TestCase {
when: windowShown
name: "SpinBox"
- SignalSpy{
- id: upPressedSpy
- signalName: "pressedChanged"
- }
-
- SignalSpy{
- id: downPressedSpy
- signalName: "pressedChanged"
+ Component {
+ id: signalSpy
+ SignalSpy { }
}
Component {
@@ -65,20 +60,6 @@ TestCase {
SpinBox { }
}
- function init() {
- verify(!upPressedSpy.target)
- compare(upPressedSpy.count, 0)
- verify(!downPressedSpy.target)
- compare(downPressedSpy.count, 0)
- }
-
- function cleanup() {
- upPressedSpy.target = null
- upPressedSpy.clear()
- downPressedSpy.target = null
- downPressedSpy.clear()
- }
-
function test_defaults() {
var control = spinBox.createObject(testCase)
verify(control)
@@ -190,9 +171,12 @@ TestCase {
var control = spinBox.createObject(testCase, {stepSize: 50})
verify(control)
- upPressedSpy.target = control.up
+ var upPressedSpy = signalSpy.createObject(control, {target: control.up, signalName: "pressedChanged"})
verify(upPressedSpy.valid)
+ var downPressedSpy = signalSpy.createObject(control, {target: control.down, signalName: "pressedChanged"})
+ verify(downPressedSpy.valid)
+
mousePress(control.up.indicator)
compare(upPressedSpy.count, 1)
compare(control.up.pressed, true)
@@ -225,9 +209,6 @@ TestCase {
compare(control.down.pressed, false)
compare(control.value, control.to)
- downPressedSpy.target = control.down
- verify(downPressedSpy.valid)
-
control.value = 50;
mousePress(control.down.indicator)
compare(downPressedSpy.count, 1)
@@ -271,10 +252,10 @@ TestCase {
var upPressedCount = 0
var downPressedCount = 0
- upPressedSpy.target = control.up
+ var upPressedSpy = signalSpy.createObject(control, {target: control.up, signalName: "pressedChanged"})
verify(upPressedSpy.valid)
- downPressedSpy.target = control.down
+ var downPressedSpy = signalSpy.createObject(control, {target: control.down, signalName: "pressedChanged"})
verify(downPressedSpy.valid)
control.forceActiveFocus()
diff --git a/tests/auto/controls/data/tst_stackview.qml b/tests/auto/controls/data/tst_stackview.qml
index 242c0699..b0e18389 100644
--- a/tests/auto/controls/data/tst_stackview.qml
+++ b/tests/auto/controls/data/tst_stackview.qml
@@ -92,18 +92,13 @@ TestCase {
control.destroy()
}
- SignalSpy {
- id: busySpy
- signalName: "busyChanged"
- }
-
function test_busy() {
var control = stackView.createObject(testCase)
verify(control)
compare(control.busy, false)
var busyCount = 0
- busySpy.target = control
+ var busySpy = signalSpy.createObject(control, {target: control, signalName: "busyChanged"})
verify(busySpy.valid)
control.push(component)
diff --git a/tests/auto/controls/data/tst_swipedelegate.qml b/tests/auto/controls/data/tst_swipedelegate.qml
index 255c1d6d..d30ade48 100644
--- a/tests/auto/controls/data/tst_swipedelegate.qml
+++ b/tests/auto/controls/data/tst_swipedelegate.qml
@@ -54,6 +54,87 @@ TestCase {
readonly property int dragDistance: Math.max(20, Qt.styleHints.startDragDistance + 5)
Component {
+ id: backgroundFillComponent
+ SwipeDelegate {
+ background: Item { anchors.fill: parent }
+ }
+ }
+
+ Component {
+ id: backgroundCenterInComponent
+ SwipeDelegate {
+ background: Item { anchors.centerIn: parent }
+ }
+ }
+
+ Component {
+ id: backgroundLeftComponent
+ SwipeDelegate {
+ background: Item { anchors.left: parent.left }
+ }
+ }
+
+ Component {
+ id: backgroundRightComponent
+ SwipeDelegate {
+ background: Item { anchors.right: parent.right }
+ }
+ }
+
+ Component {
+ id: contentItemFillComponent
+ SwipeDelegate {
+ contentItem: Item { anchors.fill: parent }
+ }
+ }
+
+ Component {
+ id: contentItemCenterInComponent
+ SwipeDelegate {
+ contentItem: Item { anchors.centerIn: parent }
+ }
+ }
+
+ Component {
+ id: contentItemLeftComponent
+ SwipeDelegate {
+ contentItem: Item { anchors.left: parent.left }
+ }
+ }
+
+ Component {
+ id: contentItemRightComponent
+ SwipeDelegate {
+ contentItem: Item { anchors.right: parent.right }
+ }
+ }
+
+ function test_horizontalAnchors_data() {
+ return [
+ { tag: "background, fill", component: backgroundFillComponent, itemName: "background", warningLocation: ":59:25" },
+ { tag: "background, centerIn", component: backgroundCenterInComponent, itemName: "background", warningLocation: ":66:25" },
+ { tag: "background, left", component: backgroundLeftComponent, itemName: "background", warningLocation: ":73:25" },
+ { tag: "background, right", component: backgroundRightComponent, itemName: "background", warningLocation: ":80:25" },
+ { tag: "contentItem, fill", component: contentItemFillComponent, itemName: "contentItem", warningLocation: ":87:26" },
+ { tag: "contentItem, centerIn", component: contentItemCenterInComponent, itemName: "contentItem", warningLocation: ":94:26" },
+ { tag: "contentItem, left", component: contentItemLeftComponent, itemName: "contentItem", warningLocation: ":101:26" },
+ { tag: "contentItem, right", component: contentItemRightComponent, itemName: "contentItem", warningLocation: ":108:26" }
+ ];
+ }
+
+ function test_horizontalAnchors(data) {
+ var warningMessage = Qt.resolvedUrl("tst_swipedelegate.qml") + data.warningLocation
+ + ": QML : SwipeDelegate: cannot use horizontal anchors with " + data.itemName + "; unable to layout the item."
+
+ ignoreWarning(warningMessage);
+
+ var control = data.component.createObject(testCase);
+ verify(control.contentItem);
+
+ control.destroy();
+ }
+
+ Component {
id: greenLeftComponent
Rectangle {
@@ -91,18 +172,6 @@ TestCase {
SignalSpy {}
}
- function test_defaults() {
- var control = swipeDelegateComponent.createObject(testCase);
- verify(control);
-
- compare(control.baselineOffset, control.contentItem.y + control.contentItem.baselineOffset);
- compare(control.swipe.position, 0);
- verify(!control.pressed);
- verify(!control.swipe.complete);
-
- control.destroy();
- }
-
Component {
id: itemComponent
@@ -139,7 +208,7 @@ TestCase {
verify(control);
ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") +
- ":79:9: QML SwipeDelegate: cannot set both behind and left/right properties")
+ ":160:9: QML SwipeDelegate: cannot set both behind and left/right properties")
control.swipe.behind = itemComponent;
// Shouldn't be any warnings when unsetting delegates.
@@ -148,7 +217,7 @@ TestCase {
// right is still set.
ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") +
- ":79:9: QML SwipeDelegate: cannot set both behind and left/right properties")
+ ":160:9: QML SwipeDelegate: cannot set both behind and left/right properties")
control.swipe.behind = itemComponent;
control.swipe.right = null;
@@ -157,11 +226,11 @@ TestCase {
control.swipe.behind = itemComponent;
ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") +
- ":79:9: QML SwipeDelegate: cannot set both behind and left/right properties")
+ ":160:9: QML SwipeDelegate: cannot set both behind and left/right properties")
control.swipe.left = itemComponent;
ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") +
- ":79:9: QML SwipeDelegate: cannot set both behind and left/right properties")
+ ":160:9: QML SwipeDelegate: cannot set both behind and left/right properties")
control.swipe.right = itemComponent;
control.swipe.behind = null;
@@ -176,7 +245,7 @@ TestCase {
var oldLeft = control.swipe.left;
var oldLeftItem = control.swipe.leftItem;
ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") +
- ":79:9: QML SwipeDelegate: left/right/behind properties may only be set when swipe.position is 0")
+ ":160:9: QML SwipeDelegate: left/right/behind properties may only be set when swipe.position is 0")
control.swipe.left = null;
compare(control.swipe.left, oldLeft);
compare(control.swipe.leftItem, oldLeftItem);
@@ -187,7 +256,7 @@ TestCase {
var oldRight = control.swipe.right;
var oldRightItem = control.swipe.rightItem;
ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") +
- ":79:9: QML SwipeDelegate: left/right/behind properties may only be set when swipe.position is 0")
+ ":160:9: QML SwipeDelegate: left/right/behind properties may only be set when swipe.position is 0")
control.swipe.right = null;
compare(control.swipe.right, oldRight);
compare(control.swipe.rightItem, oldRightItem);
@@ -213,7 +282,7 @@ TestCase {
var oldBehind = control.swipe.behind;
var oldBehindItem = control.swipe.behindItem;
ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") +
- ":79:9: QML SwipeDelegate: left/right/behind properties may only be set when swipe.position is 0")
+ ":160:9: QML SwipeDelegate: left/right/behind properties may only be set when swipe.position is 0")
control.swipe.behind = null;
compare(control.swipe.behind, oldBehind);
compare(control.swipe.behindItem, oldBehindItem);
@@ -221,6 +290,18 @@ TestCase {
control.destroy();
}
+ function test_defaults() {
+ var control = swipeDelegateComponent.createObject(testCase);
+ verify(control);
+
+ compare(control.baselineOffset, control.contentItem.y + control.contentItem.baselineOffset);
+ compare(control.swipe.position, 0);
+ verify(!control.pressed);
+ verify(!control.swipe.complete);
+
+ control.destroy();
+ }
+
SignalSequenceSpy {
id: mouseSignalSequenceSpy
signals: ["pressed", "released", "canceled", "clicked", "doubleClicked", "pressedChanged", "pressAndHold"]
@@ -1161,85 +1242,4 @@ TestCase {
control.destroy();
}
-
- Component {
- id: backgroundFillComponent
- SwipeDelegate {
- background: Item { anchors.fill: parent }
- }
- }
-
- Component {
- id: backgroundCenterInComponent
- SwipeDelegate {
- background: Item { anchors.centerIn: parent }
- }
- }
-
- Component {
- id: backgroundLeftComponent
- SwipeDelegate {
- background: Item { anchors.left: parent.left }
- }
- }
-
- Component {
- id: backgroundRightComponent
- SwipeDelegate {
- background: Item { anchors.right: parent.right }
- }
- }
-
- Component {
- id: contentItemFillComponent
- SwipeDelegate {
- contentItem: Item { anchors.fill: parent }
- }
- }
-
- Component {
- id: contentItemCenterInComponent
- SwipeDelegate {
- contentItem: Item { anchors.centerIn: parent }
- }
- }
-
- Component {
- id: contentItemLeftComponent
- SwipeDelegate {
- contentItem: Item { anchors.left: parent.left }
- }
- }
-
- Component {
- id: contentItemRightComponent
- SwipeDelegate {
- contentItem: Item { anchors.right: parent.right }
- }
- }
-
- function test_horizontalAnchors_data() {
- return [
- { tag: "background, fill", component: backgroundFillComponent, itemName: "background", warningLocation: ":1168:25" },
- { tag: "background, centerIn", component: backgroundCenterInComponent, itemName: "background", warningLocation: ":1175:25" },
- { tag: "background, left", component: backgroundLeftComponent, itemName: "background", warningLocation: ":1182:25" },
- { tag: "background, right", component: backgroundRightComponent, itemName: "background", warningLocation: ":1189:25" },
- { tag: "contentItem, fill", component: contentItemFillComponent, itemName: "contentItem", warningLocation: ":1196:26" },
- { tag: "contentItem, centerIn", component: contentItemCenterInComponent, itemName: "contentItem", warningLocation: ":1203:26" },
- { tag: "contentItem, left", component: contentItemLeftComponent, itemName: "contentItem", warningLocation: ":1210:26" },
- { tag: "contentItem, right", component: contentItemRightComponent, itemName: "contentItem", warningLocation: ":1217:26" }
- ];
- }
-
- function test_horizontalAnchors(data) {
- var warningMessage = Qt.resolvedUrl("tst_swipedelegate.qml") + data.warningLocation
- + ": QML : SwipeDelegate: cannot use horizontal anchors with " + data.itemName + "; unable to layout the item."
-
- ignoreWarning(warningMessage);
-
- var control = data.component.createObject(testCase);
- verify(control.contentItem);
-
- control.destroy();
- }
}
diff --git a/tests/auto/controls/data/tst_swipeview.qml b/tests/auto/controls/data/tst_swipeview.qml
index b131236d..2d5f413a 100644
--- a/tests/auto/controls/data/tst_swipeview.qml
+++ b/tests/auto/controls/data/tst_swipeview.qml
@@ -60,20 +60,16 @@ TestCase {
Text { }
}
- SignalSpy {
- id: currentItemChangedSpy
- signalName: "currentItemChanged"
- }
-
- function cleanup() {
- currentItemChangedSpy.clear()
- currentItemChangedSpy.target = null
+ Component {
+ id: signalSpy
+ SignalSpy { }
}
function test_current() {
var control = swipeView.createObject(testCase)
- currentItemChangedSpy.target = control
+ var currentItemChangedSpy = signalSpy.createObject(testCase, {target: control, signalName: "currentItemChanged"})
+ verify(currentItemChangedSpy.valid)
compare(control.count, 0)
compare(control.currentIndex, -1)
@@ -156,7 +152,8 @@ TestCase {
control.currentIndexChanged.connect(verifyCurrentIndexCountDiff)
control.countChanged.connect(verifyCurrentIndexCountDiff)
- currentItemChangedSpy.target = control;
+ var currentItemChangedSpy = signalSpy.createObject(testCase, {target: control, signalName: "currentItemChanged"})
+ verify(currentItemChangedSpy.valid)
compare(control.count, 0)
compare(control.currentIndex, -1)
diff --git a/tests/auto/controls/data/tst_tabbar.qml b/tests/auto/controls/data/tst_tabbar.qml
index 92e80952..da0181a1 100644
--- a/tests/auto/controls/data/tst_tabbar.qml
+++ b/tests/auto/controls/data/tst_tabbar.qml
@@ -85,19 +85,9 @@ TestCase {
}
}
- SignalSpy {
- id: contentChildrenSpy
- signalName: "contentChildrenChanged"
- }
-
- function init() {
- verify(!contentChildrenSpy.target)
- compare(contentChildrenSpy.count, 0)
- }
-
- function cleanup() {
- contentChildrenSpy.target = null
- contentChildrenSpy.clear()
+ Component {
+ id: signalSpy
+ SignalSpy { }
}
function test_defaults() {
@@ -186,7 +176,7 @@ TestCase {
control.currentIndexChanged.connect(verifyCurrentIndexCountDiff)
control.countChanged.connect(verifyCurrentIndexCountDiff)
- contentChildrenSpy.target = control
+ var contentChildrenSpy = signalSpy.createObject(testCase, {target: control, signalName: "contentChildrenChanged"})
verify(contentChildrenSpy.valid)
compare(control.count, 0)
@@ -303,7 +293,7 @@ TestCase {
return true
}
- contentChildrenSpy.target = control
+ var contentChildrenSpy = signalSpy.createObject(testCase, {target: control, signalName: "contentChildrenChanged"})
verify(contentChildrenSpy.valid)
verify(compareObjectNames(control.contentData, ["object", "button1", "timer", "button2", ""]))
diff --git a/tests/auto/controls/data/tst_toolbutton.qml b/tests/auto/controls/data/tst_toolbutton.qml
index cc41d942..a59cff07 100644
--- a/tests/auto/controls/data/tst_toolbutton.qml
+++ b/tests/auto/controls/data/tst_toolbutton.qml
@@ -50,19 +50,9 @@ TestCase {
when: windowShown
name: "ToolButton"
- SignalSpy {
- id: pressedSpy
- signalName: "pressedChanged"
- }
-
- SignalSpy {
- id: downSpy
- signalName: "downChanged"
- }
-
- SignalSpy {
- id: clickedSpy
- signalName: "clicked"
+ Component {
+ id: signalSpy
+ SignalSpy { }
}
Component {
@@ -70,20 +60,6 @@ TestCase {
ToolButton { }
}
- function init() {
- verify(!pressedSpy.target)
- verify(!clickedSpy.target)
- compare(pressedSpy.count, 0)
- compare(clickedSpy.count, 0)
- }
-
- function cleanup() {
- pressedSpy.target = null
- clickedSpy.target = null
- pressedSpy.clear()
- clickedSpy.clear()
- }
-
function test_text() {
var control = toolButton.createObject(testCase)
verify(control)
@@ -101,11 +77,13 @@ TestCase {
var control = toolButton.createObject(testCase)
verify(control)
- pressedSpy.target = control
- downSpy.target = control
- clickedSpy.target = control
+ var pressedSpy = signalSpy.createObject(control, {target: control, signalName: "pressedChanged"})
verify(pressedSpy.valid)
+
+ var downSpy = signalSpy.createObject(control, {target: control, signalName: "downChanged"})
verify(downSpy.valid)
+
+ var clickedSpy = signalSpy.createObject(control, {target: control, signalName: "clicked"})
verify(clickedSpy.valid)
// check
@@ -170,7 +148,7 @@ TestCase {
var control = toolButton.createObject(testCase)
verify(control)
- clickedSpy.target = control
+ var clickedSpy = signalSpy.createObject(control, {target: control, signalName: "clicked"})
verify(clickedSpy.valid)
control.forceActiveFocus()