summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-09-30 14:09:04 +0200
committerMarc Mutz <marc.mutz@qt.io>2022-11-03 14:59:24 +0100
commit1c6bf3e09ea9722717caedcfcceaaf3d607615cf (patch)
treecad1814e104667a84ba7b5f403bbda015413e058 /tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
parent43cda7807b98552e9292ac09a1f6612d432a8b13 (diff)
Port from container::count() and length() to size() - V5
This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to handle typedefs and accesses through pointers, too: const std::string o = "object"; auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); }; auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) { auto exprOfDeclaredType = [&](auto decl) { return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o); }; return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes)))); }; auto renameMethod = [&] (ArrayRef<StringRef> classes, StringRef from, StringRef to) { return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)), callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))), changeTo(cat(access(o, cat(to)), "()")), cat("use '", to, "' instead of '", from, "'")); }; renameMethod(<classes>, "count", "size"); renameMethod(<classes>, "length", "size"); except that the on() matcher has been replaced by one that doesn't ignoreParens(). a.k.a qt-port-to-std-compatible-api V5 with config Scope: 'Container'. Added two NOLINTNEXTLINEs in tst_qbitarray and tst_qcontiguouscache, to avoid porting calls that explicitly test count(). Change-Id: Icfb8808c2ff4a30187e9935a51cad26987451c22 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp')
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp58
1 files changed, 29 insertions, 29 deletions
diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
index 3cb0925e59..4562ac3a84 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
@@ -945,7 +945,7 @@ void tst_QGraphicsProxyWidget::hoverEnterLeaveEvent()
proxy->setPos(50, 0);
QSignalSpy sceneChangedSpy(&scene, &QGraphicsScene::changed);
scene.addItem(proxy);
- QTRY_VERIFY(sceneChangedSpy.count() > 0);
+ QTRY_VERIFY(sceneChangedSpy.size() > 0);
// outside graphics item
QTest::mouseMove(&view, QPoint(10, 10));
@@ -1043,9 +1043,9 @@ void tst_QGraphicsProxyWidget::keyReleaseEvent()
proxy->setFocus();
QTest::keyPress(view.viewport(), Qt::Key_Space);
- QTRY_COMPARE(spy.count(), 0);
+ QTRY_COMPARE(spy.size(), 0);
QTest::keyRelease(view.viewport(), Qt::Key_Space);
- QTRY_COMPARE(spy.count(), hasWidget ? 1 : 0);
+ QTRY_COMPARE(spy.size(), hasWidget ? 1 : 0);
}
// protected void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event)
@@ -1073,7 +1073,7 @@ void tst_QGraphicsProxyWidget::mouseDoubleClickEvent()
QVERIFY(QTest::qWaitForWindowActive(&view));
QCOMPARE(QApplication::activeWindow(), (QWidget*)&view);
// wait for scene to be updated before doing any coordinate mappings on it
- QTRY_VERIFY(sceneChangedSpy.count() > 0);
+ QTRY_VERIFY(sceneChangedSpy.size() > 0);
QPoint pointInLineEdit = view.mapFromScene(proxy->mapToScene(15, proxy->boundingRect().center().y()));
QTest::mousePress(view.viewport(), Qt::LeftButton, {}, pointInLineEdit);
@@ -1114,13 +1114,13 @@ void tst_QGraphicsProxyWidget::mousePressReleaseEvent()
proxy->setFocus();
// wait for scene to be updated before doing any coordinate mappings on it
- QTRY_VERIFY(sceneChangedSpy.count() > 0);
+ QTRY_VERIFY(sceneChangedSpy.size() > 0);
QPoint buttonCenter = view.mapFromScene(proxy->mapToScene(proxy->boundingRect().center()));
QTest::mousePress(view.viewport(), Qt::LeftButton, {}, buttonCenter);
- QTRY_COMPARE(spy.count(), 0);
+ QTRY_COMPARE(spy.size(), 0);
QTest::mouseRelease(view.viewport(), Qt::LeftButton, {}, buttonCenter);
- QTRY_COMPARE(spy.count(), hasWidget ? 1 : 0);
+ QTRY_COMPARE(spy.size(), hasWidget ? 1 : 0);
}
void tst_QGraphicsProxyWidget::resizeEvent_data()
@@ -1171,7 +1171,7 @@ void tst_QGraphicsProxyWidget::paintEvent()
QSignalSpy sceneChangedSpy(&scene, &QGraphicsScene::changed);
scene.addItem(&proxy);
- QTRY_VERIFY(sceneChangedSpy.count() > 0); // make sure the scene is ready
+ QTRY_VERIFY(sceneChangedSpy.size() > 0); // make sure the scene is ready
proxy.paintCount = 0;
w->update();
@@ -2410,7 +2410,7 @@ void tst_QGraphicsProxyWidget::changingCursor_basic()
proxy->setWidget(widget);
QSignalSpy sceneChangedSpy(&scene, &QGraphicsScene::changed);
scene.addItem(proxy);
- QTRY_VERIFY(sceneChangedSpy.count() > 0); // make sure the scene is ready
+ QTRY_VERIFY(sceneChangedSpy.size() > 0); // make sure the scene is ready
// in
QTest::mouseMove(view.viewport(), view.mapFromScene(proxy->mapToScene(proxy->boundingRect().center())));
@@ -2628,7 +2628,7 @@ void tst_QGraphicsProxyWidget::windowOpacity()
QTRY_COMPARE(eventSpy.counts[QEvent::UpdateRequest], 0);
QTRY_COMPARE(eventSpy.counts[QEvent::Paint], paints);
- QTRY_COMPARE(signalSpy.count(), 1);
+ QTRY_COMPARE(signalSpy.size(), 1);
const QList<QVariant> arguments = signalSpy.takeFirst();
const QList<QRectF> updateRects = qvariant_cast<QList<QRectF> >(arguments.at(0));
QCOMPARE(updateRects.size(), 1);
@@ -2903,10 +2903,10 @@ void tst_QGraphicsProxyWidget::createProxyForChildWidget()
QTest::mousePress(view.viewport(), Qt::LeftButton, {},
view.mapFromScene(checkboxProxy->mapToScene(QPointF(8,8))));
- QTRY_COMPARE(spy.count(), 0);
+ QTRY_COMPARE(spy.size(), 0);
QTest::mouseRelease(view.viewport(), Qt::LeftButton, {},
view.mapFromScene(checkboxProxy->mapToScene(QPointF(8,8))));
- QTRY_COMPARE(spy.count(), 1);
+ QTRY_COMPARE(spy.size(), 1);
@@ -3702,27 +3702,27 @@ void tst_QGraphicsProxyWidget::wheelEventPropagation()
// accepted by the embedded widget
QCOMPARE(view.itemAt(wheelPosition), nullptr);
wheelUp(Qt::NoScrollPhase);
- QCOMPARE(scrollSpy.count(), ++scrollCount);
+ QCOMPARE(scrollSpy.size(), ++scrollCount);
// wheeling on the label, which ignores the event, should scroll the view
QCOMPARE(view.itemAt(wheelPosition), labelProxy);
wheelUp(Qt::NoScrollPhase);
- QCOMPARE(scrollSpy.count(), ++scrollCount);
+ QCOMPARE(scrollSpy.size(), ++scrollCount);
QCOMPARE(view.itemAt(wheelPosition), labelProxy);
wheelUp(Qt::NoScrollPhase);
- QCOMPARE(scrollSpy.count(), ++scrollCount);
+ QCOMPARE(scrollSpy.size(), ++scrollCount);
// left the widget
QCOMPARE(view.itemAt(wheelPosition), nullptr);
wheelUp(Qt::NoScrollPhase);
- QCOMPARE(scrollSpy.count(), ++scrollCount);
+ QCOMPARE(scrollSpy.size(), ++scrollCount);
// reached the nested widget, which accepts the wheel event, so no more scrolling
QCOMPARE(view.itemAt(wheelPosition), nestedProxy);
// remember this position for later
const int scrollBarValueOnNestedProxy = view.verticalScrollBar()->value();
wheelUp(Qt::NoScrollPhase);
- QCOMPARE(scrollSpy.count(), scrollCount);
+ QCOMPARE(scrollSpy.size(), scrollCount);
QCOMPARE(nestedWidget->wheelEventCount, 1);
// reset, try with kinetic events
@@ -3733,41 +3733,41 @@ void tst_QGraphicsProxyWidget::wheelEventPropagation()
// no matter if the widget accepts wheel events - the view has the grab
QCOMPARE(view.itemAt(wheelPosition), nullptr);
wheelUp(Qt::ScrollBegin);
- QCOMPARE(scrollSpy.count(), ++scrollCount);
+ QCOMPARE(scrollSpy.size(), ++scrollCount);
for (int i = 0; i < 5; ++i) {
wheelUp(Qt::ScrollUpdate);
- QCOMPARE(scrollSpy.count(), ++scrollCount);
+ QCOMPARE(scrollSpy.size(), ++scrollCount);
}
wheelUp(Qt::ScrollEnd);
- QCOMPARE(scrollSpy.count(), ++scrollCount);
+ QCOMPARE(scrollSpy.size(), ++scrollCount);
// reset
view.verticalScrollBar()->setValue(0);
- scrollCount = scrollSpy.count();
+ scrollCount = scrollSpy.size();
// starting a scroll on a widget that doesn't accept wheel events
// should also scroll the view, which still gets the grab
wheelUp(Qt::NoScrollPhase);
- scrollCount = scrollSpy.count();
+ scrollCount = scrollSpy.size();
QCOMPARE(view.itemAt(wheelPosition), labelProxy);
wheelUp(Qt::ScrollBegin);
- QCOMPARE(scrollSpy.count(), ++scrollCount);
+ QCOMPARE(scrollSpy.size(), ++scrollCount);
for (int i = 0; i < 5; ++i) {
wheelUp(Qt::ScrollUpdate);
- QCOMPARE(scrollSpy.count(), ++scrollCount);
+ QCOMPARE(scrollSpy.size(), ++scrollCount);
}
wheelUp(Qt::ScrollEnd);
- QCOMPARE(scrollSpy.count(), ++scrollCount);
+ QCOMPARE(scrollSpy.size(), ++scrollCount);
// starting a scroll on a widget that does accept wheel events
// should not scroll the view
view.verticalScrollBar()->setValue(scrollBarValueOnNestedProxy);
- scrollCount = scrollSpy.count();
+ scrollCount = scrollSpy.size();
QCOMPARE(view.itemAt(wheelPosition), nestedProxy);
wheelUp(Qt::ScrollBegin);
- QCOMPARE(scrollSpy.count(), scrollCount);
+ QCOMPARE(scrollSpy.size(), scrollCount);
}
#endif // QT_CONFIG(wheelevent)
@@ -3969,7 +3969,7 @@ void tst_QGraphicsProxyWidget::touchEventPropagation()
QCOMPARE(record.receiver, view.windowHandle());
QCOMPARE(record.eventType, QEvent::TouchEnd);
QCOMPARE(eventSpy.mousePressReceiver, pushButton1);
- QCOMPARE(clickedSpy.count(), 1);
+ QCOMPARE(clickedSpy.size(), 1);
eventSpy.clear();
clickedSpy.clear();
@@ -4037,7 +4037,7 @@ void tst_QGraphicsProxyWidget::touchEventPropagation()
QCOMPARE(eventSpy.at(0, 3).receiver, touchWidget2);
QCOMPARE(eventSpy.at(1, 3).receiver, touchWidget2);
QCOMPARE(eventSpy.at(2, 3).receiver, touchWidget2);
- QCOMPARE(clickedSpy.count(), 0); // multi-touch event does not synthesize a mouse event
+ QCOMPARE(clickedSpy.size(), 0); // multi-touch event does not synthesize a mouse event
}
QTEST_MAIN(tst_QGraphicsProxyWidget)