summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@digia.com>2012-10-15 17:06:34 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-10-22 19:36:43 +0200
commitb213d5bfa3a8ed81077cd8eaf229764ff2f1b346 (patch)
treec38b11225116886274631306e6018ffd23cdc2af /tests/auto
parent11566de014ed22051a53f1f0c94697fd18a87500 (diff)
Make QPen default to 1-width non-cosmetic.
Use the Qt4CompatiblePainting render hint when painting with QPainter to treat default constructed QPens as cosmetic still. The NonCosmeticDefaultPen render hint gets documented as obsolete, since it was in any case not respected by the raster nor OpenGL paint engine. Change-Id: I04d910e9700baf7f13a8aac07a3633014bb9283e Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/gui/painting/qpainter/tst_qpainter.cpp1
-rw-r--r--tests/auto/gui/painting/qpathclipper/tst_qpathclipper.cpp4
-rw-r--r--tests/auto/gui/painting/qpen/tst_qpen.cpp4
-rw-r--r--tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp4
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp42
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicspolygonitem/tst_qgraphicspolygonitem.cpp2
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp35
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicssceneindex/tst_qgraphicssceneindex.cpp2
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp48
9 files changed, 109 insertions, 33 deletions
diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
index 24be319173..09180b3de9 100644
--- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
+++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
@@ -1490,6 +1490,7 @@ void tst_QPainter::setWindow()
pixmap.fill(QColor(Qt::white));
QPainter painter(&pixmap);
+ painter.setRenderHint(QPainter::Qt4CompatiblePainting);
painter.setWindow(0, 0, 3, 3);
painter.drawLine(1, 1, 2, 2);
diff --git a/tests/auto/gui/painting/qpathclipper/tst_qpathclipper.cpp b/tests/auto/gui/painting/qpathclipper/tst_qpathclipper.cpp
index 2ccc6c4ad3..4172076f6a 100644
--- a/tests/auto/gui/painting/qpathclipper/tst_qpathclipper.cpp
+++ b/tests/auto/gui/painting/qpathclipper/tst_qpathclipper.cpp
@@ -470,9 +470,9 @@ void tst_QPathClipper::clipTest(int subjectIndex, int clipIndex, QPathClipper::O
p.setRenderHint(QPainter::Antialiasing);
p.scale(scale, scale);
p.translate(-bounds.topLeft());
- p.setPen(Qt::black);
+ p.setPen(QPen(Qt::black, 0));
p.drawPath(subject);
- p.setPen(Qt::red);
+ p.setPen(QPen(Qt::red, 0));
p.drawPath(clip);
p.end();
diff --git a/tests/auto/gui/painting/qpen/tst_qpen.cpp b/tests/auto/gui/painting/qpen/tst_qpen.cpp
index 35a71ba0a9..1ef7a4d0c4 100644
--- a/tests/auto/gui/painting/qpen/tst_qpen.cpp
+++ b/tests/auto/gui/painting/qpen/tst_qpen.cpp
@@ -154,9 +154,9 @@ void tst_QPen::constructor_data()
QTest::addColumn<int>("capStyle");
QTest::addColumn<int>("joinStyle");
- QTest::newRow("solid_black") << QPen() << QBrush(Qt::black) << 0. << (int)Qt::SolidLine
+ QTest::newRow("solid_black") << QPen() << QBrush(Qt::black) << 1. << (int)Qt::SolidLine
<< (int) Qt::SquareCap << (int)Qt::BevelJoin;
- QTest::newRow("solid_red") << QPen(Qt::red) << QBrush(Qt::red) << 0. << (int)Qt::SolidLine
+ QTest::newRow("solid_red") << QPen(Qt::red) << QBrush(Qt::red) << 1. << (int)Qt::SolidLine
<< (int)Qt::SquareCap << (int)Qt::BevelJoin;
QTest::newRow("full") << QPen(QBrush(QLinearGradient(0, 0, 100, 100)), 10,
Qt::SolidLine, Qt::RoundCap, Qt::MiterJoin)
diff --git a/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp b/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp
index 1ddee7714a..a0646591e8 100644
--- a/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp
+++ b/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp
@@ -234,6 +234,7 @@ void tst_QGraphicsEffect::boundingRect()
// Install effect on QGraphicsItem.
QRectF itemRect(0, 0, 100, 100);
QGraphicsRectItem *item = new QGraphicsRectItem;
+ item->setPen(QPen(Qt::black, 0));
item->setRect(itemRect);
item->setGraphicsEffect(effect);
int margin = effect->margin();
@@ -265,16 +266,19 @@ void tst_QGraphicsEffect::boundingRect2()
{
CustomEffect *effect = new CustomEffect;
QGraphicsRectItem *root = new QGraphicsRectItem;
+ root->setPen(QPen(Qt::black, 0));
root->setGraphicsEffect(effect);
QGraphicsRectItem *child = new QGraphicsRectItem;
QRectF childRect(0, 0, 100, 100);
+ child->setPen(QPen(Qt::black, 0));
child->setFlag(QGraphicsItem::ItemClipsChildrenToShape);
child->setRect(childRect);
child->setParentItem(root);
QGraphicsRectItem *grandChild = new QGraphicsRectItem;
QRectF grandChildRect(0, 0, 200, 200);
+ grandChild->setPen(QPen(Qt::black, 0));
grandChild->setRect(grandChildRect);
grandChild->setParentItem(child);
diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
index f78b40bdf0..490d79b270 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -491,6 +491,7 @@ void tst_QGraphicsItem::construction()
switch (i) {
case 0:
item = new QGraphicsEllipseItem;
+ ((QGraphicsEllipseItem *)item)->setPen(QPen(Qt::black, 0));
QCOMPARE(int(item->type()), int(QGraphicsEllipseItem::Type));
QCOMPARE(qgraphicsitem_cast<QGraphicsEllipseItem *>(item), (QGraphicsEllipseItem *)item);
QCOMPARE(qgraphicsitem_cast<QGraphicsRectItem *>(item), (QGraphicsRectItem *)0);
@@ -498,6 +499,7 @@ void tst_QGraphicsItem::construction()
break;
case 1:
item = new QGraphicsLineItem;
+ ((QGraphicsLineItem *)item)->setPen(QPen(Qt::black, 0));
QCOMPARE(int(item->type()), int(QGraphicsLineItem::Type));
QCOMPARE(qgraphicsitem_cast<QGraphicsLineItem *>(item), (QGraphicsLineItem *)item);
QCOMPARE(qgraphicsitem_cast<QGraphicsRectItem *>(item), (QGraphicsRectItem *)0);
@@ -505,6 +507,7 @@ void tst_QGraphicsItem::construction()
break;
case 2:
item = new QGraphicsPathItem;
+ ((QGraphicsPathItem *)item)->setPen(QPen(Qt::black, 0));
QCOMPARE(int(item->type()), int(QGraphicsPathItem::Type));
QCOMPARE(qgraphicsitem_cast<QGraphicsPathItem *>(item), (QGraphicsPathItem *)item);
QCOMPARE(qgraphicsitem_cast<QGraphicsRectItem *>(item), (QGraphicsRectItem *)0);
@@ -519,6 +522,7 @@ void tst_QGraphicsItem::construction()
break;
case 4:
item = new QGraphicsPolygonItem;
+ ((QGraphicsPolygonItem *)item)->setPen(QPen(Qt::black, 0));
QCOMPARE(int(item->type()), int(QGraphicsPolygonItem::Type));
QCOMPARE(qgraphicsitem_cast<QGraphicsPolygonItem *>(item), (QGraphicsPolygonItem *)item);
QCOMPARE(qgraphicsitem_cast<QGraphicsRectItem *>(item), (QGraphicsRectItem *)0);
@@ -526,6 +530,7 @@ void tst_QGraphicsItem::construction()
break;
case 5:
item = new QGraphicsRectItem;
+ ((QGraphicsRectItem *)item)->setPen(QPen(Qt::black, 0));
QCOMPARE(int(item->type()), int(QGraphicsRectItem::Type));
QCOMPARE(qgraphicsitem_cast<QGraphicsRectItem *>(item), (QGraphicsRectItem *)item);
QCOMPARE(qgraphicsitem_cast<QGraphicsLineItem *>(item), (QGraphicsLineItem *)0);
@@ -579,7 +584,9 @@ public:
BoundingRectItem(QGraphicsItem *parent = 0)
: QGraphicsRectItem(0, 0, parent ? 200 : 100, parent ? 200 : 100,
parent)
- {}
+ {
+ setPen(QPen(Qt::black, 0));
+ }
QRectF boundingRect() const
{
@@ -2204,6 +2211,7 @@ void tst_QGraphicsItem::setMatrix()
QSignalSpy spy(&scene, SIGNAL(changed(QList<QRectF>)));
QRectF unrotatedRect(-12, -34, 56, 78);
QGraphicsRectItem item(unrotatedRect, 0);
+ item.setPen(QPen(Qt::black, 0));
scene.addItem(&item);
scene.update(scene.sceneRect());
QApplication::instance()->processEvents();
@@ -2277,6 +2285,7 @@ void tst_QGraphicsItem::zValue()
void tst_QGraphicsItem::shape()
{
QGraphicsLineItem line(QLineF(-10, -10, 20, 20));
+ line.setPen(QPen(Qt::black, 0));
// We unfortunately need this hack as QPainterPathStroker will set a width of 1.0
// if we pass a value of 0.0 to QPainterPathStroker::setWidth()
@@ -2317,6 +2326,7 @@ void tst_QGraphicsItem::shape()
QCOMPARE(line.shape(), p);
QGraphicsRectItem rect(QRectF(-10, -10, 20, 20));
+ rect.setPen(QPen(Qt::black, 0));
QPainterPathStroker ps1;
ps1.setWidth(penWidthZero);
path = QPainterPath();
@@ -2326,6 +2336,7 @@ void tst_QGraphicsItem::shape()
QCOMPARE(rect.shape(), p);
QGraphicsEllipseItem ellipse(QRectF(-10, -10, 20, 20));
+ ellipse.setPen(QPen(Qt::black, 0));
QPainterPathStroker ps2;
ps2.setWidth(ellipse.pen().widthF() <= 0.0 ? penWidthZero : ellipse.pen().widthF());
path = QPainterPath();
@@ -2339,6 +2350,7 @@ void tst_QGraphicsItem::shape()
p = ps3.createStroke(path);
p.addPath(path);
QGraphicsPathItem pathItem(path);
+ pathItem.setPen(QPen(Qt::black, 0));
QCOMPARE(pathItem.shape(), p);
QRegion region(QRect(0, 0, 300, 200));
@@ -2377,6 +2389,7 @@ void tst_QGraphicsItem::shape()
QPolygonF poly;
poly << QPointF(0, 0) << QPointF(10, 0) << QPointF(0, 10);
QGraphicsPolygonItem polygon(poly);
+ polygon.setPen(QPen(Qt::black, 0));
path = QPainterPath();
path.addPolygon(poly);
@@ -3393,6 +3406,12 @@ void tst_QGraphicsItem::childrenBoundingRectTransformed()
rect4->setParentItem(rect3);
rect5->setParentItem(rect4);
+ rect->setPen(QPen(Qt::black, 0));
+ rect2->setPen(QPen(Qt::black, 0));
+ rect3->setPen(QPen(Qt::black, 0));
+ rect4->setPen(QPen(Qt::black, 0));
+ rect5->setPen(QPen(Qt::black, 0));
+
rect2->setTransform(QTransform().translate(50, 50).rotate(45));
rect2->setPos(25, 25);
rect3->setTransform(QTransform().translate(50, 50).rotate(45));
@@ -3425,6 +3444,9 @@ void tst_QGraphicsItem::childrenBoundingRect2()
QGraphicsLineItem l2(100, 0, 100, 100, &box);
QGraphicsLineItem l3(0, 0, 0, 100, &box);
// Make sure lines (zero with/height) are included in the childrenBoundingRect.
+ l1.setPen(QPen(Qt::black, 0));
+ l2.setPen(QPen(Qt::black, 0));
+ l3.setPen(QPen(Qt::black, 0));
QCOMPARE(box.childrenBoundingRect(), QRectF(0, 0, 100, 100));
}
@@ -3442,6 +3464,12 @@ void tst_QGraphicsItem::childrenBoundingRect3()
rect4->setParentItem(rect3);
rect5->setParentItem(rect4);
+ rect->setPen(QPen(Qt::black, 0));
+ rect2->setPen(QPen(Qt::black, 0));
+ rect3->setPen(QPen(Qt::black, 0));
+ rect4->setPen(QPen(Qt::black, 0));
+ rect5->setPen(QPen(Qt::black, 0));
+
rect2->setTransform(QTransform().translate(50, 50).rotate(45));
rect2->setPos(25, 25);
rect3->setTransform(QTransform().translate(50, 50).rotate(45));
@@ -3495,6 +3523,9 @@ void tst_QGraphicsItem::childrenBoundingRect5()
QGraphicsRectItem *child = scene.addRect(QRectF(0, 0, 100, 100));
child->setParentItem(parent);
+ parent->setPen(QPen(Qt::black, 0));
+ child->setPen(QPen(Qt::black, 0));
+
QGraphicsView view(&scene);
view.show();
@@ -4382,6 +4413,7 @@ void tst_QGraphicsItem::defaultItemTest_QGraphicsTextItem()
void tst_QGraphicsItem::defaultItemTest_QGraphicsEllipseItem()
{
QGraphicsEllipseItem item;
+ item.setPen(QPen(Qt::black, 0));
QVERIFY(item.rect().isNull());
QVERIFY(item.boundingRect().isNull());
QVERIFY(item.shape().isEmpty());
@@ -6517,6 +6549,7 @@ void tst_QGraphicsItem::boundingRegion()
QFETCH(QRegion, expectedRegion);
QGraphicsLineItem item(line);
+ item.setPen(QPen(Qt::black, 0));
QCOMPARE(item.boundingRegionGranularity(), qreal(0.0));
item.setBoundingRegionGranularity(granularity);
QCOMPARE(item.boundingRegionGranularity(), granularity);
@@ -6980,6 +7013,7 @@ public:
TransformDebugItem()
: QGraphicsRectItem(QRectF(-10, -10, 20, 20))
{
+ setPen(QPen(Qt::black, 0));
setBrush(QColor(qrand() % 256, qrand() % 256, qrand() % 256));
}
@@ -7047,7 +7081,9 @@ void tst_QGraphicsItem::sceneTransformCache()
// parent is transformed.
QGraphicsScene scene;
QGraphicsRectItem *rect = scene.addRect(0, 0, 100, 100);
+ rect->setPen(QPen(Qt::black, 0));
QGraphicsRectItem *rect2 = scene.addRect(0, 0, 100, 100);
+ rect2->setPen(QPen(Qt::black, 0));
rect2->setParentItem(rect);
rect2->rotate(90);
rect->translate(0, 50);
@@ -7071,9 +7107,11 @@ void tst_QGraphicsItem::sceneTransformCache()
QGraphicsRectItem *rect3 = scene.addRect(0, 0, 100, 100);
QGraphicsRectItem *rect4 = scene.addRect(0, 0, 100, 100);
rect3->setPos(QPointF(10,10));
+ rect3->setPen(QPen(Qt::black, 0));
rect4->setParentItem(rect3);
rect4->setPos(QPointF(10,10));
+ rect4->setPen(QPen(Qt::black, 0));
QCOMPARE(rect4->mapToScene(rect4->boundingRect().topLeft()), QPointF(20,20));
@@ -7084,9 +7122,11 @@ void tst_QGraphicsItem::sceneTransformCache()
QGraphicsRectItem *rect5 = scene.addRect(0, 0, 100, 100);
QGraphicsRectItem *rect6 = scene.addRect(0, 0, 100, 100);
rect5->setPos(QPointF(20,20));
+ rect5->setPen(QPen(Qt::black, 0));
rect6->setParentItem(rect5);
rect6->setPos(QPointF(10,10));
+ rect6->setPen(QPen(Qt::black, 0));
//test if rect6 transform is ok
QCOMPARE(rect6->mapToScene(rect6->boundingRect().topLeft()), QPointF(30,30));
diff --git a/tests/auto/widgets/graphicsview/qgraphicspolygonitem/tst_qgraphicspolygonitem.cpp b/tests/auto/widgets/graphicsview/qgraphicspolygonitem/tst_qgraphicspolygonitem.cpp
index 79a3c61462..bc091a08be 100644
--- a/tests/auto/widgets/graphicsview/qgraphicspolygonitem/tst_qgraphicspolygonitem.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicspolygonitem/tst_qgraphicspolygonitem.cpp
@@ -42,6 +42,7 @@
#include <QtTest/QtTest>
#include <qgraphicsitem.h>
+#include <qpen.h>
Q_DECLARE_METATYPE(QPolygonF)
@@ -170,6 +171,7 @@ void tst_QGraphicsPolygonItem::boundingRect()
QFETCH(QRectF, boundingRect);
SubQGraphicsPolygonItem item(polygon);
+ item.setPen(QPen(Qt::black, 0));
QCOMPARE(item.boundingRect(), boundingRect);
}
diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
index 90d21d6d95..a4aa2a6e41 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
@@ -322,7 +322,8 @@ void tst_QGraphicsScene::sceneRect()
QCOMPARE(scene.sceneRect(), QRectF());
QCOMPARE(sceneRectChanged.count(), 0);
- QGraphicsItem *item = scene.addRect(QRectF(0, 0, 10, 10));
+ QGraphicsRectItem *item = scene.addRect(QRectF(0, 0, 10, 10));
+ item->setPen(QPen(Qt::black, 0));
item->setPos(-5, -5);
QCOMPARE(sceneRectChanged.count(), 0);
@@ -458,7 +459,9 @@ void tst_QGraphicsScene::items()
{
QGraphicsScene scene;
QGraphicsLineItem *l1 = scene.addLine(-5, 0, 5, 0);
+ l1->setPen(QPen(Qt::black, 0));
QGraphicsLineItem *l2 = scene.addLine(0, -5, 0, 5);
+ l2->setPen(QPen(Qt::black, 0));
QVERIFY(!l1->sceneBoundingRect().intersects(l2->sceneBoundingRect()));
QVERIFY(!l2->sceneBoundingRect().intersects(l1->sceneBoundingRect()));
QList<QGraphicsItem *> items;
@@ -533,7 +536,9 @@ void tst_QGraphicsScene::itemsBoundingRect()
foreach (QRectF rect, rects) {
QPainterPath path;
path.addRect(rect);
- scene.addPath(path)->setMatrix(matrix);
+ QGraphicsPathItem *item = scene.addPath(path);
+ item->setPen(QPen(Qt::black, 0));
+ item->setMatrix(matrix);
}
QCOMPARE(scene.itemsBoundingRect(), boundingRect);
@@ -597,7 +602,8 @@ void tst_QGraphicsScene::items_QPointF()
QPainterPath path;
path.addRect(0, 0, rect.width(), rect.height());
- QGraphicsItem *item = scene.addPath(path);
+ QGraphicsPathItem *item = scene.addPath(path);
+ item->setPen(QPen(Qt::black, 0));
item->setZValue(n++);
item->setPos(rect.topLeft());
addedItems << item;
@@ -1170,6 +1176,9 @@ void tst_QGraphicsScene::addPath()
QCOMPARE(path->pen(), QPen(Qt::red));
QCOMPARE(path->path(), p);
QCOMPARE(path->brush(), QBrush(Qt::blue));
+
+ path->setPen(QPen(Qt::red, 0));
+
QCOMPARE(scene.itemAt(0, 0), (QGraphicsItem *)path);
QCOMPARE(scene.itemAt(-9.9, 0), (QGraphicsItem *)path);
QCOMPARE(scene.itemAt(9.9, 0), (QGraphicsItem *)path);
@@ -1222,6 +1231,9 @@ void tst_QGraphicsScene::addRect()
QCOMPARE(rect->pen(), QPen(Qt::red));
QCOMPARE(rect->brush(), QBrush(Qt::blue));
QCOMPARE(rect->rect(), QRectF(-10, -10, 20, 20));
+
+ rect->setPen(QPen(Qt::red, 0));
+
QCOMPARE(scene.itemAt(0, 0), (QGraphicsItem *)rect);
QCOMPARE(scene.itemAt(-10, -10), (QGraphicsItem *)rect);
QCOMPARE(scene.itemAt(-9.9, 0), (QGraphicsItem *)rect);
@@ -1397,7 +1409,7 @@ void tst_QGraphicsScene::clear()
QGraphicsScene scene;
scene.clear();
QVERIFY(scene.items().isEmpty());
- scene.addRect(0, 0, 100, 100);
+ scene.addRect(0, 0, 100, 100)->setPen(QPen(Qt::black, 0));
QCOMPARE(scene.sceneRect(), QRectF(0, 0, 100, 100));
scene.clear();
QVERIFY(scene.items().isEmpty());
@@ -2610,8 +2622,8 @@ void tst_QGraphicsScene::render()
QGraphicsView view;
QGraphicsScene scene(&view);
- scene.addEllipse(QRectF(-10, -10, 20, 20), QPen(Qt::black), QBrush(Qt::white));
- scene.addEllipse(QRectF(-2, -7, 4, 4), QPen(Qt::black), QBrush(Qt::yellow))->setZValue(1);
+ scene.addEllipse(QRectF(-10, -10, 20, 20), QPen(Qt::black, 0), QBrush(Qt::white));
+ scene.addEllipse(QRectF(-2, -7, 4, 4), QPen(Qt::black, 0), QBrush(Qt::yellow))->setZValue(1);
QGraphicsPixmapItem *item = scene.addPixmap(pix);
item->setZValue(2);
item->setOffset(QPointF(3, 3));
@@ -2808,6 +2820,7 @@ void tst_QGraphicsScene::update()
QGraphicsScene scene;
QGraphicsRectItem *rect = new QGraphicsRectItem(0, 0, 100, 100);
+ rect->setPen(QPen(Qt::black, 0));
scene.addItem(rect);
qApp->processEvents();
rect->setPos(-100, -100);
@@ -3484,6 +3497,7 @@ void tst_QGraphicsScene::task176178_itemIndexMethodBreaksSceneRect()
QGraphicsScene scene;
scene.setItemIndexMethod(QGraphicsScene::NoIndex);
QGraphicsRectItem *rect = new QGraphicsRectItem;
+ rect->setPen(QPen(Qt::black, 0));
rect->setRect(0,0,100,100);
scene.addItem(rect);
QCOMPARE(scene.sceneRect(), rect->rect());
@@ -3513,11 +3527,11 @@ void tst_QGraphicsScene::task250680_childClip()
{
QGraphicsRectItem *clipper = new QGraphicsRectItem;
clipper->setFlag(QGraphicsItem::ItemClipsChildrenToShape);
- clipper->setPen(QPen(Qt::green));
+ clipper->setPen(QPen(Qt::green, 0));
clipper->setRect(200, 200, 640, 480);
QGraphicsRectItem *rect = new QGraphicsRectItem(clipper);
- rect->setPen(QPen(Qt::red));
+ rect->setPen(QPen(Qt::red, 0));
rect->setBrush(QBrush(QColor(255, 0, 0, 75)));
rect->setPos(320, 240);
rect->setRect(-25, -25, 50, 50);
@@ -3662,6 +3676,7 @@ void tst_QGraphicsScene::changedSignal()
view = new QGraphicsView(&scene);
QGraphicsRectItem *rect = new QGraphicsRectItem(0, 0, 10, 10);
+ rect->setPen(QPen(Qt::black, 0));
scene.addItem(rect);
QCOMPARE(cl.changes.size(), 0);
@@ -4246,13 +4261,13 @@ void tst_QGraphicsScene::siblingIndexAlwaysValid()
// first add the blue rect
QGraphicsRectItem* const item1 = new QGraphicsRectItem(QRect( 10, 10, 10, 10 ));
- item1->setPen(QColor(Qt::blue));
+ item1->setPen(QPen(Qt::blue, 0));
item1->setBrush(Qt::blue);
scene2.addItem(item1);
// then add the red rect
QGraphicsRectItem* const item2 = new QGraphicsRectItem(5, 5, 10, 10);
- item2->setPen(QColor(Qt::red));
+ item2->setPen(QPen(Qt::red, 0));
item2->setBrush(Qt::red);
scene2.addItem(item2);
diff --git a/tests/auto/widgets/graphicsview/qgraphicssceneindex/tst_qgraphicssceneindex.cpp b/tests/auto/widgets/graphicsview/qgraphicssceneindex/tst_qgraphicssceneindex.cpp
index 70ebd3c8a7..593fa4e2ef 100644
--- a/tests/auto/widgets/graphicsview/qgraphicssceneindex/tst_qgraphicssceneindex.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicssceneindex/tst_qgraphicssceneindex.cpp
@@ -132,7 +132,7 @@ void tst_QGraphicsSceneIndex::overlappedItems()
for (int i = 0; i < 10; ++i)
for (int j = 0; j < 10; ++j)
- scene.addRect(i*50, j*50, 200, 200);
+ scene.addRect(i*50, j*50, 200, 200)->setPen(QPen(Qt::black, 0));
QCOMPARE(scene.items(QPointF(5, 5)).count(), 1);
QCOMPARE(scene.items(QPointF(55, 55)).count(), 4);
diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
index 474ac47ea1..d2b7001e93 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
@@ -542,6 +542,7 @@ void tst_QGraphicsView::sceneRect()
QCOMPARE(view.sceneRect(), QRectF());
QGraphicsScene scene;
QGraphicsRectItem *item = scene.addRect(QRectF(-100, -100, 100, 100));
+ item->setPen(QPen(Qt::black, 0));
view.setScene(&scene);
@@ -1510,6 +1511,7 @@ void tst_QGraphicsView::itemsInRect_cosmeticAdjust()
QGraphicsScene scene(-100, -100, 200, 200);
CountPaintItem *rect = new CountPaintItem(QRectF(-50, -50, 100, 100));
+ rect->setPen(QPen(Qt::black, 0));
scene.addItem(rect);
QGraphicsView view(&scene);
@@ -2603,8 +2605,13 @@ void tst_QGraphicsView::optimizationFlags_dontSavePainterState2()
MyScene scene;
// Add transformed dummy items to make sure the painter's worldTransform() is changed in drawItems.
- scene.addRect(0, 0, 20, 20)->setTransform(QTransform::fromScale(2, 2));
- scene.addRect(50, 50, 20, 20)->setTransform(QTransform::fromTranslate(200, 200));
+ QGraphicsRectItem *rectA = scene.addRect(0, 0, 20, 20);
+ QGraphicsRectItem *rectB = scene.addRect(50, 50, 20, 20);
+
+ rectA->setTransform(QTransform::fromScale(2, 2));
+ rectA->setPen(QPen(Qt::black, 0));
+ rectB->setTransform(QTransform::fromTranslate(200, 200));
+ rectB->setPen(QPen(Qt::black, 0));
foreach (QGraphicsItem *item, scene.items())
item->setOpacity(0.6);
@@ -3367,10 +3374,11 @@ void tst_QGraphicsView::moveItemWhileScrolling()
setScene(new QGraphicsScene(0, 0, 1000, 1000));
rect = scene()->addRect(0, 0, 10, 10);
rect->setPos(50, 50);
+ rect->setPen(QPen(Qt::black, 0));
painted = false;
}
QRegion lastPaintedRegion;
- QGraphicsItem *rect;
+ QGraphicsRectItem *rect;
bool painted;
void waitForPaintEvent()
{
@@ -4331,25 +4339,31 @@ void tst_QGraphicsView::task255529_transformationAnchorMouseAndViewportMargins()
view.show();
qApp->setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
- QPoint mouseViewPos(20, 20);
- sendMouseMove(view.viewport(), mouseViewPos);
+ // This is highly unstable (observed to pass on Windows and some Linux configurations).
+#ifndef Q_OS_MAC
+ for (int i = 0; i < 4; ++i) {
+ QPoint mouseViewPos(20, 20);
+ sendMouseMove(view.viewport(), mouseViewPos);
- QPointF mouseScenePos = view.mapToScene(mouseViewPos);
- view.setTransform(QTransform().scale(5, 5).rotate(5, Qt::ZAxis), true);
+ QPointF mouseScenePos = view.mapToScene(mouseViewPos);
+ view.setTransform(QTransform().scale(5, 5).rotate(5, Qt::ZAxis), true);
- QPointF newMouseScenePos = view.mapToScene(mouseViewPos);
+ qreal slack = 1;
- qreal slack = 1;
+ QPointF newMouseScenePos = view.mapToScene(mouseViewPos);
- const qreal dx = qAbs(newMouseScenePos.x() - mouseScenePos.x());
- const qreal dy = qAbs(newMouseScenePos.y() - mouseScenePos.y());
- const QByteArray message = QString::fromLatin1("QTBUG-22455, distance: dx=%1, dy=%2 slack=%3 (%4).").
- arg(dx).arg(dy).arg(slack).arg(qApp->style()->metaObject()->className()).toLocal8Bit();
- // This is highly unstable (observed to pass on Windows and some Linux configurations).
-#ifdef Q_OS_MAC
- QEXPECT_FAIL("", message.constData(), Abort);
+ const qreal dx = qAbs(newMouseScenePos.x() - mouseScenePos.x());
+ const qreal dy = qAbs(newMouseScenePos.y() - mouseScenePos.y());
+ const QByteArray message = QString::fromLatin1("QTBUG-22455, distance: dx=%1, dy=%2 slack=%3 (%4).").
+ arg(dx).arg(dy).arg(slack).arg(qApp->style()->metaObject()->className()).toLocal8Bit();
+ if (i == 9 || (dx < slack && dy < slack)) {
+ QVERIFY2(dx < slack && dy < slack, message.constData());
+ break;
+ }
+
+ QTest::qWait(100);
+ }
#endif
- QVERIFY2(dx < slack && dy < slack, message.constData());
}
void tst_QGraphicsView::task259503_scrollingArtifacts()