summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/kernel')
-rw-r--r--tests/auto/corelib/kernel/qjniobject/tst_qjniobject.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/tests/auto/corelib/kernel/qjniobject/tst_qjniobject.cpp b/tests/auto/corelib/kernel/qjniobject/tst_qjniobject.cpp
index 7ea6b1e121..b524997961 100644
--- a/tests/auto/corelib/kernel/qjniobject/tst_qjniobject.cpp
+++ b/tests/auto/corelib/kernel/qjniobject/tst_qjniobject.cpp
@@ -8,6 +8,8 @@
#include <QtCore/QJniObject>
#include <QtTest>
+using namespace Qt::StringLiterals;
+
static const char testClassName[] = "org/qtproject/qt/android/testdatapackage/QtJniObjectTestClass";
Q_DECLARE_JNI_CLASS(QtJniObjectTestClass, testClassName)
@@ -310,7 +312,8 @@ void tst_QJniObject::callStaticObjectMethod()
jclass cls = env->FindClass("java/lang/String");
QVERIFY(cls != 0);
- QJniObject formatString = QJniObject::fromString(QLatin1String("test format"));
+ const QString string = u"test format"_s;
+ QJniObject formatString = QJniObject::fromString(string);
QVERIFY(formatString.isValid());
QJniObject returnValue = QJniObject::callStaticObjectMethod(cls,
@@ -319,20 +322,14 @@ void tst_QJniObject::callStaticObjectMethod()
formatString.object<jstring>(),
jobjectArray(0));
QVERIFY(returnValue.isValid());
-
- QString returnedString = returnValue.toString();
-
- QCOMPARE(returnedString, QString::fromLatin1("test format"));
+ QCOMPARE(returnValue.toString(), string);
returnValue = QJniObject::callStaticObjectMethod<jstring>(cls,
"format",
formatString.object<jstring>(),
jobjectArray(0));
QVERIFY(returnValue.isValid());
-
- returnedString = returnValue.toString();
-
- QCOMPARE(returnedString, QString::fromLatin1("test format"));
+ QCOMPARE(returnValue.toString(), string);
// from 6.4 on we can use callStaticMethod
returnValue = QJniObject::callStaticMethod<jstring>(cls,
@@ -340,10 +337,15 @@ void tst_QJniObject::callStaticObjectMethod()
formatString.object<jstring>(),
jobjectArray(0));
QVERIFY(returnValue.isValid());
+ QCOMPARE(returnValue.toString(), string);
- returnedString = returnValue.toString();
+ // from 6.7 we can use callStaticMethod without specifying the class string
+ returnValue = QJniObject::callStaticMethod<jstring, jstring>("format",
+ formatString.object<jstring>(),
+ jobjectArray(0));
+ QVERIFY(returnValue.isValid());
+ QCOMPARE(returnValue.toString(), string);
- QCOMPARE(returnedString, QString::fromLatin1("test format"));
}
void tst_QJniObject::callStaticObjectMethodById()