From 751e2ce44ffc87a2b528572a5086ba7738a63d1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C5=82a=C5=BCej=20Szczygie=C5=82?= Date: Mon, 1 Feb 2016 17:10:58 +0100 Subject: Clean up tst_qwidgetwindow Rename TestWidget to PaintTestWidget, because this class tests only whether paint event occurs. Remove unused variables. Remove reset() method, because there is no need to reset only one variable in class method. Change-Id: I8f442c73598e3431baf2b0433fefc157d3f10ea6 Reviewed-by: Friedemann Kleint --- .../kernel/qwidget_window/tst_qwidget_window.cpp | 38 ++++++++-------------- 1 file changed, 13 insertions(+), 25 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp index 5188dfbcfa..58e85d6b58 100644 --- a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp +++ b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp @@ -206,32 +206,20 @@ void tst_QWidget_window::tst_show_resize_hide_show() // QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); } -class TestWidget : public QWidget +class PaintTestWidget : public QWidget { public: - int m_first, m_next; - bool paintEventReceived; + int paintEventCount; - void reset(){ m_first = m_next = 0; paintEventReceived = false; } - bool event(QEvent *event) + explicit PaintTestWidget(QWidget *parent = Q_NULLPTR) + : QWidget(parent) + , paintEventCount(0) + {} + + void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE { - switch (event->type()) { - case QEvent::WindowActivate: - case QEvent::WindowDeactivate: - case QEvent::Hide: - case QEvent::Show: - if (m_first) - m_next = event->type(); - else - m_first = event->type(); - break; - case QEvent::Paint: - paintEventReceived = true; - break; - default: - break; - } - return QWidget::event(event); + ++paintEventCount; + QWidget::paintEvent(event); } }; @@ -366,15 +354,15 @@ void tst_QWidget_window::tst_showWithoutActivating() void tst_QWidget_window::tst_paintEventOnSecondShow() { - TestWidget w; + PaintTestWidget w; w.show(); w.hide(); - w.reset(); + w.paintEventCount = 0; w.show(); QVERIFY(QTest::qWaitForWindowExposed(&w)); QApplication::processEvents(); - QTRY_VERIFY(w.paintEventReceived); + QTRY_VERIFY(w.paintEventCount > 0); } #ifndef QT_NO_DRAGANDDROP -- cgit v1.2.3 From 04def3a8786c59a1161df3a10d966311ae9fef2d Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Wed, 28 Oct 2015 13:52:31 +0100 Subject: Don't clutter up the source tree with .qm files generated by testing. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Generate the qundo*.qm files for tst_QUndo*::commandTextFormat() in the current directory (out of source, for a shadow build) rather than alongside the qundo*.ts from which they're derived (in the source tree); and remove them once loaded, if that succeeds. (On failure, we might even want to look at them.) Task-number: QTBUG-49081 Change-Id: I666985fa3ceb8c25c917b617d6d39141eddebb76 Reviewed-by: Jędrzej Nowacki --- tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp | 8 ++++---- tests/auto/widgets/util/qundostack/tst_qundostack.cpp | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp b/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp index 9f03e9b3a0..600c6255d8 100644 --- a/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp +++ b/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp @@ -624,13 +624,13 @@ void tst_QUndoGroup::commandTextFormat() const QString tsFile = QFINDTESTDATA("testdata/qundogroup.ts"); QVERIFY(!tsFile.isEmpty()); - QVERIFY(!QProcess::execute(binDir + "/lrelease " + tsFile)); + QFile::remove("qundogroup.qm"); // Avoid confusion by strays. + QVERIFY(!QProcess::execute(binDir + "/lrelease " + tsFile + " -qm qundogroup.qm")); QTranslator translator; - const QString qmFile = QFINDTESTDATA("testdata/qundogroup.qm"); - QVERIFY(!qmFile.isEmpty()); - QVERIFY(translator.load(qmFile)); + QVERIFY(translator.load("qundogroup.qm")); + QFile::remove("qundogroup.qm"); qApp->installTranslator(&translator); QUndoGroup group; diff --git a/tests/auto/widgets/util/qundostack/tst_qundostack.cpp b/tests/auto/widgets/util/qundostack/tst_qundostack.cpp index 2c8a9a3ee5..9c861a5702 100644 --- a/tests/auto/widgets/util/qundostack/tst_qundostack.cpp +++ b/tests/auto/widgets/util/qundostack/tst_qundostack.cpp @@ -2968,12 +2968,12 @@ void tst_QUndoStack::commandTextFormat() const QString tsFile = QFINDTESTDATA("testdata/qundostack.ts"); QVERIFY(!tsFile.isEmpty()); - QVERIFY(!QProcess::execute(binDir + "/lrelease " + tsFile)); + QFile::remove("qundostack.qm"); // Avoid confusion by strays. + QVERIFY(!QProcess::execute(binDir + "/lrelease " + tsFile + " -qm qundostack.qm")); QTranslator translator; - const QString qmFile = QFINDTESTDATA("testdata/qundostack.qm"); - QVERIFY(!qmFile.isEmpty()); - QVERIFY(translator.load(qmFile)); + QVERIFY(translator.load("qundostack.qm")); + QFile::remove("qundostack.qm"); qApp->installTranslator(&translator); QUndoStack stack; -- cgit v1.2.3 From bb1924c34563881c61164a5799d5bee1e458a514 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 1 Feb 2016 18:06:57 +0100 Subject: Pass -silent to lrelease to avoid cruft in test logs. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I7cf2808187f97b6319f7561fe06ddef476fa9aa0 Reviewed-by: Jędrzej Nowacki --- tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp | 2 +- tests/auto/widgets/util/qundostack/tst_qundostack.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp b/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp index 600c6255d8..464a42b4e8 100644 --- a/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp +++ b/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp @@ -625,7 +625,7 @@ void tst_QUndoGroup::commandTextFormat() const QString tsFile = QFINDTESTDATA("testdata/qundogroup.ts"); QVERIFY(!tsFile.isEmpty()); QFile::remove("qundogroup.qm"); // Avoid confusion by strays. - QVERIFY(!QProcess::execute(binDir + "/lrelease " + tsFile + " -qm qundogroup.qm")); + QVERIFY(!QProcess::execute(binDir + "/lrelease -silent " + tsFile + " -qm qundogroup.qm")); QTranslator translator; diff --git a/tests/auto/widgets/util/qundostack/tst_qundostack.cpp b/tests/auto/widgets/util/qundostack/tst_qundostack.cpp index 9c861a5702..07c5be417a 100644 --- a/tests/auto/widgets/util/qundostack/tst_qundostack.cpp +++ b/tests/auto/widgets/util/qundostack/tst_qundostack.cpp @@ -2969,7 +2969,7 @@ void tst_QUndoStack::commandTextFormat() const QString tsFile = QFINDTESTDATA("testdata/qundostack.ts"); QVERIFY(!tsFile.isEmpty()); QFile::remove("qundostack.qm"); // Avoid confusion by strays. - QVERIFY(!QProcess::execute(binDir + "/lrelease " + tsFile + " -qm qundostack.qm")); + QVERIFY(!QProcess::execute(binDir + "/lrelease -silent " + tsFile + " -qm qundostack.qm")); QTranslator translator; QVERIFY(translator.load("qundostack.qm")); -- cgit v1.2.3 From 6ec7d7658d87132358e3c149f5e44e975748ae4b Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 2 Feb 2016 14:55:17 +0100 Subject: Fix rounding error in fetchTransformedBilinear To calculate the real count we need to use the actual fixed point increment and can not use the floating point value increment wass based on since it might round differently. Includes auto-test by Gabriel de Dietrich. Task-number: QTBUG-50153 Change-Id: Ia973088f361c90370fa20bac14a4b8f373b5d234 Reviewed-by: Gabriel de Dietrich Reviewed-by: Olivier Goffart (Woboq GmbH) --- tests/auto/gui/painting/qpainter/tst_qpainter.cpp | 26 +++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'tests') diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp index 1ed78fa0ef..8c72532122 100644 --- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp +++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp @@ -305,6 +305,8 @@ private slots: void drawPolyline_data(); void drawPolyline(); + void QTBUG50153_drawImage_assert(); + private: void fillData(); void setPenColor(QPainter& p); @@ -5052,6 +5054,30 @@ void tst_QPainter::drawPolyline() QCOMPARE(images[0], images[1]); } +void tst_QPainter::QTBUG50153_drawImage_assert() +{ + QImage::Format formats[] = { + QImage::Format_RGB32, // fetchTransformedBilinearARGB32PM + QImage::Format_ARGB32 // fetchTransformedBilinear + }; + + for (unsigned i = 0; i < sizeof(formats) / sizeof(formats[0]); i++) { + QImage image(3027, 2999, formats[i]); + + QImage backingStore(image.size(), QImage::Format_ARGB32); + QPainter backingStorePainter(&backingStore); + + QTransform transform; + transform.scale( 0.999987, 0.999987 ); + + backingStorePainter.setTransform(transform); + backingStorePainter.setRenderHint(QPainter::SmoothPixmapTransform, true); + backingStorePainter.drawImage(0, 0, image); + + // No crash, all fine + } +} + QTEST_MAIN(tst_QPainter) #include "tst_qpainter.moc" -- cgit v1.2.3 From 2ddd11dde2131ff403aa522e5aa3f6bbb836dccc Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Tue, 9 Feb 2016 14:45:15 +0100 Subject: Cleanup testcase for platforms without QProcess support. Change-Id: Ib56c90262605ad975772f6b26c6232020e308ca6 Reviewed-by: Friedemann Kleint --- tests/auto/corelib/tools/qlocale/tst_qlocale.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests') diff --git a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp index 5f046575c4..dc5140a010 100644 --- a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp +++ b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp @@ -212,6 +212,7 @@ tst_QLocale::tst_QLocale() void tst_QLocale::initTestCase() { +#ifndef QT_NO_PROCESS const QString syslocaleapp_dir = QFINDTESTDATA("syslocaleapp"); QVERIFY2(!syslocaleapp_dir.isEmpty(), qPrintable(QStringLiteral("Cannot find 'syslocaleapp' starting from ") @@ -224,6 +225,7 @@ void tst_QLocale::initTestCase() QVERIFY2(fi.exists() && fi.isExecutable(), qPrintable(QDir::toNativeSeparators(m_sysapp) + QStringLiteral(" does not exist or is not executable."))); +#endif // QT_NO_PROCESS #ifdef Q_OS_BLACKBERRY if ((m_languageFd = open(ppsLanguageLocalePath, O_RDONLY)) == -1) -- cgit v1.2.3 From 8b4ac65e2913bd7fbdd996ca290b129659f89a9e Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Wed, 20 Jan 2016 17:45:00 +0100 Subject: Provide QCss with the correct font for
 blocks

Labels would use a statically defined font for 
 blocks.
Use the one defined by the QPlatformTheme instead, through
QFontDatabase::systemFont(FixedFont)

Task-number: QTBUG-50564
Change-Id: I5491bd0defce651bdf809bcbc6a529a900f4959b
Reviewed-by: Milian Wolff 
---
 .../gui/text/qtextdocument/tst_qtextdocument.cpp   | 26 ++++++++++++++++++++++
 1 file changed, 26 insertions(+)

(limited to 'tests')

diff --git a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
index 7378ca85ee..02e2bf27e2 100644
--- a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
+++ b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
@@ -95,6 +95,8 @@ private slots:
 
     void task240325();
 
+    void preFont();
+
     void stylesheetFont_data();
     void stylesheetFont();
 
@@ -675,6 +677,30 @@ void tst_QTextDocument::stylesheetFont()
     QCOMPARE(actualFont.pixelSize(), font.pixelSize());
 }
 
+void tst_QTextDocument::preFont()
+{
+    const QFont font = QFontDatabase::systemFont(QFontDatabase::FixedFont);
+    const QString html = QString::fromLatin1(   ""
+                                                ""
+                                                "
"
+                                                "Foobar"
+                                                "
" + "" + ""); + + doc->setHtml(html); + QCOMPARE(doc->blockCount(), 1); + + // First and only block + QTextBlock block = doc->firstBlock(); + + QString text = block.text(); + QCOMPARE(text, QString::fromLatin1("Foobar")); + + QFont actualFont = block.charFormat().font(); + QCOMPARE(actualFont.family(), font.family()); +} + void tst_QTextDocument::noundo_moreIsModified() { doc->setUndoRedoEnabled(false); -- cgit v1.2.3