diff options
author | Assam Boudjelthia <assam.boudjelthia@qt.io> | 2021-04-15 16:52:44 +0300 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-04-26 08:22:48 +0000 |
commit | d119ccb8f91482e3d167745ad9f247c6613283b4 (patch) | |
tree | 6b0a0c4e20da5e5eee8f1bf070df453ada765ea9 /tests | |
parent | 644161a5e0618aa072b2e6f6259d446e4ea07f60 (diff) |
Fix QJniObject templates implementations
Define the template calls in the header to allow for better type
handling and checking with constexpr and avoid overuse of macros.
Depending on the type provided in the QJniObject's call, the
signatures and the correct JNI function variant is used.
If a type is not supported a static_assert throws a compiler error.
Change-Id: I8a4d3ce85e1ff76ef385633f2a68511fffd12e55
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
(cherry picked from commit f4e23bf3deb69131f78eb78a1cb06da0fe72d9d4)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/corelib/kernel/qjniobject/tst_qjniobject.cpp | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/tests/auto/corelib/kernel/qjniobject/tst_qjniobject.cpp b/tests/auto/corelib/kernel/qjniobject/tst_qjniobject.cpp index 96637a72a6..7b5c60a7d7 100644 --- a/tests/auto/corelib/kernel/qjniobject/tst_qjniobject.cpp +++ b/tests/auto/corelib/kernel/qjniobject/tst_qjniobject.cpp @@ -26,6 +26,8 @@ ** ****************************************************************************/ +#include <jni.h> + #include <QString> #include <QtCore/QJniEnvironment> #include <QtCore/QJniObject> @@ -520,9 +522,9 @@ void tst_QJniObject::callStaticLongMethod() void tst_QJniObject::getStaticObjectFieldClassName() { { - QJniObject boolObject = QJniObject::getStaticObjectField<jobject>("java/lang/Boolean", - "FALSE", - "Ljava/lang/Boolean;"); + QJniObject boolObject = QJniObject::getStaticObjectField("java/lang/Boolean", + "FALSE", + "Ljava/lang/Boolean;"); QVERIFY(boolObject.isValid()); jboolean booleanValue = boolObject.callMethod<jboolean>("booleanValue"); @@ -530,9 +532,9 @@ void tst_QJniObject::getStaticObjectFieldClassName() } { - QJniObject boolObject = QJniObject::getStaticObjectField<jobject>("java/lang/Boolean", - "TRUE", - "Ljava/lang/Boolean;"); + QJniObject boolObject = QJniObject::getStaticObjectField("java/lang/Boolean", + "TRUE", + "Ljava/lang/Boolean;"); QVERIFY(boolObject.isValid()); jboolean booleanValue = boolObject.callMethod<jboolean>("booleanValue"); @@ -556,9 +558,9 @@ void tst_QJniObject::getStaticObjectField() QVERIFY(cls != 0); { - QJniObject boolObject = QJniObject::getStaticObjectField<jobject>(cls, - "FALSE", - "Ljava/lang/Boolean;"); + QJniObject boolObject = QJniObject::getStaticObjectField(cls, + "FALSE", + "Ljava/lang/Boolean;"); QVERIFY(boolObject.isValid()); jboolean booleanValue = boolObject.callMethod<jboolean>("booleanValue"); @@ -566,9 +568,9 @@ void tst_QJniObject::getStaticObjectField() } { - QJniObject boolObject = QJniObject::getStaticObjectField<jobject>(cls, - "TRUE", - "Ljava/lang/Boolean;"); + QJniObject boolObject = QJniObject::getStaticObjectField(cls, + "TRUE", + "Ljava/lang/Boolean;"); QVERIFY(boolObject.isValid()); jboolean booleanValue = boolObject.callMethod<jboolean>("booleanValue"); |