summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/widgets/qtoolbutton
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/qtoolbutton
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/qtoolbutton')
-rw-r--r--tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp38
1 files changed, 19 insertions, 19 deletions
diff --git a/tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp b/tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp
index e562013345..c5ed718edb 100644
--- a/tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp
+++ b/tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp
@@ -124,7 +124,7 @@ void tst_QToolButton::triggered()
QVERIFY(QTest::qWaitForWindowActive(&mainWidget));
defaultAction->trigger();
- QCOMPARE(spy.count(),1);
+ QCOMPARE(spy.size(),1);
QCOMPARE(qvariant_cast<QAction *>(spy.at(0).at(0)), defaultAction);
m_menu = menu.data();
@@ -135,7 +135,7 @@ void tst_QToolButton::triggered()
timer->start();
QTimer::singleShot(10000, &mainWidget, SLOT(close())); // Emergency bail-out
toolButton->showMenu();
- QTRY_COMPARE(spy.count(),2);
+ QTRY_COMPARE(spy.size(),2);
QCOMPARE(qvariant_cast<QAction *>(spy.at(1).at(0)), one);
}
@@ -188,7 +188,7 @@ void tst_QToolButton::task176137_autoRepeatOfAction()
QTest::mousePress (toolButton, Qt::LeftButton);
QTest::qWait(2000);
QTest::mouseRelease (toolButton, Qt::LeftButton, {}, {});
- QCOMPARE(spy.count(),1);
+ QCOMPARE(spy.size(),1);
// try again with auto repeat
toolButton->setAutoRepeat (true);
@@ -198,11 +198,11 @@ void tst_QToolButton::task176137_autoRepeatOfAction()
QTest::mouseRelease (toolButton, Qt::LeftButton, {}, {});
const qreal expected = (3000 - toolButton->autoRepeatDelay()) / toolButton->autoRepeatInterval() + 1;
//we check that the difference is small (on some systems timers are not super accurate)
- qreal diff = (expected - repeatSpy.count()) / expected;
+ qreal diff = (expected - repeatSpy.size()) / expected;
QVERIFY2(qAbs(diff) < 0.2, qPrintable(
QString("expected: %1, actual: %2, diff (fraction): %3")
.arg(expected)
- .arg(repeatSpy.count())
+ .arg(repeatSpy.size())
.arg(diff)));
}
@@ -275,21 +275,21 @@ void tst_QToolButton::defaultActionSynced()
tb.setChecked(true);
QVERIFY(a.isChecked());
- QCOMPARE(tbSpy.count(), ++tbToggledCount);
- QCOMPARE(aSpy.count(), ++aToggledCount);
+ QCOMPARE(tbSpy.size(), ++tbToggledCount);
+ QCOMPARE(aSpy.size(), ++aToggledCount);
tb.setChecked(false);
QVERIFY(!a.isChecked());
- QCOMPARE(tbSpy.count(), ++tbToggledCount);
- QCOMPARE(aSpy.count(), ++aToggledCount);
+ QCOMPARE(tbSpy.size(), ++tbToggledCount);
+ QCOMPARE(aSpy.size(), ++aToggledCount);
a.setChecked(true);
QVERIFY(tb.isChecked());
- QCOMPARE(tbSpy.count(), ++tbToggledCount);
- QCOMPARE(aSpy.count(), ++aToggledCount);
+ QCOMPARE(tbSpy.size(), ++tbToggledCount);
+ QCOMPARE(aSpy.size(), ++aToggledCount);
a.setChecked(false);
QVERIFY(!tb.isChecked());
- QCOMPARE(tbSpy.count(), ++tbToggledCount);
- QCOMPARE(aSpy.count(), ++aToggledCount);
+ QCOMPARE(tbSpy.size(), ++tbToggledCount);
+ QCOMPARE(aSpy.size(), ++aToggledCount);
QAction b;
QSignalSpy bSpy(&b, SIGNAL(toggled(bool)));
@@ -303,17 +303,17 @@ void tst_QToolButton::defaultActionSynced()
QVERIFY(!a.isChecked());
QVERIFY(b.isChecked());
- QCOMPARE(tbSpy.count(), ++tbToggledCount);
- QCOMPARE(aSpy.count(), aToggledCount);
- QCOMPARE(bSpy.count(), ++bToggledCount);
+ QCOMPARE(tbSpy.size(), ++tbToggledCount);
+ QCOMPARE(aSpy.size(), aToggledCount);
+ QCOMPARE(bSpy.size(), ++bToggledCount);
tb.click();
QVERIFY(!a.isChecked());
QVERIFY(!tb.isChecked());
QVERIFY(!b.isChecked());
- QCOMPARE(tbSpy.count(), ++tbToggledCount);
- QCOMPARE(aSpy.count(), aToggledCount);
- QCOMPARE(bSpy.count(), ++bToggledCount);
+ QCOMPARE(tbSpy.size(), ++tbToggledCount);
+ QCOMPARE(aSpy.size(), aToggledCount);
+ QCOMPARE(bSpy.size(), ++bToggledCount);
}
QTEST_MAIN(tst_QToolButton)