From 638fc652f587b47e9fd99ab5c0e886baf8cc35a9 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 11 Apr 2012 16:36:11 +0200 Subject: Fix tst_qtextedit and remove insignification. - The crash on XCB can no longer be reproduced. - Use QFINDTESTDATA instead of SRCDIR defines. - Remove Windows CE specific profile section. Task-number: QTBUG-20756 Change-Id: I6077b3a0daacb15ab440a90c7bda247aa3756fa5 Reviewed-by: Jason McDonald --- tests/auto/widgets/widgets/qtextedit/qtextedit.pro | 15 +--------- .../widgets/widgets/qtextedit/tst_qtextedit.cpp | 35 +++++++++++++++------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/tests/auto/widgets/widgets/qtextedit/qtextedit.pro b/tests/auto/widgets/widgets/qtextedit/qtextedit.pro index 1c2821b289..6e0fff17d5 100644 --- a/tests/auto/widgets/widgets/qtextedit/qtextedit.pro +++ b/tests/auto/widgets/widgets/qtextedit/qtextedit.pro @@ -2,18 +2,5 @@ CONFIG += testcase TARGET = tst_qtextedit QT += widgets widgets-private gui-private core-private testlib -INCLUDEPATH += ../ -HEADERS += -SOURCES += tst_qtextedit.cpp - -wince* { - addImages.files = fullWidthSelection/* - addImages.path = fullWidthSelection - DEPLOYMENT += addImages - DEFINES += SRCDIR=\\\"./\\\" -} else { - DEFINES += SRCDIR=\\\"$$PWD/\\\" -} - -contains(QT_CONFIG,xcb):CONFIG+=insignificant_test # QTBUG-20756 crashes on xcb +SOURCES += tst_qtextedit.cpp diff --git a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp index 9c5a3dbed7..a3f58c4c0d 100644 --- a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp +++ b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp @@ -58,6 +58,7 @@ #include #include #include +#include #include #include @@ -218,6 +219,7 @@ private: QTextEdit *ed; qreal rootFrameMargin; PlatformInputContext m_platformInputContext; + const QString m_fullWidthSelectionImagesFolder; }; bool tst_QTextEdit::nativeClipboardWorking() @@ -376,13 +378,17 @@ public: int &iterationCounter; }; -tst_QTextEdit::tst_QTextEdit() -{} +tst_QTextEdit::tst_QTextEdit() : + m_fullWidthSelectionImagesFolder(QFINDTESTDATA("fullWidthSelection")) +{ + +} void tst_QTextEdit::initTestCase() { QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod()); inputMethodPrivate->testContext = &m_platformInputContext; + QVERIFY2(!m_fullWidthSelectionImagesFolder.isEmpty(), qPrintable(QString::fromLatin1("Cannot locate 'fullWidthSelection' starting from %1").arg(QDir::currentPath()))); } void tst_QTextEdit::cleanupTestCase() @@ -1934,12 +1940,18 @@ void tst_QTextEdit::fullWidthSelection_data() QTest::addColumn("cursorTo"); QTest::addColumn("imageFileName"); - QTest::newRow("centered fully selected") << 0 << 15 << QString("fullWidthSelection/centered-fully-selected.png"); - QTest::newRow("centered partly selected") << 2 << 15 << QString("fullWidthSelection/centered-partly-selected.png"); - QTest::newRow("last char on line") << 42 << 44 << QString("fullWidthSelection/last-char-on-line.png"); - QTest::newRow("last char on parag") << 545 << 548 << QString("fullWidthSelection/last-char-on-parag.png"); - QTest::newRow("multiple full width lines") << 20 << 60 << QString("fullWidthSelection/multiple-full-width-lines.png"); - QTest::newRow("single full width line") << 20 << 30 << QString("fullWidthSelection/single-full-width-line.png"); + QTest::newRow("centered fully selected") + << 0 << 15 << (m_fullWidthSelectionImagesFolder + QStringLiteral("/centered-fully-selected.png")); + QTest::newRow("centered partly selected") + << 2 << 15 << (m_fullWidthSelectionImagesFolder + QStringLiteral("/centered-partly-selected.png")); + QTest::newRow("last char on line") + << 42 << 44 << (m_fullWidthSelectionImagesFolder + QStringLiteral("/last-char-on-line.png")); + QTest::newRow("last char on parag") + << 545 << 548 << (m_fullWidthSelectionImagesFolder + QStringLiteral("/last-char-on-parag.png")); + QTest::newRow("multiple full width lines") + << 20 << 60 << (m_fullWidthSelectionImagesFolder + QStringLiteral("/multiple-full-width-lines.png")); + QTest::newRow("single full width line") + << 20 << 30 << (m_fullWidthSelectionImagesFolder + QStringLiteral("/single-full-width-line.png")); } void tst_QTextEdit::fullWidthSelection() @@ -2053,11 +2065,12 @@ void tst_QTextEdit::compareWidgetAndImage(QTextEdit &widget, const QString &imag QPainter painter(&image); widget.viewport()->render(&painter); painter.end(); - // qDebug() << "file: " << QString(SRCDIR) + imageFileName; - QImageReader reader(QString(SRCDIR) + imageFileName, "PNG"); + QImageReader reader(imageFileName, "PNG"); + QImage original = reader.read(); - QCOMPARE(original.isNull(), false); + QVERIFY2(!original.isNull(), + qPrintable(QString::fromLatin1("Unable to read image %1: %2").arg(imageFileName, reader.errorString()))); QCOMPARE(original.size(), image.size()); QCOMPARE(image.depth(), 32); QCOMPARE(original.depth(), image.depth()); -- cgit v1.2.3