aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@theqtcompany.com>2015-10-26 18:03:35 +0100
committerLiang Qi <liang.qi@theqtcompany.com>2015-10-27 08:46:23 +0000
commitc9e01c96e0010fc30a2ddc913b22d21a9495e01d (patch)
treeb3ab64d38822b94dbca13cb9d90ee276e5f629ea /tests
parentcc707a981e2ece079bf94c9817e2d42760cae60b (diff)
Control: fix available size
First of all, don't allow negative available size, because it doesn't make much sense. Secondly, geometryChanged() was comparing new width to old height, so availableHeightChanged() was emitted under wrong conditions. Furthermore, the comparisons should are better done fuzzy to avoid unnecessary change notifiers. Change-Id: Ic2bbc106670882b421f79db82d4b47d846e1c4e0 Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/controls/data/tst_control.qml48
1 files changed, 47 insertions, 1 deletions
diff --git a/tests/auto/controls/data/tst_control.qml b/tests/auto/controls/data/tst_control.qml
index 2278f1ef..903a8183 100644
--- a/tests/auto/controls/data/tst_control.qml
+++ b/tests/auto/controls/data/tst_control.qml
@@ -71,6 +71,16 @@ TestCase {
signalName: "mirroredChanged"
}
+ SignalSpy {
+ id: availableWidthSpy
+ signalName: "availableWidthChanged"
+ }
+
+ SignalSpy {
+ id: availableHeightSpy
+ signalName: "availableHeightChanged"
+ }
+
function test_padding() {
var control = component.createObject(testCase)
verify(control)
@@ -135,34 +145,70 @@ TestCase {
var control = component.createObject(testCase)
verify(control)
+ availableWidthSpy.target = control
+ availableHeightSpy.target = control
+
+ verify(availableWidthSpy.valid)
+ verify(availableHeightSpy.valid)
+
+ var availableWidthChanges = 0
+ var availableHeightChanges = 0
+
control.width = 100
- control.height = 100
compare(control.availableWidth, 100)
+ compare(availableWidthSpy.count, ++availableWidthChanges)
+ compare(availableHeightSpy.count, availableHeightChanges)
+
+ control.height = 100
compare(control.availableHeight, 100)
+ compare(availableWidthSpy.count, availableWidthChanges)
+ compare(availableHeightSpy.count, ++availableHeightChanges)
control.padding = 10
compare(control.availableWidth, 80)
compare(control.availableHeight, 80)
+ compare(availableWidthSpy.count, ++availableWidthChanges)
+ compare(availableHeightSpy.count, ++availableHeightChanges)
control.topPadding = 20
compare(control.availableWidth, 80)
compare(control.availableHeight, 70)
+ compare(availableWidthSpy.count, availableWidthChanges)
+ compare(availableHeightSpy.count, ++availableHeightChanges)
control.leftPadding = 30
compare(control.availableWidth, 60)
compare(control.availableHeight, 70)
+ compare(availableWidthSpy.count, ++availableWidthChanges)
+ compare(availableHeightSpy.count, availableHeightChanges)
control.rightPadding = 40
compare(control.availableWidth, 30)
compare(control.availableHeight, 70)
+ compare(availableWidthSpy.count, ++availableWidthChanges)
+ compare(availableHeightSpy.count, availableHeightChanges)
control.bottomPadding = 50
compare(control.availableWidth, 30)
compare(control.availableHeight, 30)
+ compare(availableWidthSpy.count, availableWidthChanges)
+ compare(availableHeightSpy.count, ++availableHeightChanges)
control.padding = 60
compare(control.availableWidth, 30)
compare(control.availableHeight, 30)
+ compare(availableWidthSpy.count, availableWidthChanges)
+ compare(availableHeightSpy.count, availableHeightChanges)
+
+ control.width = 0
+ compare(control.availableWidth, 0)
+ compare(availableWidthSpy.count, ++availableWidthChanges)
+ compare(availableHeightSpy.count, availableHeightChanges)
+
+ control.height = 0
+ compare(control.availableHeight, 0)
+ compare(availableWidthSpy.count, availableWidthChanges)
+ compare(availableHeightSpy.count, ++availableHeightChanges)
control.destroy()
}