summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
diff options
context:
space:
mode:
authorSergio Ahumada <sergio.ahumada@nokia.com>2012-04-17 10:38:24 +0200
committerQt by Nokia <qt-info@nokia.com>2012-04-17 10:38:24 +0200
commit16b53b2f0e3f8f64a59c465493a6209eb7f9ab47 (patch)
treebbb63401eb3c56c32ad9bd9be66bae8d3590de6b /tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
parent2c13dc7482690756280cfefe8515eb809b069721 (diff)
parent9bd032355163d92cda5e7e59ecd21214b131f187 (diff)
Merge "Merge remote-tracking branch 'origin/master' into api_changes" into refs/staging/api_changes
Diffstat (limited to 'tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp')
-rw-r--r--tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp35
1 files changed, 24 insertions, 11 deletions
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 <qimagewriter.h>
#include <qcommonstyle.h>
#include <qlayout.h>
+#include <qdir.h>
#include <qabstracttextdocumentlayout.h>
#include <qtextdocumentfragment.h>
@@ -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<int>("cursorTo");
QTest::addColumn<QString>("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());