summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2015-03-31 18:47:56 +0200
committerLiang Qi <liang.qi@theqtcompany.com>2015-04-01 09:10:26 +0200
commit0e6ee136c91432d4ceeeda64e5a5fa88231398d4 (patch)
tree6060e002af2900007895f6efa757989dd4c190c9 /tests/auto/gui
parent418869d9158ea5cd998ba30778b0b7173b48161b (diff)
parent17294c5e4d15d5776f6e414b03671a4a9ed4993d (diff)
Merge remote-tracking branch 'origin/5.5' into dev
Conflicts: src/testlib/qtestblacklist.cpp src/widgets/accessible/qaccessiblewidgets.cpp Change-Id: If032adb9296428f62384ed835dbf41ee7a0b886c
Diffstat (limited to 'tests/auto/gui')
-rw-r--r--tests/auto/gui/image/qimage/tst_qimage.cpp29
-rw-r--r--tests/auto/gui/image/qpixmap/tst_qpixmap.cpp28
-rw-r--r--tests/auto/gui/text/qtextdocument/test.css3
-rw-r--r--tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp138
-rw-r--r--tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp6
5 files changed, 200 insertions, 4 deletions
diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp
index decd4ef931..0f9bdc7a1a 100644
--- a/tests/auto/gui/image/qimage/tst_qimage.cpp
+++ b/tests/auto/gui/image/qimage/tst_qimage.cpp
@@ -178,6 +178,8 @@ private slots:
void cleanupFunctions();
+ void devicePixelRatio();
+
private:
const QString m_prefix;
};
@@ -2730,5 +2732,32 @@ void tst_QImage::cleanupFunctions()
}
+// test image devicePixelRatio setting and detaching
+void tst_QImage::devicePixelRatio()
+{
+ // create image
+ QImage a(64, 64, QImage::Format_ARGB32);
+ a.fill(Qt::white);
+ QCOMPARE(a.devicePixelRatio(), qreal(1.0));
+ QCOMPARE(a.isDetached(), true);
+
+ // copy image
+ QImage b = a;
+ QCOMPARE(b.devicePixelRatio(), qreal(1.0));
+ QCOMPARE(a.isDetached(), false);
+ QCOMPARE(b.isDetached(), false);
+
+ // set devicePixelRatio to the current value: does not detach
+ a.setDevicePixelRatio(qreal(1.0));
+ QCOMPARE(a.isDetached(), false);
+ QCOMPARE(b.isDetached(), false);
+
+ // set devicePixelRatio to a new value: may detach (currently
+ // does, but we may want to avoid the data copy the future)
+ a.setDevicePixelRatio(qreal(2.0));
+ QCOMPARE(a.devicePixelRatio(), qreal(2.0));
+ QCOMPARE(b.devicePixelRatio(), qreal(1.0));
+}
+
QTEST_GUILESS_MAIN(tst_QImage)
#include "tst_qimage.moc"
diff --git a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
index 0fda8482ce..58cc5824bd 100644
--- a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
+++ b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
@@ -164,6 +164,7 @@ private slots:
void detachOnLoad_QTBUG29639();
void copyOnNonAlignedBoundary();
+ void devicePixelRatio();
private:
const QString m_prefix;
@@ -1543,5 +1544,32 @@ void tst_QPixmap::copyOnNonAlignedBoundary()
QPixmap pm2 = pm1.copy(QRect(5, 0, 3, 2)); // When copying second line: 2 bytes too many are read which might cause an access violation.
}
+// test pixmap devicePixelRatio setting and detaching
+void tst_QPixmap::devicePixelRatio()
+{
+ // create pixmap
+ QPixmap a(64, 64);
+ a.fill(Qt::white);
+ QCOMPARE(a.devicePixelRatio(), qreal(1.0));
+ QCOMPARE(a.isDetached(), true);
+
+ // copy pixmap
+ QPixmap b = a;
+ QCOMPARE(b.devicePixelRatio(), qreal(1.0));
+ QCOMPARE(a.isDetached(), false);
+ QCOMPARE(b.isDetached(), false);
+
+ // set devicePixelRatio to the current value: does not detach
+ a.setDevicePixelRatio(qreal(1.0));
+ QCOMPARE(a.isDetached(), false);
+ QCOMPARE(b.isDetached(), false);
+
+ // set devicePixelRatio to a new value: may detach (currently
+ // does, but we may want to avoid the data copy the future)
+ a.setDevicePixelRatio(qreal(2.0));
+ QCOMPARE(a.devicePixelRatio(), qreal(2.0));
+ QCOMPARE(b.devicePixelRatio(), qreal(1.0));
+}
+
QTEST_MAIN(tst_QPixmap)
#include "tst_qpixmap.moc"
diff --git a/tests/auto/gui/text/qtextdocument/test.css b/tests/auto/gui/text/qtextdocument/test.css
new file mode 100644
index 0000000000..16a2b90666
--- /dev/null
+++ b/tests/auto/gui/text/qtextdocument/test.css
@@ -0,0 +1,3 @@
+body {
+ font: normal 400 14px/1.2 Arial;
+}
diff --git a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
index c51d33487e..5e6b606d83 100644
--- a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
+++ b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
@@ -187,7 +187,7 @@ private slots:
void QTBUG28998_linkColor();
void textCursorUsageWithinContentsChange();
-
+ void cssInheritance();
private:
void backgroundImage_checkExpectedHtml(const QTextDocument &doc);
void buildRegExpData();
@@ -3006,6 +3006,37 @@ void tst_QTextDocument::QTBUG27354_spaceAndSoftSpace()
QPainter p(&image);
document.drawContents(&p, image.rect());
}
+ {
+ // If no p tag is specified it should not be inheriting it
+ QTextDocument td;
+ td.setHtml("<html><head><style type=\"text/css\">p { line-height: 200% }</style></head><body>Foo<ul><li>First</li></ul></body></html>");
+ QTextBlock block = td.begin();
+ while (block.isValid()) {
+ QTextBlockFormat fmt = block.blockFormat();
+ QVERIFY(fmt.lineHeightType() == QTextBlockFormat::SingleHeight);
+ QVERIFY(fmt.lineHeight() == 0);
+ block = block.next();
+ }
+ }
+ {
+ QTextDocument td;
+ td.setHtml("<html><head></head><body><p>Foo</p><ul><li>First</li></ul></body></html>");
+ QList<double> originalMargins;
+ QTextBlock block = td.begin();
+ while (block.isValid()) {
+ originalMargins << block.blockFormat().topMargin();
+ block = block.next();
+ }
+ originalMargins[0] = 85;
+ td.setHtml("<html><head><style type=\"text/css\">body { margin-top: 85px; }</style></head><body><p>Foo</p><ul><li>First</li></ul></body></html>");
+ block = td.begin();
+ int count = 0;
+ while (block.isValid()) {
+ QTextBlockFormat fmt = block.blockFormat();
+ QCOMPARE(fmt.topMargin(), originalMargins.at(count++));
+ block = block.next();
+ }
+ }
}
class BaseDocument : public QTextDocument
@@ -3124,5 +3155,110 @@ void tst_QTextDocument::textCursorUsageWithinContentsChange()
QCOMPARE(handler.verticalMovementX, -1);
}
+void tst_QTextDocument::cssInheritance()
+{
+ {
+ QTextDocument td;
+ td.setHtml("<html><head><style type=\"text/css\">body { line-height: 200% }</style></head><body>"
+ "<p>Foo</p><p>Bar</p><p>Baz</p></body></html>");
+ QTextBlock block = td.begin();
+ while (block.isValid()) {
+ QTextBlockFormat fmt = block.blockFormat();
+ QVERIFY(fmt.lineHeightType() == QTextBlockFormat::ProportionalHeight);
+ QVERIFY(fmt.lineHeight() == 200);
+ block = block.next();
+ }
+ }
+ {
+ QTextDocument td;
+ td.setHtml("<html><head><style type=\"text/css\">body { line-height: 200% } p { line-height: 300% }</style></head><body>"
+ "<p style=\"line-height: 40px\">Foo</p><p>Bar</p><p>Baz</p></body></html>");
+ QTextBlock block = td.begin();
+ QTextBlockFormat fmt = block.blockFormat();
+ QVERIFY(fmt.lineHeightType() == QTextBlockFormat::FixedHeight);
+ QVERIFY(fmt.lineHeight() == 40);
+ block = block.next();
+ fmt = block.blockFormat();
+ QVERIFY(fmt.lineHeightType() == QTextBlockFormat::ProportionalHeight);
+ QVERIFY(fmt.lineHeight() == 300);
+ }
+ {
+ QTextDocument td;
+ td.setHtml("<html><head><style type=\"text/css\">body { font-weight: bold; background-color: #ff0000 }</style></head><body>"
+ "<p>Foo</p><p>Bar</p><p>Baz</p></body></html>");
+ QTextBlock block = td.begin();
+ while (block.isValid()) {
+ QVERIFY(block.blockFormat().background() == QBrush());
+ QVERIFY(block.charFormat().font().bold());
+ block = block.next();
+ }
+ }
+ {
+ QTextDocument td;
+ td.setHtml("<html><head><style type=\"text/css\">body { font-style: italic; font-weight: normal; }</style></head><body>"
+ "<table><tr><th>Foo</th></tr><tr><td>Bar</td></tr></table></body></html>");
+ QTextBlock block = td.begin();
+ // First is the table
+ QTextCharFormat fmt = block.charFormat();
+ QVERIFY(!fmt.font().bold());
+ QVERIFY(fmt.font().italic());
+ // Then the th
+ block = block.next();
+ fmt = block.charFormat();
+ QVERIFY(fmt.font().bold());
+ QVERIFY(fmt.font().italic());
+ // Then the td
+ block = block.next();
+ fmt = block.charFormat();
+ QVERIFY(!fmt.font().bold());
+ QVERIFY(fmt.font().italic());
+ }
+ {
+ QTextDocument td;
+ td.setHtml("<html><head><style type=\"text/css\">b { font-style: italic; font-weight: normal; }</style></head><body>"
+ "<p>This should be <b>bold</b></p></body></html>");
+ QTextBlock block = td.begin();
+ // First is the p
+ QTextCharFormat fmt = block.charFormat();
+ QVERIFY(!fmt.font().bold());
+ QTextBlock::iterator it = block.begin();
+ // The non bold text is first
+ QTextFragment currentFragment = it.fragment();
+ QVERIFY(currentFragment.isValid());
+ fmt = currentFragment.charFormat();
+ QVERIFY(!fmt.font().bold());
+ ++it;
+ QVERIFY(!it.atEnd());
+ // Now check the "bold" text
+ currentFragment = it.fragment();
+ QVERIFY(currentFragment.isValid());
+ fmt = currentFragment.charFormat();
+ QVERIFY(!fmt.font().bold());
+ QVERIFY(fmt.font().italic());
+ }
+ {
+ QTextDocument td;
+ td.setHtml("<html><head><link rel=\"stylesheet\" type=\"text/css\" href=\"test.css\"></head><body>"
+ "<p>This should be <b>bold</b></p></body></html>");
+ QTextBlock block = td.begin();
+ // First is the p
+ QTextCharFormat fmt = block.charFormat();
+ QVERIFY(!fmt.font().bold());
+ QTextBlock::iterator it = block.begin();
+ // The non bold text is first
+ QTextFragment currentFragment = it.fragment();
+ QVERIFY(currentFragment.isValid());
+ fmt = currentFragment.charFormat();
+ QVERIFY(!fmt.font().bold());
+ ++it;
+ QVERIFY(!it.atEnd());
+ // Now check the bold text
+ currentFragment = it.fragment();
+ QVERIFY(currentFragment.isValid());
+ fmt = currentFragment.charFormat();
+ QVERIFY(fmt.font().bold());
+ }
+}
+
QTEST_MAIN(tst_QTextDocument)
#include "tst_qtextdocument.moc"
diff --git a/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp b/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp
index 0fb66c8cdc..8f0d306cba 100644
--- a/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp
+++ b/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp
@@ -841,13 +841,13 @@ void tst_QTextDocumentFragment::unorderedListEnumeration()
setHtml(QString::fromLatin1(html));
cursor.movePosition(QTextCursor::End);
QVERIFY(cursor.currentList());
- QVERIFY(cursor.currentList()->format().style() == QTextListFormat::ListCircle);
+ QVERIFY(cursor.currentList()->format().style() == QTextListFormat::ListDisc);
- const char html2[] = "<ul><ul><ul type=disc><li>Blah</li></ul></ul>";
+ const char html2[] = "<ul><ul><ul type=circle><li>Blah</li></ul></ul>";
setHtml(QString::fromLatin1(html2));
cursor.movePosition(QTextCursor::End);
QVERIFY(cursor.currentList());
- QVERIFY(cursor.currentList()->format().style() == QTextListFormat::ListDisc);
+ QVERIFY(cursor.currentList()->format().style() == QTextListFormat::ListCircle);
}