summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/widgets/qpushbutton
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/widgets/qpushbutton
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/widgets/qpushbutton')
-rw-r--r--tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp b/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
index bf06675804..11cac837b9 100644
--- a/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+++ b/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
@@ -613,7 +613,7 @@ void tst_QPushButton::taskQTBUG_20191_shortcutWithKeypadModifer()
QTest::qWait(300);
QTest::keyClick(&dialog, Qt::Key_5, Qt::KeypadModifier);
QTest::qWait(300);
- QCOMPARE(spy1.count(), 2);
+ QCOMPARE(spy1.size(), 2);
// add shortcut 'keypad 5' to button2
spy1.clear();
@@ -623,8 +623,8 @@ void tst_QPushButton::taskQTBUG_20191_shortcutWithKeypadModifer()
QTest::qWait(300);
QTest::keyClick(&dialog, Qt::Key_5, Qt::KeypadModifier);
QTest::qWait(300);
- QCOMPARE(spy1.count(), 1);
- QCOMPARE(spy2.count(), 1);
+ QCOMPARE(spy1.size(), 1);
+ QCOMPARE(spy2.size(), 1);
// remove shortcut from button1
spy1.clear();
@@ -634,8 +634,8 @@ void tst_QPushButton::taskQTBUG_20191_shortcutWithKeypadModifer()
QTest::qWait(300);
QTest::keyClick(&dialog, Qt::Key_5, Qt::KeypadModifier);
QTest::qWait(300);
- QCOMPARE(spy1.count(), 0);
- QCOMPARE(spy2.count(), 1);
+ QCOMPARE(spy1.size(), 0);
+ QCOMPARE(spy2.size(), 1);
}
#endif // QT_CONFIG(shortcut)
@@ -659,16 +659,16 @@ void tst_QPushButton::emitReleasedAfterChange()
QVERIFY(button1->isDown());
QTest::keyClick(&dialog, Qt::Key_Tab);
QVERIFY(!button1->isDown());
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
button1->setFocus();
QTest::mousePress(button1, Qt::LeftButton);
QVERIFY(button1->isDown());
button1->setEnabled(false);
QVERIFY(!button1->isDown());
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
/*
@@ -746,22 +746,22 @@ void tst_QPushButton::mousePressAndMove()
QSignalSpy releaseSpy(&button, &QAbstractButton::released);
QTest::mousePress(&button, Qt::LeftButton);
- QCOMPARE(pressSpy.count(), 1);
- QCOMPARE(releaseSpy.count(), 0);
+ QCOMPARE(pressSpy.size(), 1);
+ QCOMPARE(releaseSpy.size(), 0);
// mouse pressed and moving out
QTest::mouseMove(&button, QPoint(100, 100));
// should emit released signal when the mouse is dragged out of boundary
- QCOMPARE(pressSpy.count(), 1);
- QCOMPARE(releaseSpy.count(), 1);
+ QCOMPARE(pressSpy.size(), 1);
+ QCOMPARE(releaseSpy.size(), 1);
// mouse pressed and moving into
QTest::mouseMove(&button, QPoint(10, 10));
// should emit pressed signal when the mouse is dragged into of boundary
- QCOMPARE(pressSpy.count(), 2);
- QCOMPARE(releaseSpy.count(), 1);
+ QCOMPARE(pressSpy.size(), 2);
+ QCOMPARE(releaseSpy.size(), 1);
}
QTEST_MAIN(tst_QPushButton)