summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/gui')
-rw-r--r--tests/auto/gui/image/qpixmap/tst_qpixmap.cpp6
-rw-r--r--tests/auto/gui/kernel/qwindow/tst_qwindow.cpp20
-rw-r--r--tests/auto/gui/painting/qcolor/tst_qcolor.cpp4
-rw-r--r--tests/auto/gui/painting/qpainter/tst_qpainter.cpp21
-rw-r--r--tests/auto/gui/painting/qregion/tst_qregion.cpp6
-rw-r--r--tests/auto/gui/qopengl/tst_qopengl.cpp28
-rw-r--r--tests/auto/gui/text/qcssparser/tst_qcssparser.cpp1
-rw-r--r--tests/auto/gui/text/qfontdatabase/qfontdatabase.pro4
-rw-r--r--tests/auto/gui/text/qfontdatabase/testdata.qrc2
-rw-r--r--tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp69
10 files changed, 133 insertions, 28 deletions
diff --git a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
index c349d0df09..895f68bbd7 100644
--- a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
+++ b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
@@ -262,7 +262,7 @@ void tst_QPixmap::fromImage()
image.fill(0x7f7f7f7f);
const QPixmap pixmap = QPixmap::fromImage(image);
-#ifdef Q_DEAD_CODE_FROM_QT4_X11
+#if 0 // Used to be included in Qt4 for Q_WS_X11
if (pixmap.handle()->classId() == QPlatformPixmap::X11Class && !pixmap.x11PictureHandle())
QSKIP("Requires XRender support");
#endif
@@ -486,7 +486,7 @@ void tst_QPixmap::fill()
else
pm = QPixmap(400, 400);
-#if defined(Q_DEAD_CODE_FROM_QT4_X11)
+#if 0 // Used to be included in Qt4 for Q_WS_X11
if (!bitmap && pm.handle()->classId() == QPlatformPixmap::X11Class && !pm.x11PictureHandle())
QSKIP("Requires XRender support");
#endif
@@ -516,7 +516,7 @@ void tst_QPixmap::fill()
void tst_QPixmap::fill_transparent()
{
QPixmap pixmap(10, 10);
-#ifdef Q_DEAD_CODE_FROM_QT4_X11
+#if 0 // Used to be included in Qt4 for Q_WS_X11
if (pixmap.handle()->classId() == QPlatformPixmap::X11Class && !pixmap.x11PictureHandle())
QSKIP("Requires XRender support");
#endif
diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
index 45be8bf099..a08f1896bb 100644
--- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
+++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
@@ -803,6 +803,24 @@ void tst_QWindow::isActive()
// child has focus
QVERIFY(window.isActive());
+ // test focus back to parent and then back to child (QTBUG-39362)
+ // also verify the cumulative FocusOut and FocusIn counts
+ // activate parent
+ window.requestActivate();
+ QTRY_COMPARE(QGuiApplication::focusWindow(), &window);
+ QVERIFY(window.isActive());
+ QCoreApplication::processEvents();
+ QTRY_COMPARE(child.received(QEvent::FocusOut), 1);
+ QTRY_COMPARE(window.received(QEvent::FocusIn), 2);
+
+ // activate child again
+ child.requestActivate();
+ QTRY_COMPARE(QGuiApplication::focusWindow(), &child);
+ QVERIFY(child.isActive());
+ QCoreApplication::processEvents();
+ QTRY_COMPARE(window.received(QEvent::FocusOut), 2);
+ QTRY_COMPARE(child.received(QEvent::FocusIn), 2);
+
Window dialog;
dialog.setTransientParent(&window);
dialog.setGeometry(QRect(m_availableTopLeft + QPoint(110, 100), m_testWindowSize));
@@ -827,7 +845,7 @@ void tst_QWindow::isActive()
QTRY_COMPARE(QGuiApplication::focusWindow(), &window);
QCoreApplication::processEvents();
QTRY_COMPARE(dialog.received(QEvent::FocusOut), 1);
- QTRY_COMPARE(window.received(QEvent::FocusIn), 2);
+ QTRY_COMPARE(window.received(QEvent::FocusIn), 3);
QVERIFY(window.isActive());
diff --git a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
index ab893385e3..9dd9ab05e8 100644
--- a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
+++ b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
@@ -107,7 +107,7 @@ private slots:
void qrgba64Premultiply();
void qrgba64Equivalence();
-#ifdef Q_DEAD_CODE_FROM_QT4_X11
+#if 0 // Used to be included in Qt4 for Q_WS_X11
void setallowX11ColorNames();
#endif
};
@@ -1403,7 +1403,7 @@ void tst_QColor::achromaticHslHue()
QCOMPARE(hsl.hslHue(), -1);
}
-#ifdef Q_DEAD_CODE_FROM_QT4_X11
+#if 0 // Used to be included in Qt4 for Q_WS_X11
void tst_QColor::setallowX11ColorNames()
{
#if defined(Q_OS_IRIX)
diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
index 1bd7f67810..254ab1f8ad 100644
--- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
+++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
@@ -298,6 +298,8 @@ private slots:
void rotateImage_data();
void rotateImage();
+ void QTBUG56252();
+
private:
void fillData();
void setPenColor(QPainter& p);
@@ -497,7 +499,7 @@ void tst_QPainter::drawPixmap_comp()
destPm.fill(c1);
srcPm.fill(c2);
-#if defined(Q_DEAD_CODE_FROM_QT4_X11)
+#if 0 // Used to be included in Qt4 for Q_WS_X11
if (!destPm.x11PictureHandle())
QSKIP("Requires XRender support");
#endif
@@ -5120,6 +5122,23 @@ void tst_QPainter::rotateImage()
}
+void tst_QPainter::QTBUG56252()
+{
+ QImage sourceImage(1770, 1477, QImage::Format_RGB32);
+ QImage rotatedImage(1478, 1771, QImage::Format_RGB32);
+ QTransform transformCenter;
+ transformCenter.translate(739.0, 885.5);
+ transformCenter.rotate(270.0);
+ transformCenter.translate(-885.0, -738.5);
+ QPainter painter;
+ painter.begin(&rotatedImage);
+ painter.setTransform(transformCenter);
+ painter.drawImage(QPoint(0, 0),sourceImage);
+ painter.end();
+
+ // If no crash or illegal memory read, all is fine
+}
+
QTEST_MAIN(tst_QPainter)
#include "tst_qpainter.moc"
diff --git a/tests/auto/gui/painting/qregion/tst_qregion.cpp b/tests/auto/gui/painting/qregion/tst_qregion.cpp
index 6a297dbfc2..b20ad0f33c 100644
--- a/tests/auto/gui/painting/qregion/tst_qregion.cpp
+++ b/tests/auto/gui/painting/qregion/tst_qregion.cpp
@@ -33,7 +33,7 @@
#include <qbitmap.h>
#include <qpainter.h>
#include <qpolygon.h>
-#ifdef Q_DEAD_CODE_FROM_QT4_X11
+#if 0 // Used to be included in Qt4 for Q_WS_X11
#include <private/qt_x11_p.h>
#endif
@@ -79,7 +79,7 @@ private slots:
void isEmpty_data();
void isEmpty();
-#if defined(Q_DEAD_CODE_FROM_QT4_X11) && defined(QT_BUILD_INTERNAL)
+#if 0 /* Used to be included in Qt4 for Q_WS_X11 */ && defined(QT_BUILD_INTERNAL)
void clipRectangles();
#endif
@@ -893,7 +893,7 @@ void tst_QRegion::isEmpty()
QVERIFY(region.rects().isEmpty());
}
-#if defined(Q_DEAD_CODE_FROM_QT4_X11) && defined(QT_BUILD_INTERNAL)
+#if 0 /* Used to be included in Qt4 for Q_WS_X11 */ && defined(QT_BUILD_INTERNAL)
void tst_QRegion::clipRectangles()
{
QRegion region(30, 30, 30, 30);
diff --git a/tests/auto/gui/qopengl/tst_qopengl.cpp b/tests/auto/gui/qopengl/tst_qopengl.cpp
index ed48a4978a..44921f68aa 100644
--- a/tests/auto/gui/qopengl/tst_qopengl.cpp
+++ b/tests/auto/gui/qopengl/tst_qopengl.cpp
@@ -109,6 +109,7 @@ private slots:
void vaoCreate();
void bufferCreate();
void bufferMapRange();
+ void defaultQGLCurrentBuffer();
};
struct SharedResourceTracker
@@ -1520,6 +1521,33 @@ void tst_QOpenGL::bufferMapRange()
ctx->doneCurrent();
}
+void tst_QOpenGL::defaultQGLCurrentBuffer()
+{
+ QScopedPointer<QSurface> surface(createSurface(QSurface::Window));
+ QScopedPointer<QOpenGLContext> ctx(new QOpenGLContext);
+ ctx->create();
+ ctx->makeCurrent(surface.data());
+
+ // Bind default FBO on the current context, and record what's the current QGL FBO. It should
+ // be Q_NULLPTR because the default platform OpenGL FBO is not backed by a
+ // QOpenGLFramebufferObject.
+ QOpenGLFramebufferObject::bindDefault();
+ QOpenGLFramebufferObject *defaultQFBO = QOpenGLContextPrivate::get(ctx.data())->qgl_current_fbo;
+
+ // Create new FBO, bind it, and see that the QGL FBO points to the newly created FBO.
+ QScopedPointer<QOpenGLFramebufferObject> obj(new QOpenGLFramebufferObject(128, 128));
+ obj->bind();
+ QOpenGLFramebufferObject *customQFBO = QOpenGLContextPrivate::get(ctx.data())->qgl_current_fbo;
+ QVERIFY(defaultQFBO != customQFBO);
+
+ // Bind the default FBO, and check that the QGL FBO points to the original FBO object.
+ QOpenGLFramebufferObject::bindDefault();
+ QOpenGLFramebufferObject *finalQFBO = QOpenGLContextPrivate::get(ctx.data())->qgl_current_fbo;
+ QCOMPARE(defaultQFBO, finalQFBO);
+
+ ctx->doneCurrent();
+}
+
void tst_QOpenGL::nullTextureInitializtion()
{
QScopedPointer<QSurface> surface(createSurface(QSurface::Window));
diff --git a/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp b/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp
index 45cfd6f43a..dbe5bf7cc6 100644
--- a/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp
+++ b/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp
@@ -844,6 +844,7 @@ void tst_QCssParser::colorValue_data()
QTest::newRow("hsla") << "color: hsva(10, 20, 30, 40)" << QColor::fromHsv(10, 20, 30, 40);
QTest::newRow("invalid1") << "color: rgb(why, does, it, always, rain, on, me)" << QColor();
QTest::newRow("invalid2") << "color: rgba(i, meant, norway)" << QColor();
+ QTest::newRow("invalid3") << "color: rgb(21)" << QColor();
QTest::newRow("role") << "color: palette(base)" << qApp->palette().color(QPalette::Base);
QTest::newRow("role2") << "color: palette( window-text ) " << qApp->palette().color(QPalette::WindowText);
QTest::newRow("transparent") << "color: transparent" << QColor(Qt::transparent);
diff --git a/tests/auto/gui/text/qfontdatabase/qfontdatabase.pro b/tests/auto/gui/text/qfontdatabase/qfontdatabase.pro
index 8a08cdc182..9d357a35f2 100644
--- a/tests/auto/gui/text/qfontdatabase/qfontdatabase.pro
+++ b/tests/auto/gui/text/qfontdatabase/qfontdatabase.pro
@@ -4,7 +4,5 @@ SOURCES += tst_qfontdatabase.cpp
QT += testlib core-private gui-private
TESTDATA += LED_REAL.TTF
-android {
- RESOURCES += testdata.qrc
-}
+RESOURCES += testdata.qrc
diff --git a/tests/auto/gui/text/qfontdatabase/testdata.qrc b/tests/auto/gui/text/qfontdatabase/testdata.qrc
index 8a8670bf17..81a0b5b0bf 100644
--- a/tests/auto/gui/text/qfontdatabase/testdata.qrc
+++ b/tests/auto/gui/text/qfontdatabase/testdata.qrc
@@ -1,5 +1,7 @@
<RCC>
<qresource prefix="/">
<file>LED_REAL.TTF</file>
+ <file alias="testfont.ttf">../../../shared/resources/testfont.ttf</file>
+ <file alias="testfont_condensed.ttf">../../../shared/resources/testfont_condensed.ttf</file>
</qresource>
</RCC>
diff --git a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
index f71d808390..c53792da99 100644
--- a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+++ b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
@@ -64,20 +64,27 @@ private slots:
void aliases();
void fallbackFonts();
- void liberationFont();
+ void condensedFontWidth();
+ void condensedFontMatching();
private:
- const QString m_testFont;
+ QString m_ledFont;
+ QString m_testFont;
+ QString m_testFontCondensed;
};
tst_QFontDatabase::tst_QFontDatabase()
- : m_testFont(QFINDTESTDATA("LED_REAL.TTF"))
{
}
void tst_QFontDatabase::initTestCase()
{
+ m_ledFont = QFINDTESTDATA("LED_REAL.TTF");
+ m_testFont = QFINDTESTDATA("testfont.ttf");
+ m_testFontCondensed = QFINDTESTDATA("testfont_condensed.ttf");
+ QVERIFY(!m_ledFont.isEmpty());
QVERIFY(!m_testFont.isEmpty());
+ QVERIFY(!m_testFontCondensed.isEmpty());
}
void tst_QFontDatabase::styles_data()
@@ -209,13 +216,13 @@ void tst_QFontDatabase::addAppFont()
int id;
if (useMemoryFont) {
- QFile fontfile(m_testFont);
+ QFile fontfile(m_ledFont);
fontfile.open(QIODevice::ReadOnly);
QByteArray fontdata = fontfile.readAll();
QVERIFY(!fontdata.isEmpty());
id = QFontDatabase::addApplicationFontFromData(fontdata);
} else {
- id = QFontDatabase::addApplicationFont(m_testFont);
+ id = QFontDatabase::addApplicationFont(m_ledFont);
}
#if defined(Q_OS_HPUX) && defined(QT_NO_FONTCONFIG)
// Documentation says that X11 systems that don't have fontconfig
@@ -277,22 +284,54 @@ void tst_QFontDatabase::fallbackFonts()
}
}
-void tst_QFontDatabase::liberationFont()
+static QString testString()
{
- QString libSans("Liberation Sans");
- QString libSansNarrow("Liberation Sans Narrow");
+ return QStringLiteral("foo bar");
+}
+void tst_QFontDatabase::condensedFontWidth()
+{
QFontDatabase db;
- if (!db.hasFamily(libSans) || !db.hasFamily(libSansNarrow))
- QSKIP("Requires Liberation Sans installed");
+ QFontDatabase::addApplicationFont(m_testFont);
+ QFontDatabase::addApplicationFont(m_testFontCondensed);
+
+ QVERIFY(db.hasFamily("QtBidiTestFont"));
+ if (!db.hasFamily("QtBidiTestFontCondensed"))
+ QSKIP("This platform doesn't support font sub-family names (QTBUG-55625)");
- QFont fontLS(libSans);
- QFont fontLSN(libSansNarrow);
+ // Test we really get a condensed font, and a not renormalized one (QTBUG-48043):
+ QFont testFont("QtBidiTestFont");
+ QFont testFontCondensed("QtBidiTestFontCondensed");
+ QFontMetrics fmTF(testFont);
+ QFontMetrics fmTFC(testFontCondensed);
+ QVERIFY(fmTF.width(testString()) > fmTFC.width(testString()));
- QFontMetrics fmLS(fontLS);
- QFontMetrics fmLSN(fontLSN);
+}
- QVERIFY(fmLS.width(QStringLiteral("foo bar")) > fmLSN.width(QStringLiteral("foo bar")));
+void tst_QFontDatabase::condensedFontMatching()
+{
+ QFontDatabase db;
+ QFontDatabase::removeAllApplicationFonts();
+ QFontDatabase::addApplicationFont(m_testFontCondensed);
+ if (!db.hasFamily("QtBidiTestFont"))
+ QSKIP("This platform doesn't support preferred font family names (QTBUG-53478)");
+ QFontDatabase::addApplicationFont(m_testFont);
+
+ // Test we correctly get the condensed font using different font matching methods:
+ QFont tfcByStretch("QtBidiTestFont");
+ tfcByStretch.setStretch(QFont::Condensed);
+ QFont tfcByStyleName("QtBidiTestFont");
+ tfcByStyleName.setStyleName("Condensed");
+
+ QCOMPARE(QFontMetrics(tfcByStretch).width(testString()),
+ QFontMetrics(tfcByStyleName).width(testString()));
+
+ if (!db.hasFamily("QtBidiTestFontCondensed"))
+ QSKIP("This platform doesn't support font sub-family names (QTBUG-55625)");
+
+ QFont tfcBySubfamilyName("QtBidiTestFontCondensed");
+ QCOMPARE(QFontMetrics(tfcByStyleName).width(testString()),
+ QFontMetrics(tfcBySubfamilyName).width(testString()));
}
QTEST_MAIN(tst_QFontDatabase)