From 4e1c2ac86179f8ff524468aa7fccfabc656a238a Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 10 Mar 2016 16:29:33 +0100 Subject: 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 Reviewed-by: Liang Qi --- tests/auto/controls/data/tst_label.qml | 48 ++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'tests/auto/controls/data/tst_label.qml') 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() + } } -- cgit v1.2.3