summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qcombobox/tst_qcombobox.cpp36
-rw-r--r--tests/auto/qgl/tst_qgl.cpp13
-rw-r--r--tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp186
-rw-r--r--tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp89
-rw-r--r--tests/auto/qpixmapfilter/tst_qpixmapfilter.cpp41
-rw-r--r--tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp61
-rw-r--r--tests/auto/qsslcertificate/tst_qsslcertificate.cpp5
-rw-r--r--tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp5
-rw-r--r--tests/auto/qwidget/tst_qwidget.cpp5
9 files changed, 316 insertions, 125 deletions
diff --git a/tests/auto/qcombobox/tst_qcombobox.cpp b/tests/auto/qcombobox/tst_qcombobox.cpp
index e75b9cd..810be04 100644
--- a/tests/auto/qcombobox/tst_qcombobox.cpp
+++ b/tests/auto/qcombobox/tst_qcombobox.cpp
@@ -147,6 +147,7 @@ private slots:
void task253944_itemDelegateIsReset();
void subControlRectsWithOffset_data();
void subControlRectsWithOffset();
+ void task260974_menuItemRectangleForComboBoxPopup();
protected slots:
void onEditTextChanged( const QString &newString );
@@ -2339,5 +2340,40 @@ void tst_QComboBox::subControlRectsWithOffset()
}
+void tst_QComboBox::task260974_menuItemRectangleForComboBoxPopup()
+{
+ class TestStyle: public QWindowsStyle
+ {
+ public:
+ int styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget, QStyleHintReturn *ret) const
+ {
+ if (hint == SH_ComboBox_Popup) return 1;
+ else return QCommonStyle::styleHint(hint, option, widget, ret);
+ }
+
+ void drawControl(ControlElement element, const QStyleOption *option, QPainter *, const QWidget *) const
+ {
+ if (element == CE_MenuItem)
+ discoveredRect = option->rect;
+ }
+
+ mutable QRect discoveredRect;
+ } style;
+
+
+ {
+ QComboBox comboBox;
+ comboBox.setStyle(&style);
+ comboBox.addItem("Item 1");
+
+ comboBox.show();
+ QTest::qWait(100);
+ comboBox.showPopup();
+ QTest::qWait(100);
+
+ QVERIFY(style.discoveredRect.width() <= comboBox.width());
+ }
+}
+
QTEST_MAIN(tst_QComboBox)
#include "tst_qcombobox.moc"
diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp
index ebbfbae..a0b8b5d 100644
--- a/tests/auto/qgl/tst_qgl.cpp
+++ b/tests/auto/qgl/tst_qgl.cpp
@@ -81,6 +81,8 @@ private slots:
void stackedFBOs();
void colormap();
void fboFormat();
+
+ void testDontCrashOnDanglingResources();
};
tst_QGL::tst_QGL()
@@ -1513,5 +1515,16 @@ void tst_QGL::fboFormat()
QVERIFY(format1c != format4c);
}
+void tst_QGL::testDontCrashOnDanglingResources()
+{
+ // We have a number of Q_GLOBAL_STATICS inside the QtOpenGL
+ // library. This test is verify that we don't crash as a result of
+ // them calling into libgl on application shutdown.
+ QWidget *widget = new UnclippedWidget();
+ widget->show();
+ qApp->processEvents();
+ widget->hide();
+}
+
QTEST_MAIN(tst_QGL)
#include "tst_qgl.moc"
diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
index 95476f0..059ad33 100644
--- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
+++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
@@ -64,6 +64,7 @@ private slots:
void example();
void setSpacing();
void hardComplexS60();
+ void delete_anchor();
};
class RectWidget : public QGraphicsWidget
@@ -101,8 +102,8 @@ static void setAnchor(QGraphicsAnchorLayout *l,
Qt::AnchorPoint secondEdge,
qreal spacing)
{
- l->addAnchor(firstItem, firstEdge, secondItem, secondEdge);
- l->setAnchorSpacing(firstItem, firstEdge, secondItem, secondEdge, spacing);
+ QGraphicsAnchor *anchor = l->addAnchor(firstItem, firstEdge, secondItem, secondEdge);
+ anchor->setSpacing(spacing);
}
static bool checkReverseDirection(QGraphicsWidget *w)
@@ -293,47 +294,29 @@ void tst_QGraphicsAnchorLayout::diagonal()
QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout;
l->setContentsMargins(0, 0, 0, 0);
+ l->setSpacing(0);
// vertical
l->addAnchor(a, Qt::AnchorTop, l, Qt::AnchorTop);
- l->setAnchorSpacing(a, Qt::AnchorTop, l, Qt::AnchorTop, 0);
-
l->addAnchor(b, Qt::AnchorTop, l, Qt::AnchorTop);
- l->setAnchorSpacing(b, Qt::AnchorTop, l, Qt::AnchorTop, 0);
-
l->addAnchor(c, Qt::AnchorTop, a, Qt::AnchorBottom);
- l->setAnchorSpacing(c, Qt::AnchorTop, a, Qt::AnchorBottom, 0);
l->addAnchor(c, Qt::AnchorTop, b, Qt::AnchorBottom);
- l->setAnchorSpacing(c, Qt::AnchorTop, b, Qt::AnchorBottom, 0);
l->addAnchor(c, Qt::AnchorBottom, d, Qt::AnchorTop);
- l->setAnchorSpacing(c, Qt::AnchorBottom, d, Qt::AnchorTop, 0);
l->addAnchor(c, Qt::AnchorBottom, e, Qt::AnchorTop);
- l->setAnchorSpacing(c, Qt::AnchorBottom, e, Qt::AnchorTop, 0);
-
l->addAnchor(d, Qt::AnchorBottom, l, Qt::AnchorBottom);
- l->setAnchorSpacing(d, Qt::AnchorBottom, l, Qt::AnchorBottom, 0);
l->addAnchor(e, Qt::AnchorBottom, l, Qt::AnchorBottom);
- l->setAnchorSpacing(e, Qt::AnchorBottom, l, Qt::AnchorBottom, 0);
// horizontal
l->addAnchor(l, Qt::AnchorLeft, a, Qt::AnchorLeft);
- l->setAnchorSpacing(l, Qt::AnchorLeft, a, Qt::AnchorLeft, 0);
l->addAnchor(l, Qt::AnchorLeft, d, Qt::AnchorLeft);
- l->setAnchorSpacing(l, Qt::AnchorLeft, d, Qt::AnchorLeft, 0);
l->addAnchor(a, Qt::AnchorRight, b, Qt::AnchorLeft);
- l->setAnchorSpacing(a, Qt::AnchorRight, b, Qt::AnchorLeft, 0);
l->addAnchor(a, Qt::AnchorRight, c, Qt::AnchorLeft);
- l->setAnchorSpacing(a, Qt::AnchorRight, c, Qt::AnchorLeft, 0);
l->addAnchor(c, Qt::AnchorRight, e, Qt::AnchorLeft);
- l->setAnchorSpacing(c, Qt::AnchorRight, e, Qt::AnchorLeft, 0);
l->addAnchor(b, Qt::AnchorRight, l, Qt::AnchorRight);
- l->setAnchorSpacing(b, Qt::AnchorRight, l, Qt::AnchorRight, 0);
l->addAnchor(e, Qt::AnchorRight, l, Qt::AnchorRight);
- l->setAnchorSpacing(e, Qt::AnchorRight, l, Qt::AnchorRight, 0);
l->addAnchor(d, Qt::AnchorRight, e, Qt::AnchorLeft);
- l->setAnchorSpacing(d, Qt::AnchorRight, e, Qt::AnchorLeft, 0);
QCOMPARE(l->count(), 5);
@@ -412,40 +395,25 @@ void tst_QGraphicsAnchorLayout::parallel()
QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout;
l->setContentsMargins(0, 0, 0, 0);
+ l->setSpacing(0);
l->addAnchor(l, Qt::AnchorTop, a, Qt::AnchorTop);
- l->setAnchorSpacing(l, Qt::AnchorTop, a, Qt::AnchorTop, 0);
l->addAnchor(a, Qt::AnchorBottom, b, Qt::AnchorTop);
- l->setAnchorSpacing(a, Qt::AnchorBottom, b, Qt::AnchorTop, 0);
l->addAnchor(b, Qt::AnchorBottom, c, Qt::AnchorTop);
- l->setAnchorSpacing(b, Qt::AnchorBottom, c, Qt::AnchorTop, 0);
l->addAnchor(c, Qt::AnchorBottom, d, Qt::AnchorTop);
- l->setAnchorSpacing(c, Qt::AnchorBottom, d, Qt::AnchorTop, 0);
l->addAnchor(d, Qt::AnchorBottom, e, Qt::AnchorTop);
- l->setAnchorSpacing(d, Qt::AnchorBottom, e, Qt::AnchorTop, 0);
l->addAnchor(e, Qt::AnchorBottom, f, Qt::AnchorTop);
- l->setAnchorSpacing(e, Qt::AnchorBottom, f, Qt::AnchorTop, 0);
l->addAnchor(f, Qt::AnchorBottom, l, Qt::AnchorBottom);
- l->setAnchorSpacing(f, Qt::AnchorBottom, l, Qt::AnchorBottom, 0);
l->addAnchor(l, Qt::AnchorLeft, a, Qt::AnchorLeft);
- l->setAnchorSpacing(l, Qt::AnchorLeft, a, Qt::AnchorLeft, 0);
l->addAnchor(a, Qt::AnchorRight, b, Qt::AnchorLeft);
- l->setAnchorSpacing(a, Qt::AnchorRight, b, Qt::AnchorLeft, 0);
l->addAnchor(a, Qt::AnchorRight, c, Qt::AnchorLeft);
- l->setAnchorSpacing(a, Qt::AnchorRight, c, Qt::AnchorLeft, 0);
l->addAnchor(b, Qt::AnchorRight, d, Qt::AnchorLeft);
- l->setAnchorSpacing(b, Qt::AnchorRight, d, Qt::AnchorLeft, 0);
l->addAnchor(b, Qt::AnchorRight, e, Qt::AnchorLeft);
- l->setAnchorSpacing(b, Qt::AnchorRight, e, Qt::AnchorLeft, 0);
l->addAnchor(c, Qt::AnchorRight, f, Qt::AnchorLeft);
- l->setAnchorSpacing(c, Qt::AnchorRight, f, Qt::AnchorLeft, 0);
l->addAnchor(d, Qt::AnchorRight, f, Qt::AnchorLeft);
- l->setAnchorSpacing(d, Qt::AnchorRight, f, Qt::AnchorLeft, 0);
l->addAnchor(e, Qt::AnchorRight, f, Qt::AnchorLeft);
- l->setAnchorSpacing(e, Qt::AnchorRight, f, Qt::AnchorLeft, 0);
l->addAnchor(f, Qt::AnchorRight, l, Qt::AnchorRight);
- l->setAnchorSpacing(f, Qt::AnchorRight, l, Qt::AnchorRight, 0);
QCOMPARE(l->count(), 6);
@@ -503,19 +471,15 @@ void tst_QGraphicsAnchorLayout::parallel2()
QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout;
l->setContentsMargins(0, 0, 0, 0);
+ l->setSpacing(0);
l->addAnchor(l, Qt::AnchorTop, a, Qt::AnchorTop);
- l->setAnchorSpacing(l, Qt::AnchorTop, a, Qt::AnchorTop, 0);
l->addAnchor(a, Qt::AnchorBottom, b, Qt::AnchorTop);
- l->setAnchorSpacing(a, Qt::AnchorBottom, b, Qt::AnchorTop, 0);
l->addAnchor(b, Qt::AnchorBottom, l, Qt::AnchorBottom);
- l->setAnchorSpacing(b, Qt::AnchorBottom, l, Qt::AnchorBottom, 0);
- l->addLeftAndRightAnchors(l, a);
+ l->addAnchors(l, a, Qt::Horizontal);
l->addAnchor(l, Qt::AnchorLeft, b, Qt::AnchorLeft);
- l->setAnchorSpacing(l, Qt::AnchorLeft, b, Qt::AnchorLeft, 0);
l->addAnchor(b, Qt::AnchorRight, a, Qt::AnchorRight);
- l->setAnchorSpacing(b, Qt::AnchorRight, a, Qt::AnchorRight, 0);
QCOMPARE(l->count(), 2);
@@ -556,24 +520,17 @@ void tst_QGraphicsAnchorLayout::snake()
QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout;
l->setContentsMargins(0, 0, 0, 0);
+ l->setSpacing(0);
l->addAnchor(l, Qt::AnchorTop, a, Qt::AnchorTop);
- l->setAnchorSpacing(l, Qt::AnchorTop, a, Qt::AnchorTop, 0);
l->addAnchor(a, Qt::AnchorBottom, b, Qt::AnchorTop);
- l->setAnchorSpacing(a, Qt::AnchorBottom, b, Qt::AnchorTop, 0);
l->addAnchor(b, Qt::AnchorBottom, c, Qt::AnchorTop);
- l->setAnchorSpacing(b, Qt::AnchorBottom, c, Qt::AnchorTop, 0);
l->addAnchor(c, Qt::AnchorBottom, l, Qt::AnchorBottom);
- l->setAnchorSpacing(c, Qt::AnchorBottom, l, Qt::AnchorBottom, 0);
l->addAnchor(l, Qt::AnchorLeft, a, Qt::AnchorLeft);
- l->setAnchorSpacing(l, Qt::AnchorLeft, a, Qt::AnchorLeft, 0);
l->addAnchor(a, Qt::AnchorRight, b, Qt::AnchorRight);
- l->setAnchorSpacing(a, Qt::AnchorRight, b, Qt::AnchorRight, 0);
l->addAnchor(b, Qt::AnchorLeft, c, Qt::AnchorLeft);
- l->setAnchorSpacing(b, Qt::AnchorLeft, c, Qt::AnchorLeft, 0);
l->addAnchor(c, Qt::AnchorRight, l, Qt::AnchorRight);
- l->setAnchorSpacing(c, Qt::AnchorRight, l, Qt::AnchorRight, 0);
QCOMPARE(l->count(), 3);
@@ -623,27 +580,20 @@ void tst_QGraphicsAnchorLayout::snakeOppositeDirections()
QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout;
l->setContentsMargins(0, 0, 0, 0);
+ l->setSpacing(0);
l->addAnchor(l, Qt::AnchorTop, a, Qt::AnchorTop);
- l->setAnchorSpacing(l, Qt::AnchorTop, a, Qt::AnchorTop, 0);
l->addAnchor(a, Qt::AnchorBottom, b, Qt::AnchorTop);
- l->setAnchorSpacing(a, Qt::AnchorBottom, b, Qt::AnchorTop, 0);
l->addAnchor(b, Qt::AnchorBottom, c, Qt::AnchorTop);
- l->setAnchorSpacing(b, Qt::AnchorBottom, c, Qt::AnchorTop, 0);
l->addAnchor(c, Qt::AnchorBottom, l, Qt::AnchorBottom);
- l->setAnchorSpacing(c, Qt::AnchorBottom, l, Qt::AnchorBottom, 0);
l->addAnchor(l, Qt::AnchorLeft, a, Qt::AnchorLeft);
- l->setAnchorSpacing(l, Qt::AnchorLeft, a, Qt::AnchorLeft, 0);
// Both a and c are 'pointing' to b
l->addAnchor(a, Qt::AnchorRight, b, Qt::AnchorRight);
- l->setAnchorSpacing(a, Qt::AnchorRight, b, Qt::AnchorRight, 0);
l->addAnchor(c, Qt::AnchorLeft, b, Qt::AnchorLeft);
- l->setAnchorSpacing(c, Qt::AnchorLeft, b, Qt::AnchorLeft, 0);
l->addAnchor(c, Qt::AnchorRight, l, Qt::AnchorRight);
- l->setAnchorSpacing(c, Qt::AnchorRight, l, Qt::AnchorRight, 0);
QCOMPARE(l->count(), 3);
@@ -700,30 +650,20 @@ void tst_QGraphicsAnchorLayout::fairDistribution()
QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout;
l->setContentsMargins(0, 0, 0, 0);
+ l->setSpacing(0);
l->addAnchor(l, Qt::AnchorTop, a, Qt::AnchorTop);
- l->setAnchorSpacing(l, Qt::AnchorTop, a, Qt::AnchorTop, 0);
l->addAnchor(a, Qt::AnchorBottom, b, Qt::AnchorTop);
- l->setAnchorSpacing(a, Qt::AnchorBottom, b, Qt::AnchorTop, 0);
l->addAnchor(b, Qt::AnchorBottom, c, Qt::AnchorTop);
- l->setAnchorSpacing(b, Qt::AnchorBottom, c, Qt::AnchorTop, 0);
l->addAnchor(c, Qt::AnchorBottom, d, Qt::AnchorTop);
- l->setAnchorSpacing(c, Qt::AnchorBottom, d, Qt::AnchorTop, 0);
l->addAnchor(d, Qt::AnchorBottom, l, Qt::AnchorBottom);
- l->setAnchorSpacing(d, Qt::AnchorBottom, l, Qt::AnchorBottom, 0);
l->addAnchor(l, Qt::AnchorLeft, a, Qt::AnchorLeft);
- l->setAnchorSpacing(l, Qt::AnchorLeft, a, Qt::AnchorLeft, 0);
l->addAnchor(a, Qt::AnchorRight, b, Qt::AnchorLeft);
- l->setAnchorSpacing(a, Qt::AnchorRight, b, Qt::AnchorLeft, 0);
l->addAnchor(b, Qt::AnchorRight, c, Qt::AnchorLeft);
- l->setAnchorSpacing(b, Qt::AnchorRight, c, Qt::AnchorLeft, 0);
l->addAnchor(c, Qt::AnchorRight, l, Qt::AnchorRight);
- l->setAnchorSpacing(c, Qt::AnchorRight, l, Qt::AnchorRight, 0);
l->addAnchor(l, Qt::AnchorLeft, d, Qt::AnchorLeft);
- l->setAnchorSpacing(l, Qt::AnchorLeft, d, Qt::AnchorLeft, 0);
l->addAnchor(d, Qt::AnchorRight, l, Qt::AnchorRight);
- l->setAnchorSpacing(d, Qt::AnchorRight, l, Qt::AnchorRight, 0);
QCOMPARE(l->count(), 4);
@@ -785,31 +725,21 @@ void tst_QGraphicsAnchorLayout::fairDistributionOppositeDirections()
QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout;
l->setContentsMargins(0, 0, 0, 0);
+ l->setSpacing(0);
l->addAnchor(l, Qt::AnchorTop, a, Qt::AnchorTop);
- l->setAnchorSpacing(l, Qt::AnchorTop, a, Qt::AnchorTop, 0);
l->addAnchor(a, Qt::AnchorBottom, b, Qt::AnchorTop);
- l->setAnchorSpacing(a, Qt::AnchorBottom, b, Qt::AnchorTop, 0);
l->addAnchor(b, Qt::AnchorBottom, c, Qt::AnchorTop);
- l->setAnchorSpacing(b, Qt::AnchorBottom, c, Qt::AnchorTop, 0);
l->addAnchor(c, Qt::AnchorBottom, d, Qt::AnchorTop);
- l->setAnchorSpacing(c, Qt::AnchorBottom, d, Qt::AnchorTop, 0);
l->addAnchor(d, Qt::AnchorBottom, e, Qt::AnchorTop);
- l->setAnchorSpacing(d, Qt::AnchorBottom, e, Qt::AnchorTop, 0);
l->addAnchor(e, Qt::AnchorBottom, l, Qt::AnchorBottom);
- l->setAnchorSpacing(e, Qt::AnchorBottom, l, Qt::AnchorBottom, 0);
l->addAnchor(a, Qt::AnchorLeft, l, Qt::AnchorLeft);
- l->setAnchorSpacing(a, Qt::AnchorLeft, l, Qt::AnchorLeft, 0);
l->addAnchor(b, Qt::AnchorLeft, a, Qt::AnchorRight);
- l->setAnchorSpacing(b, Qt::AnchorLeft, a, Qt::AnchorRight, 0);
l->addAnchor(c, Qt::AnchorLeft, b, Qt::AnchorRight);
- l->setAnchorSpacing(c, Qt::AnchorLeft, b, Qt::AnchorRight, 0);
l->addAnchor(d, Qt::AnchorLeft, c, Qt::AnchorRight);
- l->setAnchorSpacing(d, Qt::AnchorLeft, c, Qt::AnchorRight, 0);
l->addAnchor(d, Qt::AnchorRight, l, Qt::AnchorRight);
- l->setAnchorSpacing(d, Qt::AnchorRight, l, Qt::AnchorRight, 0);
- l->addLeftAndRightAnchors(l, e);
+ l->addAnchors(l, e, Qt::Horizontal);
QCOMPARE(l->count(), 5);
@@ -857,32 +787,21 @@ void tst_QGraphicsAnchorLayout::proportionalPreferred()
QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout;
l->setContentsMargins(0, 0, 0, 0);
+ l->setSpacing(0);
l->addAnchor(l, Qt::AnchorTop, a, Qt::AnchorTop);
- l->setAnchorSpacing(l, Qt::AnchorTop, a, Qt::AnchorTop, 0);
l->addAnchor(a, Qt::AnchorBottom, b, Qt::AnchorTop);
- l->setAnchorSpacing(a, Qt::AnchorBottom, b, Qt::AnchorTop, 0);
l->addAnchor(b, Qt::AnchorBottom, c, Qt::AnchorTop);
- l->setAnchorSpacing(b, Qt::AnchorBottom, c, Qt::AnchorTop, 0);
l->addAnchor(c, Qt::AnchorBottom, d, Qt::AnchorTop);
- l->setAnchorSpacing(c, Qt::AnchorBottom, d, Qt::AnchorTop, 0);
l->addAnchor(d, Qt::AnchorBottom, l, Qt::AnchorBottom);
- l->setAnchorSpacing(d, Qt::AnchorBottom, l, Qt::AnchorBottom, 0);
l->addAnchor(l, Qt::AnchorLeft, a, Qt::AnchorLeft);
- l->setAnchorSpacing(l, Qt::AnchorLeft, a, Qt::AnchorLeft, 0);
l->addAnchor(l, Qt::AnchorLeft, b, Qt::AnchorLeft);
- l->setAnchorSpacing(l, Qt::AnchorLeft, b, Qt::AnchorLeft, 0);
l->addAnchor(a, Qt::AnchorRight, c, Qt::AnchorLeft);
- l->setAnchorSpacing(a, Qt::AnchorRight, c, Qt::AnchorLeft, 0);
l->addAnchor(a, Qt::AnchorRight, d, Qt::AnchorLeft);
- l->setAnchorSpacing(a, Qt::AnchorRight, d, Qt::AnchorLeft, 0);
l->addAnchor(b, Qt::AnchorRight, l, Qt::AnchorRight);
- l->setAnchorSpacing(b, Qt::AnchorRight, l, Qt::AnchorRight, 0);
l->addAnchor(c, Qt::AnchorRight, l, Qt::AnchorRight);
- l->setAnchorSpacing(c, Qt::AnchorRight, l, Qt::AnchorRight, 0);
l->addAnchor(d, Qt::AnchorRight, l, Qt::AnchorRight);
- l->setAnchorSpacing(d, Qt::AnchorRight, l, Qt::AnchorRight, 0);
QCOMPARE(l->count(), 4);
@@ -935,62 +854,40 @@ void tst_QGraphicsAnchorLayout::example()
QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout;
l->setContentsMargins(0, 0, 0, 0);
+ l->setSpacing(0);
// vertical
l->addAnchor(a, Qt::AnchorTop, l, Qt::AnchorTop);
- l->setAnchorSpacing(a, Qt::AnchorTop, l, Qt::AnchorTop, 0);
l->addAnchor(b, Qt::AnchorTop, l, Qt::AnchorTop);
- l->setAnchorSpacing(b, Qt::AnchorTop, l, Qt::AnchorTop, 0);
l->addAnchor(c, Qt::AnchorTop, a, Qt::AnchorBottom);
- l->setAnchorSpacing(c, Qt::AnchorTop, a, Qt::AnchorBottom, 0);
l->addAnchor(c, Qt::AnchorTop, b, Qt::AnchorBottom);
- l->setAnchorSpacing(c, Qt::AnchorTop, b, Qt::AnchorBottom, 0);
l->addAnchor(c, Qt::AnchorBottom, d, Qt::AnchorTop);
- l->setAnchorSpacing(c, Qt::AnchorBottom, d, Qt::AnchorTop, 0);
l->addAnchor(c, Qt::AnchorBottom, e, Qt::AnchorTop);
- l->setAnchorSpacing(c, Qt::AnchorBottom, e, Qt::AnchorTop, 0);
l->addAnchor(d, Qt::AnchorBottom, l, Qt::AnchorBottom);
- l->setAnchorSpacing(d, Qt::AnchorBottom, l, Qt::AnchorBottom, 0);
l->addAnchor(e, Qt::AnchorBottom, l, Qt::AnchorBottom);
- l->setAnchorSpacing(e, Qt::AnchorBottom, l, Qt::AnchorBottom, 0);
l->addAnchor(c, Qt::AnchorTop, f, Qt::AnchorTop);
- l->setAnchorSpacing(c, Qt::AnchorTop, f, Qt::AnchorTop, 0);
l->addAnchor(c, Qt::AnchorVerticalCenter, f, Qt::AnchorBottom);
- l->setAnchorSpacing(c, Qt::AnchorVerticalCenter, f, Qt::AnchorBottom, 0);
l->addAnchor(f, Qt::AnchorBottom, g, Qt::AnchorTop);
- l->setAnchorSpacing(f, Qt::AnchorBottom, g, Qt::AnchorTop, 0);
l->addAnchor(c, Qt::AnchorBottom, g, Qt::AnchorBottom);
- l->setAnchorSpacing(c, Qt::AnchorBottom, g, Qt::AnchorBottom, 0);
// horizontal
l->addAnchor(l, Qt::AnchorLeft, a, Qt::AnchorLeft);
- l->setAnchorSpacing(l, Qt::AnchorLeft, a, Qt::AnchorLeft, 0);
l->addAnchor(l, Qt::AnchorLeft, d, Qt::AnchorLeft);
- l->setAnchorSpacing(l, Qt::AnchorLeft, d, Qt::AnchorLeft, 0);
l->addAnchor(a, Qt::AnchorRight, b, Qt::AnchorLeft);
- l->setAnchorSpacing(a, Qt::AnchorRight, b, Qt::AnchorLeft, 0);
l->addAnchor(a, Qt::AnchorRight, c, Qt::AnchorLeft);
- l->setAnchorSpacing(a, Qt::AnchorRight, c, Qt::AnchorLeft, 0);
l->addAnchor(c, Qt::AnchorRight, e, Qt::AnchorLeft);
- l->setAnchorSpacing(c, Qt::AnchorRight, e, Qt::AnchorLeft, 0);
l->addAnchor(b, Qt::AnchorRight, l, Qt::AnchorRight);
- l->setAnchorSpacing(b, Qt::AnchorRight, l, Qt::AnchorRight, 0);
l->addAnchor(e, Qt::AnchorRight, l, Qt::AnchorRight);
- l->setAnchorSpacing(e, Qt::AnchorRight, l, Qt::AnchorRight, 0);
l->addAnchor(d, Qt::AnchorRight, e, Qt::AnchorLeft);
- l->setAnchorSpacing(d, Qt::AnchorRight, e, Qt::AnchorLeft, 0);
l->addAnchor(l, Qt::AnchorLeft, f, Qt::AnchorLeft);
- l->setAnchorSpacing(l, Qt::AnchorLeft, f, Qt::AnchorLeft, 0);
l->addAnchor(l, Qt::AnchorLeft, g, Qt::AnchorLeft);
- l->setAnchorSpacing(l, Qt::AnchorLeft, g, Qt::AnchorLeft, 0);
l->addAnchor(f, Qt::AnchorRight, g, Qt::AnchorRight);
- l->setAnchorSpacing(f, Qt::AnchorRight, g, Qt::AnchorRight, 0);
QCOMPARE(l->count(), 7);
@@ -1039,7 +936,7 @@ void tst_QGraphicsAnchorLayout::setSpacing()
l->addCornerAnchors(b, Qt::TopRightCorner, l, Qt::TopRightCorner);
l->addAnchor(a, Qt::AnchorRight, b, Qt::AnchorLeft);
- l->addLeftAndRightAnchors(l, c);
+ l->addAnchors(l, c, Qt::Horizontal);
l->addAnchor(a, Qt::AnchorBottom, c, Qt::AnchorTop);
l->addAnchor(c, Qt::AnchorBottom, l, Qt::AnchorBottom);
@@ -1146,5 +1043,58 @@ void tst_QGraphicsAnchorLayout::hardComplexS60()
}
+void tst_QGraphicsAnchorLayout::delete_anchor()
+{
+ QGraphicsScene scene;
+ QSizeF minSize(0, 0);
+ QSizeF prefSize(50, 50);
+ QSizeF maxSize(100, 100);
+ QGraphicsWidget *w1 = createItem(minSize, prefSize, maxSize, "w1");
+ QGraphicsWidget *w2 = createItem(minSize, prefSize, maxSize, "w2");
+ QGraphicsWidget *w3 = createItem(minSize, prefSize, maxSize, "w3");
+
+ QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout;
+ l->setSpacing(0);
+ l->setContentsMargins(0, 0, 0, 0);
+ l->addAnchor(l, Qt::AnchorLeft, w1, Qt::AnchorLeft);
+ l->addAnchor(w1, Qt::AnchorRight, w2, Qt::AnchorLeft);
+ l->addAnchor(w2, Qt::AnchorRight, l, Qt::AnchorRight);
+ l->addAnchor(w1, Qt::AnchorRight, w3, Qt::AnchorLeft);
+ l->addAnchor(w3, Qt::AnchorRight, l, Qt::AnchorRight);
+
+ QGraphicsAnchor *anchor = l->anchor(w3, Qt::AnchorRight, l, Qt::AnchorRight);
+ anchor->setSpacing(10);
+
+ QGraphicsWidget *p = new QGraphicsWidget;
+ p->setLayout(l);
+
+ QCOMPARE(l->count(), 3);
+
+ scene.addItem(p);
+ QGraphicsView *view = new QGraphicsView(&scene);
+ QApplication::processEvents();
+ // Should now be simplified
+ QCOMPARE(l->effectiveSizeHint(Qt::PreferredSize).width(), qreal(110));
+ QGraphicsAnchor *anchor1 = l->anchor(w3, Qt::AnchorRight, l, Qt::AnchorRight);
+ QVERIFY(anchor1);
+ QGraphicsAnchor *anchor2 = l->anchor(w3, Qt::AnchorRight, l, Qt::AnchorRight);
+ QVERIFY(anchor2);
+
+ // should be the same object
+ QCOMPARE(anchor1, anchor2);
+
+ // check if removal works
+ delete anchor1;
+
+ QApplication::processEvents();
+
+ // it should also change the preferred size of the layout
+ QCOMPARE(l->effectiveSizeHint(Qt::PreferredSize).width(), qreal(100));
+
+ delete p;
+ delete view;
+
+}
+
QTEST_MAIN(tst_QGraphicsAnchorLayout)
#include "tst_qgraphicsanchorlayout.moc"
diff --git a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp
index b36cf73..d5205cd 100644
--- a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp
+++ b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp
@@ -63,6 +63,8 @@ private slots:
void boundingRect();
void draw();
void opacity();
+ void grayscale();
+ void colorize();
};
void tst_QGraphicsEffect::initTestCase()
@@ -365,6 +367,93 @@ void tst_QGraphicsEffect::opacity()
QCOMPARE(effect->m_opacity, qreal(0.5));
}
+void tst_QGraphicsEffect::grayscale()
+{
+ QGraphicsScene scene(0, 0, 100, 100);
+
+ QGraphicsRectItem *item = scene.addRect(0, 0, 50, 50);
+ item->setPen(Qt::NoPen);
+ item->setBrush(QColor(122, 193, 66)); // Qt light green
+
+ QGraphicsGrayscaleEffect *effect = new QGraphicsGrayscaleEffect;
+ item->setGraphicsEffect(effect);
+
+ QPainter painter;
+ QImage image(100, 100, QImage::Format_ARGB32_Premultiplied);
+
+ image.fill(0);
+ painter.begin(&image);
+ painter.setRenderHint(QPainter::Antialiasing);
+ scene.render(&painter);
+ painter.end();
+
+ QCOMPARE(image.pixel(10, 10), qRgb(148, 148, 148));
+
+ effect->setStrength(0.5);
+
+ image.fill(0);
+ painter.begin(&image);
+ painter.setRenderHint(QPainter::Antialiasing);
+ scene.render(&painter);
+ painter.end();
+
+ QCOMPARE(image.pixel(10, 10), qRgb(135, 171, 107));
+
+ effect->setStrength(0.0);
+
+ image.fill(0);
+ painter.begin(&image);
+ painter.setRenderHint(QPainter::Antialiasing);
+ scene.render(&painter);
+ painter.end();
+
+ QCOMPARE(image.pixel(10, 10), qRgb(122, 193, 66));
+}
+
+void tst_QGraphicsEffect::colorize()
+{
+ QGraphicsScene scene(0, 0, 100, 100);
+
+ QGraphicsRectItem *item = scene.addRect(0, 0, 50, 50);
+ item->setPen(Qt::NoPen);
+ item->setBrush(QColor(122, 193, 66)); // Qt light green
+
+ QGraphicsColorizeEffect *effect = new QGraphicsColorizeEffect;
+ effect->setColor(QColor(102, 153, 51)); // Qt dark green
+ item->setGraphicsEffect(effect);
+
+ QPainter painter;
+ QImage image(100, 100, QImage::Format_ARGB32_Premultiplied);
+
+ image.fill(0);
+ painter.begin(&image);
+ painter.setRenderHint(QPainter::Antialiasing);
+ scene.render(&painter);
+ painter.end();
+
+ QCOMPARE(image.pixel(10, 10), qRgb(191, 212, 169));
+
+ effect->setStrength(0.5);
+
+ image.fill(0);
+ painter.begin(&image);
+ painter.setRenderHint(QPainter::Antialiasing);
+ scene.render(&painter);
+ painter.end();
+
+ QCOMPARE(image.pixel(10, 10), qRgb(156, 203, 117));
+
+ effect->setStrength(0.0);
+
+ image.fill(0);
+ painter.begin(&image);
+ painter.setRenderHint(QPainter::Antialiasing);
+ scene.render(&painter);
+ painter.end();
+
+ QCOMPARE(image.pixel(10, 10), qRgb(122, 193, 66));
+}
+
QTEST_MAIN(tst_QGraphicsEffect)
#include "tst_qgraphicseffect.moc"
diff --git a/tests/auto/qpixmapfilter/tst_qpixmapfilter.cpp b/tests/auto/qpixmapfilter/tst_qpixmapfilter.cpp
index 83bd537..5a9bad7 100644
--- a/tests/auto/qpixmapfilter/tst_qpixmapfilter.cpp
+++ b/tests/auto/qpixmapfilter/tst_qpixmapfilter.cpp
@@ -63,8 +63,10 @@ public slots:
private slots:
void colorizeSetColor();
+ void colorizeSetStrength();
void colorizeProcess();
void colorizeDraw();
+ void colorizeDrawStrength();
void colorizeDrawSubRect();
void colorizeProcessSubRect();
void convolutionBoundingRectFor();
@@ -127,6 +129,16 @@ void tst_QPixmapFilter::colorizeSetColor()
QCOMPARE(filter.color(), QColor(50, 100, 200));
}
+void tst_QPixmapFilter::colorizeSetStrength()
+{
+ QPixmapColorizeFilter filter;
+ QCOMPARE(filter.strength(), qreal(1));
+ filter.setStrength(0.5);
+ QCOMPARE(filter.strength(), qreal(0.5));
+ filter.setStrength(0.0);
+ QCOMPARE(filter.strength(), qreal(0.0));
+}
+
void tst_QPixmapFilter::colorizeProcess()
{
QPixmapColorizeFilter filter;
@@ -180,6 +192,35 @@ void tst_QPixmapFilter::colorizeDraw()
}
}
+void tst_QPixmapFilter::colorizeDrawStrength()
+{
+ QPixmapColorizeFilter filter;
+ filter.setColor(Qt::blue);
+ filter.setStrength(0.3);
+
+ QImage source(256, 128, QImage::Format_ARGB32);
+ source.fill(qRgb(255, 0, 0));
+ QPixmap pixmap = QPixmap::fromImage(source);
+
+ QImage result(pixmap.size(), QImage::Format_ARGB32_Premultiplied);
+ QPainter painter(&result);
+ painter.setCompositionMode(QPainter::CompositionMode_Source);
+ filter.draw(&painter, QPointF(0, 0), pixmap);
+ painter.end();
+
+ QImage resultImg = result;
+ for(int y = 0; y < resultImg.height(); y++)
+ {
+ for(int x = 0; x < resultImg.width(); x++)
+ {
+ QRgb pixel = resultImg.pixel(x,y);
+ QCOMPARE(qRed(pixel), 206);
+ QCOMPARE(qGreen(pixel), 26);
+ QCOMPARE(qBlue(pixel), 75);
+ }
+ }
+}
+
void tst_QPixmapFilter::colorizeDrawSubRect()
{
QPixmapColorizeFilter filter;
diff --git a/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp b/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp
index 75b5190..073afae 100644
--- a/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp
+++ b/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp
@@ -119,6 +119,11 @@ private slots:
void tableModifyWithBlank_data() { generic_data(); }
void tableModifyWithBlank(); // For mail task
+ void removeColumnAndRow_data() { generic_data(); }
+ void removeColumnAndRow(); // task 256032
+
+ void insertBeforeDelete_data() { generic_data(); }
+ void insertBeforeDelete();
private:
void generic_data(const QString& engine=QString());
};
@@ -989,5 +994,61 @@ void tst_QSqlTableModel::tableModifyWithBlank()
QCOMPARE(model.record(0).value(1).toString(), QLatin1String("col1ModelData"));
}
+void tst_QSqlTableModel::removeColumnAndRow()
+{
+ QFETCH(QString, dbName);
+ QSqlDatabase db = QSqlDatabase::database(dbName);
+ CHECK_DATABASE(db);
+
+ QSqlTableModel model(0, db);
+ model.setTable(qTableName("test"));
+ model.setEditStrategy(QSqlTableModel::OnManualSubmit);
+ QVERIFY_SQL(model, select());
+ QCOMPARE(model.rowCount(), 3);
+ QCOMPARE(model.columnCount(), 3);
+
+ QVERIFY(model.removeColumn(0));
+ QVERIFY(model.removeRow(0));
+ QVERIFY(model.submitAll());
+ QCOMPARE(model.rowCount(), 2);
+ QCOMPARE(model.columnCount(), 2);
+
+ // check with another table because the model has been modified
+ // but not the sql table
+ QSqlTableModel model2(0, db);
+ model2.setTable(qTableName("test"));
+ QVERIFY_SQL(model2, select());
+ QCOMPARE(model2.rowCount(), 2);
+ QCOMPARE(model2.columnCount(), 3);
+}
+
+void tst_QSqlTableModel::insertBeforeDelete()
+{
+ QFETCH(QString, dbName);
+ QSqlDatabase db = QSqlDatabase::database(dbName);
+ CHECK_DATABASE(db);
+
+ QSqlQuery q(db);
+ QVERIFY_SQL( q, exec("insert into " + qTableName("test") + " values(9, 'andrew', 9)"));
+ QVERIFY_SQL( q, exec("insert into " + qTableName("test") + " values(10, 'justin', 10)"));
+
+ QSqlTableModel model(0, db);
+ model.setTable(qTableName("test"));
+ model.setEditStrategy(QSqlTableModel::OnManualSubmit);
+ QVERIFY_SQL(model, select());
+
+ qDebug() << model.rowCount();
+
+ QSqlRecord rec = model.record();
+ rec.setValue(0, 4);
+ rec.setValue(1, QString("bill"));
+ rec.setValue(2, 4);
+ QVERIFY_SQL(model, insertRecord(4, rec));
+
+ QVERIFY_SQL(model, removeRow(5));
+ QVERIFY_SQL(model, submitAll());
+ QCOMPARE(model.rowCount(), 5);
+}
+
QTEST_MAIN(tst_QSqlTableModel)
#include "tst_qsqltablemodel.moc"
diff --git a/tests/auto/qsslcertificate/tst_qsslcertificate.cpp b/tests/auto/qsslcertificate/tst_qsslcertificate.cpp
index 9cd9f39..62c64a1 100644
--- a/tests/auto/qsslcertificate/tst_qsslcertificate.cpp
+++ b/tests/auto/qsslcertificate/tst_qsslcertificate.cpp
@@ -115,12 +115,7 @@ private slots:
tst_QSslCertificate::tst_QSslCertificate()
{
-#ifdef Q_WS_MAC
- // applicationDirPath() points to a path inside the app bundle on Mac.
- QDir dir(qApp->applicationDirPath() + QLatin1String("/../../../certificates"));
-#else
QDir dir(SRCDIR + QLatin1String("/certificates"));
-#endif
QFileInfoList fileInfoList = dir.entryInfoList(QDir::Files | QDir::Readable);
QRegExp rxCert(QLatin1String("^.+\\.(pem|der)$"));
QRegExp rxSan(QLatin1String("^(.+\\.(?:pem|der))\\.san$"));
diff --git a/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp
index 491330b..360e433 100644
--- a/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp
+++ b/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp
@@ -841,6 +841,11 @@ void tst_QStyleSheetStyle::hoverColors()
frame.setLayout(layout);
frame.show();
+#ifdef Q_WS_QWS
+//QWS does not implement enter/leave when windows are shown underneath the cursor
+ QCursor::setPos(QPoint(0,0));
+#endif
+
#ifdef Q_WS_X11
qt_x11_wait_for_window_manager(&frame);
#endif
diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp
index 47cd860..86caddb 100644
--- a/tests/auto/qwidget/tst_qwidget.cpp
+++ b/tests/auto/qwidget/tst_qwidget.cpp
@@ -350,7 +350,7 @@ private slots:
void setClearAndResizeMask();
void maskedUpdate();
-#if defined(Q_WS_WIN) || defined(Q_WS_X11)
+#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_QWS)
void syntheticEnterLeave();
#endif
void windowFlags();
@@ -8990,7 +8990,7 @@ void tst_QWidget::maskedUpdate()
QCOMPARE(grandChild.paintedRegion, QRegion(grandChild.rect())); // Full update.
}
-#if defined(Q_WS_X11) || defined(Q_WS_WIN)
+#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_QWS)
void tst_QWidget::syntheticEnterLeave()
{
class MyWidget : public QWidget
@@ -9275,6 +9275,7 @@ void tst_QWidget::rectOutsideCoordinatesLimit_task144779()
#ifdef Q_WS_X11
qt_x11_wait_for_window_manager(&main);
#endif
+ QCursor::setPos(main.pos()); //get the cursor out of the picture
QTest::qWait(100);
QPixmap pixmap = QPixmap::grabWindow(main.winId());