summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-11-15 09:51:41 +0100
committerLiang Qi <liang.qi@qt.io>2016-11-15 09:58:16 +0100
commit9808b53fde1dfc65ad3757cc6720e430c3cc89a2 (patch)
treea0517ae1e290e7bbdb118c9f01f4e6e5d744998c /tests/auto/gui
parentc214379156e4c75dcfe59cf73d69b912f4293303 (diff)
parent246fe271878dbe586b5f3222a78d67dfecd1ca83 (diff)
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts: configure src/plugins/platforms/eglfs/qeglfsintegration.cpp src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp Change-Id: Id2da7c775439adb62646d5b741ee7c638042b34b
Diffstat (limited to 'tests/auto/gui')
-rw-r--r--tests/auto/gui/image/qpixmap/tst_qpixmap.cpp15
-rw-r--r--tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp37
2 files changed, 45 insertions, 7 deletions
diff --git a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
index 8dc6f901e6..8df8c2d3b6 100644
--- a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
+++ b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
@@ -162,6 +162,7 @@ private:
const QString m_prefix;
const QString m_convertFromImage;
const QString m_loadFromData;
+ const QTemporaryDir m_tempDir;
};
static bool lenientCompare(const QPixmap &actual, const QPixmap &expected)
@@ -209,11 +210,11 @@ void tst_QPixmap::initTestCase()
QVERIFY(!m_prefix.isEmpty());
QVERIFY(!m_convertFromImage.isEmpty());
QVERIFY(!m_loadFromData.isEmpty());
+ QVERIFY2(m_tempDir.isValid(), qPrintable(m_tempDir.errorString()));
}
void tst_QPixmap::cleanupTestCase()
{
- QFile::remove(QLatin1String("temp_image.png"));
}
void tst_QPixmap::swap()
@@ -1455,18 +1456,18 @@ void tst_QPixmap::preserveDepth()
void tst_QPixmap::loadAsBitmapOrPixmap()
{
QImage tmp(10, 10, QImage::Format_RGB32);
- tmp.save("temp_image.png");
+ tmp.save(m_tempDir.path() + "/temp_image.png");
bool ok;
// Check that we can load the pixmap as a pixmap and that it then turns into a pixmap
- QPixmap pixmap("temp_image.png");
+ QPixmap pixmap(m_tempDir.path() + "/temp_image.png");
QVERIFY(!pixmap.isNull());
QVERIFY(pixmap.depth() > 1);
QVERIFY(!pixmap.isQBitmap());
pixmap = QPixmap();
- ok = pixmap.load("temp_image.png");
+ ok = pixmap.load(m_tempDir.path() + "/temp_image.png");
QVERIFY(ok);
QVERIFY(!pixmap.isNull());
QVERIFY(pixmap.depth() > 1);
@@ -1474,20 +1475,20 @@ void tst_QPixmap::loadAsBitmapOrPixmap()
//now we can try to load it without an extension
pixmap = QPixmap();
- ok = pixmap.load("temp_image");
+ ok = pixmap.load(m_tempDir.path() + "/temp_image");
QVERIFY(ok);
QVERIFY(!pixmap.isNull());
QVERIFY(pixmap.depth() > 1);
QVERIFY(!pixmap.isQBitmap());
// The do the same check for bitmaps..
- QBitmap bitmap("temp_image.png");
+ QBitmap bitmap(m_tempDir.path() + "/temp_image.png");
QVERIFY(!bitmap.isNull());
QCOMPARE(bitmap.depth(), 1);
QVERIFY(bitmap.isQBitmap());
bitmap = QBitmap();
- ok = bitmap.load("temp_image.png");
+ ok = bitmap.load(m_tempDir.path() + "/temp_image.png");
QVERIFY(ok);
QVERIFY(!bitmap.isNull());
QCOMPARE(bitmap.depth(), 1);
diff --git a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp
index 0d1d0f1ae1..b8af5271ea 100644
--- a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp
+++ b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp
@@ -134,6 +134,7 @@ private slots:
void xToCursorForLigatures();
void cursorInNonStopChars();
void nbsp();
+ void nbspWithFormat();
void noModificationOfInputString();
void superscriptCrash_qtbug53911();
@@ -2254,5 +2255,41 @@ void tst_QTextLayout::superscriptCrash_qtbug53911()
qDeleteAll(textLayouts);
}
+void tst_QTextLayout::nbspWithFormat()
+{
+ QString s1 = QLatin1String("ABCDEF ");
+ QString s2 = QLatin1String("GHI");
+ QChar nbsp(QChar::Nbsp);
+ QString s3 = QLatin1String("JKLMNOPQRSTUVWXYZ");
+
+ QTextLayout layout;
+ layout.setText(s1 + s2 + nbsp + s3);
+
+ QTextLayout::FormatRange formatRange;
+ formatRange.start = s1.length() + s2.length();
+ formatRange.length = 1;
+ formatRange.format.setFontUnderline(true);
+
+ QList<QTextLayout::FormatRange> overrides;
+ overrides.append(formatRange);
+
+ layout.setAdditionalFormats(overrides);
+
+ layout.beginLayout();
+ forever {
+ QTextLine line = layout.createLine();
+ if (!line.isValid())
+ break;
+ line.setLineWidth(1);
+ }
+ layout.endLayout();
+
+ QCOMPARE(layout.lineCount(), 2);
+ QCOMPARE(layout.lineAt(0).textStart(), 0);
+ QCOMPARE(layout.lineAt(0).textLength(), s1.length());
+ QCOMPARE(layout.lineAt(1).textStart(), s1.length());
+ QCOMPARE(layout.lineAt(1).textLength(), s2.length() + 1 + s3.length());
+}
+
QTEST_MAIN(tst_QTextLayout)
#include "tst_qtextlayout.moc"