aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/controls/data/tst_label.qml
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@theqtcompany.com>2016-03-10 16:29:33 +0100
committerJ-P Nurmi <jpnurmi@theqtcompany.com>2016-03-11 12:12:51 +0000
commit4e1c2ac86179f8ff524468aa7fccfabc656a238a (patch)
tree5aca7a971f3df950d7bf61219a57641e32b9a2f8 /tests/auto/controls/data/tst_label.qml
parent2e79c79bed863b5abc3ce55a4552fd9d32a7d83a (diff)
Fix font comparisons
When inheritance of explicitly set font attributes is involved, it is important to compare the resolve mask in addition to comparing the attribute values to avoid losing the information whether a specific attribute is set explicitly. For example, QFont::operator==() returns true for two fonts that are both bold regardless of whether only one of them has explicit weight set. Therefore, setFont() must not ignore fonts resolve mask. Furthermore, the fontChanged() notifier must be emitted only if the actual attribute values change, not if only the resolve mask changes. Change-Id: I2eb7a071c0eaecd2f8d2f6074c4ce6ed6764a6e9 Task-number: QTBUG-50984 Task-number: QTBUG-51696 Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com> Reviewed-by: Liang Qi <liang.qi@theqtcompany.com>
Diffstat (limited to 'tests/auto/controls/data/tst_label.qml')
-rw-r--r--tests/auto/controls/data/tst_label.qml48
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/auto/controls/data/tst_label.qml b/tests/auto/controls/data/tst_label.qml
index 2af02cdf..b93ca3c7 100644
--- a/tests/auto/controls/data/tst_label.qml
+++ b/tests/auto/controls/data/tst_label.qml
@@ -55,9 +55,57 @@ TestCase {
Label { }
}
+ Component {
+ id: signalSpy
+ SignalSpy { }
+ }
+
function test_creation() {
var control = label.createObject(testCase)
verify(control)
control.destroy()
}
+
+ function test_font_explicit_attributes_data() {
+ return [
+ {tag: "bold", value: true},
+ {tag: "capitalization", value: Font.Capitalize},
+ {tag: "family", value: "Courier"},
+ {tag: "italic", value: true},
+ {tag: "strikeout", value: true},
+ {tag: "underline", value: true},
+ {tag: "weight", value: Font.Black},
+ {tag: "wordSpacing", value: 55}
+ ]
+ }
+
+ function test_font_explicit_attributes(data) {
+ var control = label.createObject(testCase)
+ verify(control)
+
+ var child = label.createObject(control)
+ verify(child)
+
+ var controlSpy = signalSpy.createObject(control, {target: control, signalName: "fontChanged"})
+ verify(controlSpy.valid)
+
+ var childSpy = signalSpy.createObject(child, {target: child, signalName: "fontChanged"})
+ verify(childSpy.valid)
+
+ var defaultValue = control.font[data.tag]
+ child.font[data.tag] = defaultValue
+
+ compare(child.font[data.tag], defaultValue)
+ compare(childSpy.count, 0)
+
+ control.font[data.tag] = data.value
+
+ compare(control.font[data.tag], data.value)
+ compare(controlSpy.count, 1)
+
+ compare(child.font[data.tag], defaultValue)
+ compare(childSpy.count, 0)
+
+ control.destroy()
+ }
}