From 1e714bb0fc45e333d7f9f52a9586aee06e9178e8 Mon Sep 17 00:00:00 2001 From: Soheil Armin Date: Thu, 14 Nov 2024 11:23:46 +0200 Subject: [PATCH] Fix flaky QtAbstractItemModel setData test case The Java callback function onDataChanged() gets called from Android UI thread. QTRY_COMPARE on the result of a JNI call does not make sense because it actually does not retry to reinvoke the JNI call to read the related counter. This change puts the JNI call to QTRY_COMPARE to make sure the Android thread have to to process the Runnable. Fixes: QTBUG-131253 Change-Id: Icdff8f8f37b33968f5a3f6e545ce753907305e74 Reviewed-by: Assam Boudjelthia --- .../corelib/platform/androiditemmodel/tst_androiditemmodel.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/auto/corelib/platform/androiditemmodel/tst_androiditemmodel.cpp b/tests/auto/corelib/platform/androiditemmodel/tst_androiditemmodel.cpp index a8adfaa4d32..baa808a9046 100644 --- a/tests/auto/corelib/platform/androiditemmodel/tst_androiditemmodel.cpp +++ b/tests/auto/corelib/platform/androiditemmodel/tst_androiditemmodel.cpp @@ -249,8 +249,7 @@ void tst_AndroidItemModel::setData() QCOMPARE(bottomRight, qProxy->index(row, column, QModelIndex())); QCOMPARE(roles, QList{role}); - jint jDataChangedCount = jModel.getField("m_dataChangedCount"); - QTRY_COMPARE(jDataChangedCount, 1); + QTRY_COMPARE(jModel.getField("m_dataChangedCount"), 1); } void tst_AndroidItemModel::resetModel()