summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp54
-rw-r--r--tests/auto/qimage/tst_qimage.cpp4
-rw-r--r--tests/auto/qpainter/tst_qpainter.cpp16
3 files changed, 66 insertions, 8 deletions
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index fe68c8e..31a6845 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -442,6 +442,7 @@ private slots:
void updateMicroFocus();
void textItem_shortcuts();
void scroll();
+ void stopClickFocusPropagation();
// task specific tests below me
void task141694_textItemEnsureVisible();
@@ -10268,6 +10269,59 @@ void tst_QGraphicsItem::scroll()
QCOMPARE(item2->lastExposedRect, expectedItem2Expose);
}
+void tst_QGraphicsItem::stopClickFocusPropagation()
+{
+ class MyItem : public QGraphicsRectItem
+ {
+ public:
+ MyItem() : QGraphicsRectItem(0, 0, 100, 100) {}
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
+ {
+ painter->fillRect(boundingRect(), hasFocus() ? QBrush(Qt::red) : brush());
+ }
+ };
+
+ QGraphicsScene scene(-50, -50, 400, 400);
+ scene.setStickyFocus(true);
+
+ QGraphicsRectItem *noFocusOnTop = new MyItem;
+ noFocusOnTop->setBrush(Qt::yellow);
+ noFocusOnTop->setFlag(QGraphicsItem::ItemStopsClickFocusPropagation);
+
+ QGraphicsRectItem *focusableUnder = new MyItem;
+ focusableUnder->setBrush(Qt::blue);
+ focusableUnder->setFlag(QGraphicsItem::ItemIsFocusable);
+ focusableUnder->setPos(50, 50);
+
+ QGraphicsRectItem *itemWithFocus = new MyItem;
+ itemWithFocus->setBrush(Qt::black);
+ itemWithFocus->setFlag(QGraphicsItem::ItemIsFocusable);
+ itemWithFocus->setPos(250, 10);
+
+ scene.addItem(noFocusOnTop);
+ scene.addItem(focusableUnder);
+ scene.addItem(itemWithFocus);
+ focusableUnder->stackBefore(noFocusOnTop);
+ itemWithFocus->setFocus();
+
+ QGraphicsView view(&scene);
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+
+ QApplication::setActiveWindow(&view);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
+ QVERIFY(itemWithFocus->hasFocus());
+
+ QPointF mousePressPoint = noFocusOnTop->mapToScene(QPointF());
+ mousePressPoint.rx() += 60;
+ mousePressPoint.ry() += 60;
+ const QList<QGraphicsItem *> itemsAtMousePressPosition = scene.items(mousePressPoint);
+ QVERIFY(itemsAtMousePressPosition.contains(focusableUnder));
+
+ sendMousePress(&scene, mousePressPoint);
+ QVERIFY(itemWithFocus->hasFocus());
+}
+
void tst_QGraphicsItem::QTBUG_5418_textItemSetDefaultColor()
{
struct Item : public QGraphicsTextItem
diff --git a/tests/auto/qimage/tst_qimage.cpp b/tests/auto/qimage/tst_qimage.cpp
index 16deb03..5052114 100644
--- a/tests/auto/qimage/tst_qimage.cpp
+++ b/tests/auto/qimage/tst_qimage.cpp
@@ -945,11 +945,11 @@ void tst_QImage::rotate()
const int n = original.colorTable().size();
for (int x = 0; x < w; ++x) {
original.setPixel(x, 0, x % n);
- original.setPixel(x,h - 1, n - (x % n));
+ original.setPixel(x, h - 1, n - (x % n) - 1);
}
for (int y = 0; y < h; ++y) {
original.setPixel(0, y, y % n);
- original.setPixel(w - 1, y, n - (y % n));
+ original.setPixel(w - 1, y, n - (y % n) - 1);
}
}
diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp
index 701dc2e..27ee6e7 100644
--- a/tests/auto/qpainter/tst_qpainter.cpp
+++ b/tests/auto/qpainter/tst_qpainter.cpp
@@ -2648,12 +2648,16 @@ void tst_QPainter::setOpacity()
p.drawImage(imageRect, src, imageRect);
p.end();
- QImage expected(imageSize, destFormat);
- p.begin(&expected);
- p.fillRect(imageRect, QColor(127, 127, 127));
- p.end();
-
- QCOMPARE(dest, expected);
+ QImage actual = dest.convertToFormat(QImage::Format_RGB32);
+
+ for (int y = 0; y < actual.height(); ++y) {
+ QRgb *p = (QRgb *)actual.scanLine(y);
+ for (int x = 0; x < actual.width(); ++x) {
+ QVERIFY(qAbs(qRed(p[x]) - 127) <= 0xf);
+ QVERIFY(qAbs(qGreen(p[x]) - 127) <= 0xf);
+ QVERIFY(qAbs(qBlue(p[x]) - 127) <= 0xf);
+ }
+ }
}
void tst_QPainter::drawhelper_blend_untransformed_data()