summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qgl/tst_qgl.cpp103
-rw-r--r--tests/auto/qpainter/tst_qpainter.cpp48
-rw-r--r--tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp38
-rw-r--r--tests/auto/qstatictext/qstatictext.pro2
-rw-r--r--tests/auto/qstatictext/tst_qstatictext.cpp37
-rw-r--r--tests/auto/qstringbuilder1/stringbuilder.cpp14
-rw-r--r--tests/auto/qtreeview/tst_qtreeview.cpp14
7 files changed, 205 insertions, 51 deletions
diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp
index 1bf7850..6ffe2a7 100644
--- a/tests/auto/qgl/tst_qgl.cpp
+++ b/tests/auto/qgl/tst_qgl.cpp
@@ -978,6 +978,47 @@ void tst_QGL::glWidgetWithAlpha()
delete w;
}
+
+void qt_opengl_draw_test_pattern(QPainter* painter, int width, int height)
+{
+ QPainterPath intersectingPath;
+ intersectingPath.moveTo(0, 0);
+ intersectingPath.lineTo(100, 0);
+ intersectingPath.lineTo(0, 100);
+ intersectingPath.lineTo(100, 100);
+ intersectingPath.closeSubpath();
+
+ QPainterPath trianglePath;
+ trianglePath.moveTo(50, 0);
+ trianglePath.lineTo(100, 100);
+ trianglePath.lineTo(0, 100);
+ trianglePath.closeSubpath();
+
+ painter->setTransform(QTransform()); // reset xform
+ painter->fillRect(-1, -1, width+2, height+2, Qt::red); // Background
+ painter->translate(14, 14);
+ painter->fillPath(intersectingPath, Qt::blue); // Test stencil buffer works
+ painter->translate(128, 0);
+ painter->setClipPath(trianglePath); // Test depth buffer works
+ painter->setTransform(QTransform()); // reset xform ready for fill
+ painter->fillRect(-1, -1, width+2, height+2, Qt::green);
+}
+
+void qt_opengl_check_test_pattern(const QImage& img)
+{
+ // As we're doing more than trivial painting, we can't just compare to
+ // an image rendered with raster. Instead, we sample at well-defined
+ // test-points:
+ QFUZZY_COMPARE_PIXELS(img.pixel(39, 64), QColor(Qt::red).rgb());
+ QFUZZY_COMPARE_PIXELS(img.pixel(89, 64), QColor(Qt::red).rgb());
+ QFUZZY_COMPARE_PIXELS(img.pixel(64, 39), QColor(Qt::blue).rgb());
+ QFUZZY_COMPARE_PIXELS(img.pixel(64, 89), QColor(Qt::blue).rgb());
+
+ QFUZZY_COMPARE_PIXELS(img.pixel(167, 39), QColor(Qt::red).rgb());
+ QFUZZY_COMPARE_PIXELS(img.pixel(217, 39), QColor(Qt::red).rgb());
+ QFUZZY_COMPARE_PIXELS(img.pixel(192, 64), QColor(Qt::green).rgb());
+}
+
class GLWidget : public QGLWidget
{
public:
@@ -992,9 +1033,7 @@ public:
QPaintEngine* pe = p.paintEngine();
engineType = pe->type();
- // This test only ensures it's possible to paint onto a QGLWidget. Full
- // paint engine feature testing is way out of scope!
- p.fillRect(-1, -1, width()+2, height()+2, Qt::red);
+ qt_opengl_draw_test_pattern(&p, width(), height());
// No p.end() or swap buffers, should be done automatically
}
@@ -1007,7 +1046,7 @@ void tst_QGL::glWidgetRendering()
#ifdef Q_WS_QWS
w.setWindowFlags(Qt::FramelessWindowHint);
#endif
- w.setGeometry(100, 100, 200, 200);
+ w.resize(256, 128);
w.show();
#ifdef Q_WS_X11
@@ -1018,11 +1057,8 @@ void tst_QGL::glWidgetRendering()
QVERIFY(w.beginOk);
QVERIFY(w.engineType == QPaintEngine::OpenGL || w.engineType == QPaintEngine::OpenGL2);
- QImage fb = w.grabFrameBuffer(false).convertToFormat(QImage::Format_RGB32);
- QImage reference(fb.size(), QImage::Format_RGB32);
- reference.fill(0xffff0000);
-
- QFUZZY_COMPARE_IMAGES(fb, reference);
+ QImage fb = w.grabFrameBuffer(false);
+ qt_opengl_check_test_pattern(fb);
}
void tst_QGL::glFBOSimpleRendering()
@@ -1075,46 +1111,23 @@ void tst_QGL::glFBORendering()
// Don't complicate things by using NPOT:
QGLFramebufferObject *fbo = new QGLFramebufferObject(256, 128, fboFormat);
+ if (fbo->attachment() != QGLFramebufferObject::CombinedDepthStencil) {
+ delete fbo;
+ QSKIP("FBOs missing combined depth~stencil support", SkipSingle);
+ }
+
QPainter fboPainter;
bool painterBegun = fboPainter.begin(fbo);
QVERIFY(painterBegun);
- QPainterPath intersectingPath;
- intersectingPath.moveTo(0, 0);
- intersectingPath.lineTo(100, 0);
- intersectingPath.lineTo(0, 100);
- intersectingPath.lineTo(100, 100);
- intersectingPath.closeSubpath();
-
- QPainterPath trianglePath;
- trianglePath.moveTo(50, 0);
- trianglePath.lineTo(100, 100);
- trianglePath.lineTo(0, 100);
- trianglePath.closeSubpath();
+ qt_opengl_draw_test_pattern(&fboPainter, fbo->width(), fbo->height());
- fboPainter.fillRect(0, 0, fbo->width(), fbo->height(), Qt::red); // Background
- fboPainter.translate(14, 14);
- fboPainter.fillPath(intersectingPath, Qt::blue); // Test stencil buffer works
- fboPainter.translate(128, 0);
- fboPainter.setClipPath(trianglePath); // Test depth buffer works
- fboPainter.setTransform(QTransform()); // reset xform
- fboPainter.fillRect(0, 0, fbo->width(), fbo->height(), Qt::green);
fboPainter.end();
QImage fb = fbo->toImage().convertToFormat(QImage::Format_RGB32);
delete fbo;
- // As we're doing more than trivial painting, we can't just compare to
- // an image rendered with raster. Instead, we sample at well-defined
- // test-points:
- QFUZZY_COMPARE_PIXELS(fb.pixel(39, 64), QColor(Qt::red).rgb());
- QFUZZY_COMPARE_PIXELS(fb.pixel(89, 64), QColor(Qt::red).rgb());
- QFUZZY_COMPARE_PIXELS(fb.pixel(64, 39), QColor(Qt::blue).rgb());
- QFUZZY_COMPARE_PIXELS(fb.pixel(64, 89), QColor(Qt::blue).rgb());
-
- QFUZZY_COMPARE_PIXELS(fb.pixel(167, 39), QColor(Qt::red).rgb());
- QFUZZY_COMPARE_PIXELS(fb.pixel(217, 39), QColor(Qt::red).rgb());
- QFUZZY_COMPARE_PIXELS(fb.pixel(192, 64), QColor(Qt::green).rgb());
+ qt_opengl_check_test_pattern(fb);
}
@@ -1137,6 +1150,16 @@ void tst_QGL::multipleFBOInterleavedRendering()
QGLFramebufferObject *fbo2 = new QGLFramebufferObject(256, 128, fboFormat);
QGLFramebufferObject *fbo3 = new QGLFramebufferObject(256, 128, fboFormat);
+ if ( (fbo1->attachment() != QGLFramebufferObject::CombinedDepthStencil) ||
+ (fbo2->attachment() != QGLFramebufferObject::CombinedDepthStencil) ||
+ (fbo3->attachment() != QGLFramebufferObject::CombinedDepthStencil) )
+ {
+ delete fbo1;
+ delete fbo2;
+ delete fbo3;
+ QSKIP("FBOs missing combined depth~stencil support", SkipSingle);
+ }
+
QPainter fbo1Painter;
QPainter fbo2Painter;
QPainter fbo3Painter;
@@ -1242,7 +1265,7 @@ protected:
QPainter widgetPainter;
widgetPainterBeginOk = widgetPainter.begin(this);
QGLFramebufferObjectFormat fboFormat;
- fboFormat.setAttachment(QGLFramebufferObject::CombinedDepthStencil);
+ fboFormat.setAttachment(QGLFramebufferObject::NoAttachment);
QGLFramebufferObject *fbo = new QGLFramebufferObject(128, 128, fboFormat);
QPainter fboPainter;
diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp
index beb83a1..a03b2c7 100644
--- a/tests/auto/qpainter/tst_qpainter.cpp
+++ b/tests/auto/qpainter/tst_qpainter.cpp
@@ -107,6 +107,7 @@ private slots:
void saveAndRestore();
void drawBorderPixmap();
+ void drawPixmapFragments();
void drawLine_data();
void drawLine();
@@ -994,6 +995,49 @@ void tst_QPainter::drawBorderPixmap()
QTileRules(Qt::StretchTile,Qt::StretchTile), 0);
}
+void tst_QPainter::drawPixmapFragments()
+{
+ QPixmap origPixmap(20, 20);
+ QPixmap resPixmap(20, 20);
+ QPainter::Fragment fragments[4] = { {15, 15, 0, 0, 10, 10, 1, 1, 0, 1},
+ { 5, 15, 10, 0, 10, 10, 1, 1, 0, 1},
+ {15, 5, 0, 10, 10, 10, 1, 1, 0, 1},
+ { 5, 5, 10, 10, 10, 10, 1, 1, 0, 1} };
+ {
+ QPainter p(&origPixmap);
+ p.fillRect(0, 0, 10, 10, Qt::red);
+ p.fillRect(10, 0, 10, 10, Qt::green);
+ p.fillRect(0, 10, 10, 10, Qt::blue);
+ p.fillRect(10, 10, 10, 10, Qt::yellow);
+ }
+ {
+ QPainter p(&resPixmap);
+ p.drawPixmapFragments(fragments, 4, origPixmap);
+ }
+
+ QImage origImage = origPixmap.toImage().convertToFormat(QImage::Format_ARGB32);
+ QImage resImage = resPixmap.toImage().convertToFormat(QImage::Format_ARGB32);
+
+ QVERIFY(resImage.size() == resPixmap.size());
+ QVERIFY(resImage.pixel(5, 5) == origImage.pixel(15, 15));
+ QVERIFY(resImage.pixel(5, 15) == origImage.pixel(15, 5));
+ QVERIFY(resImage.pixel(15, 5) == origImage.pixel(5, 15));
+ QVERIFY(resImage.pixel(15, 15) == origImage.pixel(5, 5));
+
+
+ QPainter::Fragment fragment = QPainter::Fragment::create(QPointF(20, 20), QRectF(30, 30, 2, 2));
+ QVERIFY(fragment.x == 20);
+ QVERIFY(fragment.y == 20);
+ QVERIFY(fragment.sourceLeft == 30);
+ QVERIFY(fragment.sourceTop == 30);
+ QVERIFY(fragment.width == 2);
+ QVERIFY(fragment.height == 2);
+ QVERIFY(fragment.scaleX == 1);
+ QVERIFY(fragment.scaleY == 1);
+ QVERIFY(fragment.rotation == 0);
+ QVERIFY(fragment.opacity == 1);
+}
+
void tst_QPainter::drawLine_data()
{
QTest::addColumn<QLine>("line");
@@ -3443,8 +3487,8 @@ bool verifyOutlineFillConsistency(const QImage &img, QRgb outside, QRgb inside,
if ((dx == 0) == (dy == 0))
continue;
QRgb neighbor = img.pixel(p.x() + dx, p.y() + dy);
- if (pixel == inside && neighbor == outside ||
- pixel == outside && neighbor == inside)
+ if ((pixel == inside && neighbor == outside) ||
+ (pixel == outside && neighbor == inside))
return false;
}
}
diff --git a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
index 5b2b0cf..56eaf25 100644
--- a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
+++ b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
@@ -137,6 +137,7 @@ private slots:
void task255652_removeRowsRecursive();
void taskQTBUG_6205_doubleProxySelectionSetSourceModel();
void taskQTBUG_7537_appearsAndSort();
+ void taskQTBUG_7716_unnecessaryDynamicSorting();
protected:
void buildHierarchy(const QStringList &data, QAbstractItemModel *model);
@@ -918,15 +919,16 @@ void tst_QSortFilterProxyModel::removeRows()
QStandardItemModel model;
QSortFilterProxyModel proxy;
proxy.setSourceModel(&model);
- if (sortOrder != -1)
- proxy.sort(0, static_cast<Qt::SortOrder>(sortOrder));
- if (!filter.isEmpty())
- proxy.setFilterRegExp(QRegExp(filter));
// prepare model
foreach (QString s, initial)
model.appendRow(new QStandardItem(s));
+ if (sortOrder != -1)
+ proxy.sort(0, static_cast<Qt::SortOrder>(sortOrder));
+ if (!filter.isEmpty())
+ proxy.setFilterRegExp(QRegExp(filter));
+
// remove the rows
QCOMPARE(proxy.removeRows(position, count, QModelIndex()), success);
QCOMPARE(model.rowCount(QModelIndex()), expectedSource.count());
@@ -2419,6 +2421,7 @@ void tst_QSortFilterProxyModel::sortColumnTracking2()
{
QStandardItemModel model;
QSortFilterProxyModel proxyModel;
+ proxyModel.setDynamicSortFilter(true);
proxyModel.setSourceModel(&model);
proxyModel.sort(0);
@@ -2921,5 +2924,32 @@ void tst_QSortFilterProxyModel::taskQTBUG_7537_appearsAndSort()
QCOMPARE(spyChanged2.count(), 1);
}
+void tst_QSortFilterProxyModel::taskQTBUG_7716_unnecessaryDynamicSorting()
+{
+ QStringListModel model;
+ const QStringList initial = QString("bravo charlie delta echo").split(" ");
+ model.setStringList(initial);
+ QSortFilterProxyModel proxy;
+ proxy.setDynamicSortFilter(false);
+ proxy.setSourceModel(&model);
+ proxy.sort(Qt::AscendingOrder);
+
+ //append two rows
+ int maxrows = proxy.rowCount(QModelIndex());
+ model.insertRows(maxrows, 2);
+ model.setData(model.index(maxrows, 0), QString("alpha"));
+ model.setData(model.index(maxrows + 1, 0), QString("fondue"));
+
+ //append new items to the initial string list and compare with model
+ QStringList expected = initial;
+ expected << QString("alpha") << QString("fondue");
+
+ //if bug 7716 is present, new rows were prepended, when they should have been appended
+ for (int row = 0; row < proxy.rowCount(QModelIndex()); ++row) {
+ QModelIndex index = proxy.index(row, 0, QModelIndex());
+ QCOMPARE(proxy.data(index, Qt::DisplayRole).toString(), expected.at(row));
+ }
+}
+
QTEST_MAIN(tst_QSortFilterProxyModel)
#include "tst_qsortfilterproxymodel.moc"
diff --git a/tests/auto/qstatictext/qstatictext.pro b/tests/auto/qstatictext/qstatictext.pro
index a759a90..0f1ca68 100644
--- a/tests/auto/qstatictext/qstatictext.pro
+++ b/tests/auto/qstatictext/qstatictext.pro
@@ -1,4 +1,4 @@
load(qttest_p4)
-QT = core gui opengl
+QT = core gui
SOURCES += tst_qstatictext.cpp
diff --git a/tests/auto/qstatictext/tst_qstatictext.cpp b/tests/auto/qstatictext/tst_qstatictext.cpp
index 68f05c1..16832ad 100644
--- a/tests/auto/qstatictext/tst_qstatictext.cpp
+++ b/tests/auto/qstatictext/tst_qstatictext.cpp
@@ -45,13 +45,20 @@
#include <QtGui/QImage>
#include <qstatictext.h>
+#include <qpaintengine.h>
+
#include <private/qstatictext_p.h>
+#include <private/qapplication_p.h>
// #define DEBUG_SAVE_IMAGE
class tst_QStaticText: public QObject
{
Q_OBJECT
+
+private:
+ bool supportsTransformations() const;
+
private slots:
void init();
void cleanup();
@@ -177,6 +184,8 @@ void tst_QStaticText::prepareToCorrectData()
p.drawStaticText(QPointF(11, 12), text);
}
+ if (!supportsTransformations())
+ QEXPECT_FAIL("", "Graphics system does not support transformed text on this platform", Abort);
QCOMPARE(imageDrawStaticText, imageDrawText);
}
@@ -288,6 +297,25 @@ void tst_QStaticText::translatedPainter()
QCOMPARE(imageDrawStaticText, imageDrawText);
}
+bool tst_QStaticText::supportsTransformations() const
+{
+ QPixmap pm(10, 10);
+ QPainter p(&pm);
+ QPaintEngine *engine = p.paintEngine();
+
+ QPaintEngine::Type type = engine->type();
+
+ if (type == QPaintEngine::OpenGL2
+ || type == QPaintEngine::OpenGL
+#if !defined Q_WS_WIN
+ || type == QPaintEngine::Raster
+#endif
+ )
+ return false;
+
+ return true;
+}
+
void tst_QStaticText::rotatedPainter()
{
QPixmap imageDrawText(1000, 1000);
@@ -314,6 +342,8 @@ void tst_QStaticText::rotatedPainter()
imageDrawStaticText.save("rotatedPainter_imageDrawStaticText.png");
#endif
+ if (!supportsTransformations())
+ QEXPECT_FAIL("", "Graphics system does not support transformed text on this platform", Abort);
QCOMPARE(imageDrawStaticText, imageDrawText);
}
@@ -340,6 +370,8 @@ void tst_QStaticText::scaledPainter()
p.drawStaticText(QPointF(11, 12), text);
}
+ if (!supportsTransformations())
+ QEXPECT_FAIL("", "Graphics system does not support transformed text on this platform", Abort);
QCOMPARE(imageDrawStaticText, imageDrawText);
}
@@ -370,7 +402,6 @@ void tst_QStaticText::projectedPainter()
}
QCOMPARE(imageDrawStaticText, imageDrawText);
-
}
void tst_QStaticText::rotatedScaledAndTranslatedPainter()
@@ -405,6 +436,8 @@ void tst_QStaticText::rotatedScaledAndTranslatedPainter()
imageDrawStaticText.save("rotatedScaledAndPainter_imageDrawStaticText.png");
#endif
+ if (!supportsTransformations())
+ QEXPECT_FAIL("", "Graphics system does not support transformed text on this platform", Abort);
QCOMPARE(imageDrawStaticText, imageDrawText);
}
@@ -444,6 +477,8 @@ void tst_QStaticText::transformationChanged()
imageDrawStaticText.save("transformationChanged_imageDrawStaticText.png");
#endif
+ if (!supportsTransformations())
+ QEXPECT_FAIL("", "Graphics system does not support transformed text on this platform", Abort);
QCOMPARE(imageDrawStaticText, imageDrawText);
}
diff --git a/tests/auto/qstringbuilder1/stringbuilder.cpp b/tests/auto/qstringbuilder1/stringbuilder.cpp
index 8e95818..e9ae7a6 100644
--- a/tests/auto/qstringbuilder1/stringbuilder.cpp
+++ b/tests/auto/qstringbuilder1/stringbuilder.cpp
@@ -44,6 +44,14 @@
// "some literal", but replacing all vocals by their umlauted UTF-8 string :)
#define UTF8_LITERAL "s\xc3\xb6m\xc3\xab l\xc3\xaft\xc3\xabr\xc3\xa4l"
+
+//fix for gcc4.0: if the operator+ does not exist without QT_USE_FAST_OPERATOR_PLUS
+#ifndef QT_USE_FAST_CONCATENATION
+#define Q %
+#else
+#define Q P
+#endif
+
void runScenario()
{
// set codec for C strings to 0, enforcing Latin1
@@ -59,13 +67,13 @@ void runScenario()
QString r;
QByteArray ba(LITERAL);
- r = l1literal P l1literal;
+ r = l1literal Q l1literal;
QCOMPARE(r, r2);
r = string P string;
QCOMPARE(r, r2);
- r = stringref P stringref;
+ r = stringref Q stringref;
QCOMPARE(r, QString(stringref.toString() + stringref.toString()));
- r = string P l1literal;
+ r = string Q l1literal;
QCOMPARE(r, r2);
r = string P l1string;
QCOMPARE(r, r2);
diff --git a/tests/auto/qtreeview/tst_qtreeview.cpp b/tests/auto/qtreeview/tst_qtreeview.cpp
index fd4815e..e39cf6c 100644
--- a/tests/auto/qtreeview/tst_qtreeview.cpp
+++ b/tests/auto/qtreeview/tst_qtreeview.cpp
@@ -3083,6 +3083,20 @@ void tst_QTreeView::styleOptionViewItem()
QApplication::processEvents();
QTRY_VERIFY(delegate.count >= 3);
QApplication::processEvents();
+
+ item00->setText("OnlyOne");
+ item0->insertRow(2, new QStandardItem("OnlyOne Last"));
+ view.collapse(item0->index());
+ item0->removeRow(0);
+ delegate.count = 0;
+ QTRY_VERIFY(delegate.count >= 2);
+ QApplication::processEvents();
+
+ item0->removeRow(1);
+ item0->setText("OnlyOne");
+ delegate.count = 0;
+ QTRY_VERIFY(delegate.count >= 2);
+ QApplication::processEvents();
}
}