diff options
author | J-P Nurmi <jpnurmi@theqtcompany.com> | 2016-03-10 16:29:33 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@theqtcompany.com> | 2016-03-11 12:12:51 +0000 |
commit | 4e1c2ac86179f8ff524468aa7fccfabc656a238a (patch) | |
tree | 5aca7a971f3df950d7bf61219a57641e32b9a2f8 /tests/auto/controls/data/tst_textfield.qml | |
parent | 2e79c79bed863b5abc3ce55a4552fd9d32a7d83a (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_textfield.qml')
-rw-r--r-- | tests/auto/controls/data/tst_textfield.qml | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/auto/controls/data/tst_textfield.qml b/tests/auto/controls/data/tst_textfield.qml index 57675659..a7e2f6ec 100644 --- a/tests/auto/controls/data/tst_textfield.qml +++ b/tests/auto/controls/data/tst_textfield.qml @@ -55,6 +55,11 @@ TestCase { TextField { } } + Component { + id: signalSpy + SignalSpy { } + } + function test_creation() { var control = textField.createObject(testCase) verify(control) @@ -90,4 +95,47 @@ TestCase { 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 = textField.createObject(testCase) + verify(control) + + var child = textField.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() + } } |