summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/kernel/qjniobject
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2023-09-24 04:58:19 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2023-09-27 19:44:58 +0200
commit064b46779cb96225614ef3b5b1fa511b6acc3c9d (patch)
treed48dc7b4cd3403b3b808c1dff7bb885773887749 /tests/auto/corelib/kernel/qjniobject
parentca68fa01fe890e2f2c169e5ed7d793bd3c76d7be (diff)
JNI: Implement QJniObject::className to get the name of the class if not set
If we construct the QJniObject from a jobject, then we know the jclass, but not the class's name. If className is called while the stored name is empty, get the name of the jclass and updated the stored value. Change-Id: Ic3332a6da2dac1eb6842f90da1b9264398a43155 Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
Diffstat (limited to 'tests/auto/corelib/kernel/qjniobject')
-rw-r--r--tests/auto/corelib/kernel/qjniobject/tst_qjniobject.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/auto/corelib/kernel/qjniobject/tst_qjniobject.cpp b/tests/auto/corelib/kernel/qjniobject/tst_qjniobject.cpp
index 6f690f0091..36f6f5923e 100644
--- a/tests/auto/corelib/kernel/qjniobject/tst_qjniobject.cpp
+++ b/tests/auto/corelib/kernel/qjniobject/tst_qjniobject.cpp
@@ -42,6 +42,7 @@ private slots:
void callObjectMethodTest();
void stringConvertionTest();
void compareOperatorTests();
+ void className();
void callStaticObjectMethodClassName();
void callStaticObjectMethod();
void callStaticObjectMethodById();
@@ -300,6 +301,22 @@ void tst_QJniObject::compareOperatorTests()
QVERIFY(!invalidStringObject.isValid());
}
+void tst_QJniObject::className()
+{
+ const QString str("Hello!");
+ QJniObject jString = QJniObject::fromString(str);
+ {
+ QCOMPARE(jString.className(), "java/lang/String");
+ QCOMPARE(jString.toString(), str);
+ }
+
+ {
+ QJniObject strObject = QJniObject("java/lang/String", jString.object<jstring>());
+ QCOMPARE(strObject.className(), "java/lang/String");
+ QCOMPARE(strObject.toString(), str);
+ }
+}
+
void tst_QJniObject::callStaticObjectMethodClassName()
{
QJniObject formatString = QJniObject::fromString(QLatin1String("test format"));