From 44e67c8c7ee0c82156a43d5088dc97c9b0f47ffc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Str=C3=B8mme?= Date: Tue, 3 Mar 2015 13:48:14 +0100 Subject: Add fromLocalRef() to QAndroidJniObject This makes it more convenient to transfer the ownership of the local JNI reference to QAndroidJniObject. Before this change user would need to manually delete the local ref. after creating a QAndroidJniObject. Change-Id: Iebae7829773d1b783dc0982de92c51b4c6b0abd1 Reviewed-by: Alex Blasche --- tests/auto/qandroidjniobject/tst_qandroidjniobject.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests') diff --git a/tests/auto/qandroidjniobject/tst_qandroidjniobject.cpp b/tests/auto/qandroidjniobject/tst_qandroidjniobject.cpp index c46a03a..73674f8 100644 --- a/tests/auto/qandroidjniobject/tst_qandroidjniobject.cpp +++ b/tests/auto/qandroidjniobject/tst_qandroidjniobject.cpp @@ -105,6 +105,7 @@ private slots: void getIntField(); void templateApiCheck(); void isClassAvailable(); + void fromLocalRef(); void cleanupTestCase(); }; @@ -1046,6 +1047,14 @@ void tst_QAndroidJniObject::isClassAvailable() QVERIFY(QAndroidJniObject::isClassAvailable("org/qtproject/qt5/android/QtActivityDelegate")); } +void tst_QAndroidJniObject::fromLocalRef() +{ + const int limit = 512 + 1; + QAndroidJniEnvironment env; + for (int i = 0; i != limit; ++i) + QAndroidJniObject o = QAndroidJniObject::fromLocalRef(env->FindClass("java/lang/String")); +} + QTEST_APPLESS_MAIN(tst_QAndroidJniObject) #include "tst_qandroidjniobject.moc" -- cgit v1.2.3