summaryrefslogtreecommitdiffstats
path: root/tests/auto/qstatictext
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-09-03 10:48:01 (GMT)
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-09-03 10:50:44 (GMT)
commit200d1743dcdacf1036384f746046e55d91ccd918 (patch)
treed05d3386e6c3a1e0b3db015e13ccc9d45566a472 /tests/auto/qstatictext
parentcff2b82a83b2746c42b9b8eb2a89f7345e468c05 (diff)
downloadQt-200d1743dcdacf1036384f746046e55d91ccd918.zip
Qt-200d1743dcdacf1036384f746046e55d91ccd918.tar.gz
Qt-200d1743dcdacf1036384f746046e55d91ccd918.tar.bz2
Fix QStaticText copy constructor to also copy text option property
The text option property of QStaticText was not copied in the copy constructor, so when the text was detached, the property would be reset to the default. Task-number: QTBUG-13368 Reviewed-by: Gunnar
Diffstat (limited to 'tests/auto/qstatictext')
-rw-r--r--tests/auto/qstatictext/tst_qstatictext.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/auto/qstatictext/tst_qstatictext.cpp b/tests/auto/qstatictext/tst_qstatictext.cpp
index 0ae5320..2a60e9e 100644
--- a/tests/auto/qstatictext/tst_qstatictext.cpp
+++ b/tests/auto/qstatictext/tst_qstatictext.cpp
@@ -73,6 +73,8 @@ private slots:
void prepareToCorrectData();
void prepareToWrongData();
+ void copyConstructor();
+
void translatedPainter();
void rotatedPainter();
void scaledPainter();
@@ -104,6 +106,31 @@ void tst_QStaticText::constructionAndDestruction()
QStaticText text("My text");
}
+void tst_QStaticText::copyConstructor()
+{
+ QStaticText text(QLatin1String("My text"));
+
+ QTextOption textOption(Qt::AlignRight);
+ text.setTextOption(textOption);
+
+ text.setPerformanceHint(QStaticText::AggressiveCaching);
+ text.setTextWidth(123.456);
+ text.setTextFormat(Qt::PlainText);
+
+ QStaticText copiedText(text);
+ copiedText.setText(QLatin1String("Other text"));
+
+ QCOMPARE(copiedText.textOption().alignment(), Qt::AlignRight);
+ QCOMPARE(copiedText.performanceHint(), QStaticText::AggressiveCaching);
+ QCOMPARE(copiedText.textWidth(), 123.456);
+ QCOMPARE(copiedText.textFormat(), Qt::PlainText);
+
+ QStaticText otherCopiedText(copiedText);
+ otherCopiedText.setTextWidth(789);
+
+ QCOMPARE(otherCopiedText.text(), QString::fromLatin1("Other text"));
+}
+
Q_DECLARE_METATYPE(QStaticText::PerformanceHint)
void tst_QStaticText::drawToPoint_data()
{