summaryrefslogtreecommitdiffstats
path: root/tests/auto/other
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-10-04 07:40:08 +0200
commitdf9d882d41b741fef7c5beeddb0abe9d904443d8 (patch)
tree6f3e90dacad4581b7f1cabe235cca298833a3da4 /tests/auto/other
parent109e088c7c5d0c9325966e88d55fd9f7a58f67ea (diff)
Port from container.count()/length() to size()
This is semantic patch using ClangTidyTransformator: auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o) makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'. <classes> are: // sequential: "QByteArray", "QList", "QQueue", "QStack", "QString", "QVarLengthArray", "QVector", // associative: "QHash", "QMultiHash", "QMap", "QMultiMap", "QSet", // Qt has no QMultiSet Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'tests/auto/other')
-rw-r--r--tests/auto/other/gestures/tst_gestures.cpp32
-rw-r--r--tests/auto/other/networkselftest/tst_networkselftest.cpp16
-rw-r--r--tests/auto/other/qaccessibility/accessiblewidgets.h2
-rw-r--r--tests/auto/other/qaccessibility/tst_qaccessibility.cpp22
-rw-r--r--tests/auto/other/qcomplextext/tst_qcomplextext.cpp8
5 files changed, 40 insertions, 40 deletions
diff --git a/tests/auto/other/gestures/tst_gestures.cpp b/tests/auto/other/gestures/tst_gestures.cpp
index 9fe036dd89..1fcca836d3 100644
--- a/tests/auto/other/gestures/tst_gestures.cpp
+++ b/tests/auto/other/gestures/tst_gestures.cpp
@@ -584,7 +584,7 @@ void tst_Gestures::conflictingGestures()
QCOMPARE(child->gestureOverrideEventsReceived, 1);
QVERIFY(child->gestureEventsReceived > TotalGestureEventsCount);
- QCOMPARE(child->events.all.count(), TotalGestureEventsCount + ContinuousGestureEventsCount);
+ QCOMPARE(child->events.all.size(), TotalGestureEventsCount + ContinuousGestureEventsCount);
QCOMPARE(parent.gestureOverrideEventsReceived, 0);
QCOMPARE(parent.gestureEventsReceived, 0);
@@ -1409,13 +1409,13 @@ void tst_Gestures::ungrabGesture() // a method on QWidget
// sending an event will cause the QGesture objects to be instantiated for the widgets
sendCustomGesture(&event, b);
- QCOMPARE(a->gestures.count(), 1);
+ QCOMPARE(a->gestures.size(), 1);
QPointer<QGesture> customGestureA;
customGestureA = *(a->gestures.begin());
QVERIFY(!customGestureA.isNull());
QCOMPARE(customGestureA->gestureType(), CustomGesture::GestureType);
- QCOMPARE(b->gestures.count(), 1);
+ QCOMPARE(b->gestures.size(), 1);
QPointer<QGesture> customGestureB;
customGestureB = *(b->gestures.begin());
QVERIFY(!customGestureB.isNull());
@@ -1426,7 +1426,7 @@ void tst_Gestures::ungrabGesture() // a method on QWidget
// sending an event will cause the QGesture objects to be instantiated for the widget
sendCustomGesture(&event, a);
- QCOMPARE(a->gestures.count(), 1);
+ QCOMPARE(a->gestures.size(), 1);
customGestureA = *(a->gestures.begin());
QVERIFY(!customGestureA.isNull());
QCOMPARE(customGestureA->gestureType(), CustomGesture::GestureType);
@@ -1471,7 +1471,7 @@ void tst_Gestures::autoCancelGestures()
{
if (event->type() == QEvent::Gesture) {
QGestureEvent *ge = static_cast<QGestureEvent*>(event);
- if (ge->gestures().count() != 1)
+ if (ge->gestures().size() != 1)
++badGestureEvents; // event should contain exactly one gesture
ge->gestures().first()->setGestureCancelPolicy(QGesture::CancelAllInContext);
}
@@ -1504,15 +1504,15 @@ void tst_Gestures::autoCancelGestures()
CustomEvent event;
event.serial = CustomGesture::SerialStartedThreshold;
QApplication::sendEvent(child, &event);
- QCOMPARE(child->events.all.count(), 2);
- QCOMPARE(child->events.started.count(), 1);
- QCOMPARE(child->events.canceled.count(), 1);
- QCOMPARE(parent.events.all.count(), 1);
+ QCOMPARE(child->events.all.size(), 2);
+ QCOMPARE(child->events.started.size(), 1);
+ QCOMPARE(child->events.canceled.size(), 1);
+ QCOMPARE(parent.events.all.size(), 1);
// clean up, make the parent gesture finish
event.serial = CustomGesture::SerialFinishedThreshold;
QApplication::sendEvent(child, &event);
- QCOMPARE(parent.events.all.count(), 2);
+ QCOMPARE(parent.events.all.size(), 2);
QCOMPARE(parent.badGestureEvents, 0);
}
@@ -1526,7 +1526,7 @@ void tst_Gestures::autoCancelGestures2()
{
if (event->type() == QEvent::Gesture) {
QGestureEvent *ge = static_cast<QGestureEvent*>(event);
- if (ge->gestures().count() != 1)
+ if (ge->gestures().size() != 1)
++badGestureEvents; // event should contain exactly one gesture
ge->gestures().first()->setGestureCancelPolicy(QGesture::CancelAllInContext);
}
@@ -1561,15 +1561,15 @@ void tst_Gestures::autoCancelGestures2()
event.hasHotSpot = true;
event.hotSpot = mapToGlobal(QPointF(5, 5), child, &view);
scene.sendEvent(child, &event);
- QCOMPARE(parent->events.all.count(), 1);
- QCOMPARE(child->events.started.count(), 1);
- QCOMPARE(child->events.canceled.count(), 1);
- QCOMPARE(child->events.all.count(), 2);
+ QCOMPARE(parent->events.all.size(), 1);
+ QCOMPARE(child->events.started.size(), 1);
+ QCOMPARE(child->events.canceled.size(), 1);
+ QCOMPARE(child->events.all.size(), 2);
// clean up, make the parent gesture finish
event.serial = CustomGesture::SerialFinishedThreshold;
scene.sendEvent(child, &event);
- QCOMPARE(parent->events.all.count(), 2);
+ QCOMPARE(parent->events.all.size(), 2);
QCOMPARE(parent->badGestureEvents, 0);
}
diff --git a/tests/auto/other/networkselftest/tst_networkselftest.cpp b/tests/auto/other/networkselftest/tst_networkselftest.cpp
index 824f26aeaa..16b7d33097 100644
--- a/tests/auto/other/networkselftest/tst_networkselftest.cpp
+++ b/tests/auto/other/networkselftest/tst_networkselftest.cpp
@@ -105,8 +105,8 @@ static QString prettyByteArray(const QByteArray &array)
{
// any control chars?
QString result;
- result.reserve(array.length() + array.length() / 3);
- for (int i = 0; i < array.length(); ++i) {
+ result.reserve(array.size() + array.size() / 3);
+ for (int i = 0; i < array.size(); ++i) {
char c = array.at(i);
switch (c) {
case '\n':
@@ -208,11 +208,11 @@ static void netChat(int port, const QList<Chat> &chat)
switch (it->type) {
case Chat::Expect: {
qDebug() << i << "Expecting" << prettyByteArray(it->data);
- if (!doSocketRead(&socket, it->data.length(), 3 * defaultReadTimeoutMS))
- QFAIL(msgDoSocketReadFailed(serverName, port, i, it->data.length()));
+ if (!doSocketRead(&socket, it->data.size(), 3 * defaultReadTimeoutMS))
+ QFAIL(msgDoSocketReadFailed(serverName, port, i, it->data.size()));
// pop that many bytes off the socket
- QByteArray received = socket.read(it->data.length());
+ QByteArray received = socket.read(it->data.size());
// is it what we expected?
QVERIFY2(received == it->data,
@@ -226,8 +226,8 @@ static void netChat(int port, const QList<Chat> &chat)
qDebug() << i << "Discarding until" << prettyByteArray(it->data);
while (true) {
// scan the buffer until we have our string
- if (!doSocketRead(&socket, it->data.length()))
- QFAIL(msgDoSocketReadFailed(serverName, port, i, it->data.length()));
+ if (!doSocketRead(&socket, it->data.size()))
+ QFAIL(msgDoSocketReadFailed(serverName, port, i, it->data.size()));
QByteArray buffer;
buffer.resize(socket.bytesAvailable());
@@ -239,7 +239,7 @@ static void netChat(int port, const QList<Chat> &chat)
continue;
}
- buffer = socket.read(pos + it->data.length());
+ buffer = socket.read(pos + it->data.size());
qDebug() << i << "Discarded" << prettyByteArray(buffer);
break;
}
diff --git a/tests/auto/other/qaccessibility/accessiblewidgets.h b/tests/auto/other/qaccessibility/accessiblewidgets.h
index 2e93f24fd3..b0382ef60a 100644
--- a/tests/auto/other/qaccessibility/accessiblewidgets.h
+++ b/tests/auto/other/qaccessibility/accessiblewidgets.h
@@ -116,7 +116,7 @@ public:
int cursorPosition() const override { return textWidget()->cursorPosition; }
void setCursorPosition(int position) override { textWidget()->cursorPosition = position; }
QString text(int startOffset, int endOffset) const override { return textWidget()->text.mid(startOffset, endOffset); }
- int characterCount() const override { return textWidget()->text.length(); }
+ int characterCount() const override { return textWidget()->text.size(); }
QRect characterRect(int) const override { return QRect(); }
int offsetAtPoint(const QPoint &) const override { return 0; }
void scrollToSubstring(int, int) override {}
diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
index c54d9308c4..f65230c07c 100644
--- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
+++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
@@ -786,7 +786,7 @@ void tst_QAccessibility::textAttributes()
QAccessibleInterface *interface = QAccessible::queryAccessibleInterface(&textEdit);
QAccessibleTextInterface *textInterface=interface->textInterface();
QVERIFY(textInterface);
- QCOMPARE(textInterface->characterCount(), textEdit.toPlainText().length());
+ QCOMPARE(textInterface->characterCount(), textEdit.toPlainText().size());
int startOffset = -1;
int endOffset = -1;
@@ -1948,7 +1948,7 @@ void tst_QAccessibility::mdiAreaTest()
mdiArea.addSubWindow(new QWidget, Qt::Dialog)->show();
QList<QMdiSubWindow *> subWindows = mdiArea.subWindowList();
- QCOMPARE(subWindows.count(), subWindowCount);
+ QCOMPARE(subWindows.size(), subWindowCount);
QAccessibleInterface *interface = QAccessible::queryAccessibleInterface(&mdiArea);
QVERIFY(interface);
@@ -1986,7 +1986,7 @@ void tst_QAccessibility::mdiSubWindowTest()
}
QList<QMdiSubWindow *> subWindows = mdiArea.subWindowList();
- QCOMPARE(subWindows.count(), subWindowCount);
+ QCOMPARE(subWindows.size(), subWindowCount);
QMdiSubWindow *testWindow = subWindows.at(3);
QVERIFY(testWindow);
@@ -2110,10 +2110,10 @@ void tst_QAccessibility::lineEditTest()
QCOMPARE(iface->text(QAccessible::Value), QString());
le->setEchoMode(QLineEdit::Password);
QVERIFY(iface->state().passwordEdit);
- QCOMPARE(iface->text(QAccessible::Value), QString(secret.length(), QLatin1Char('*')));
+ QCOMPARE(iface->text(QAccessible::Value), QString(secret.size(), QLatin1Char('*')));
le->setEchoMode(QLineEdit::PasswordEchoOnEdit);
QVERIFY(iface->state().passwordEdit);
- QCOMPARE(iface->text(QAccessible::Value), QString(secret.length(), QLatin1Char('*')));
+ QCOMPARE(iface->text(QAccessible::Value), QString(secret.size(), QLatin1Char('*')));
le->setEchoMode(QLineEdit::Normal);
QVERIFY(!(iface->state().passwordEdit));
QCOMPARE(iface->text(QAccessible::Value), secret);
@@ -2205,7 +2205,7 @@ void tst_QAccessibility::lineEditTest()
QCOMPARE(textIface->textAtOffset(5, QAccessible::ParagraphBoundary,&start,&end), cite);
QCOMPARE(start, 0);
- QCOMPARE(end, cite.length());
+ QCOMPARE(end, cite.size());
QCOMPARE(textIface->textAtOffset(5, QAccessible::LineBoundary,&start,&end), cite);
QCOMPARE(textIface->textAtOffset(5, QAccessible::NoBoundary,&start,&end), cite);
@@ -2249,8 +2249,8 @@ void tst_QAccessibility::lineEditTest()
QVERIFY_EVENT(&sel);
lineEdit->selectAll();
- sel.setSelection(0, lineEdit->text().length());
- sel.setCursorPosition(lineEdit->text().length());
+ sel.setSelection(0, lineEdit->text().size());
+ sel.setCursorPosition(lineEdit->text().size());
QVERIFY_EVENT(&sel);
lineEdit->setSelection(10, -4);
@@ -2606,7 +2606,7 @@ void tst_QAccessibility::dialogButtonBoxTest()
std::sort(buttons.begin(), buttons.end(), accessibleInterfaceLeftOf);
- for (int i = 0; i < buttons.count(); ++i)
+ for (int i = 0; i < buttons.size(); ++i)
actualOrder << buttons.at(i)->text(QAccessible::Name);
QStringList expectedOrder;
@@ -2658,7 +2658,7 @@ void tst_QAccessibility::dialogButtonBoxTest()
std::sort(buttons.begin(), buttons.end(), accessibleInterfaceAbove);
- for (int i = 0; i < buttons.count(); ++i)
+ for (int i = 0; i < buttons.size(); ++i)
actualOrder << buttons.at(i)->text(QAccessible::Name);
QStringList expectedOrder;
@@ -3720,7 +3720,7 @@ void tst_QAccessibility::labelTest()
QCOMPARE(acc_label->state().readOnly, true);
QList<QPair<QAccessibleInterface *, QAccessible::Relation>> rels = acc_label->relations();
- QCOMPARE(rels.count(), 1);
+ QCOMPARE(rels.size(), 1);
QAccessibleInterface *iface = rels.first().first;
QAccessible::Relation rel = rels.first().second;
diff --git a/tests/auto/other/qcomplextext/tst_qcomplextext.cpp b/tests/auto/other/qcomplextext/tst_qcomplextext.cpp
index 1b944bf1b6..a164851886 100644
--- a/tests/auto/other/qcomplextext/tst_qcomplextext.cpp
+++ b/tests/auto/other/qcomplextext/tst_qcomplextext.cpp
@@ -84,7 +84,7 @@ void tst_QComplexText::bidiReorderString()
if (si.analysis.bidiLevel % 2) {
// reverse sub
QChar *a = sub.data();
- QChar *b = a + sub.length() - 1;
+ QChar *b = a + sub.size() - 1;
while (a < b) {
QChar tmp = *a;
*a = *b;
@@ -93,7 +93,7 @@ void tst_QComplexText::bidiReorderString()
--b;
}
a = (QChar *)sub.unicode();
- b = a + sub.length();
+ b = a + sub.size();
while (a<b) {
*a = a->mirroredChar();
++a;
@@ -315,7 +315,7 @@ static void testBidiString(const QString &data, int paragraphDirection,
if (si.analysis.bidiLevel % 2) {
// reverse sub
QChar *a = sub.data();
- QChar *b = a + sub.length() - 1;
+ QChar *b = a + sub.size() - 1;
while (a < b) {
QChar tmp = *a;
*a = *b;
@@ -324,7 +324,7 @@ static void testBidiString(const QString &data, int paragraphDirection,
--b;
}
a = (QChar *)sub.unicode();
- b = a + sub.length();
+ b = a + sub.size();
// while (a<b) {
// *a = a->mirroredChar();
// ++a;