aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Strømme <christian.stromme@qt.io>2019-06-25 13:30:22 +0200
committerChristian Strømme <christian.stromme@qt.io>2019-06-28 11:18:50 +0200
commite0b68dfe82b350f5502e939d9cd2ff8a680f846a (patch)
treed3568c4e2ee6275f2c494d2d28bde39c453b986d
parent77485c52210cb3d6a2899498331986ab64756811 (diff)
Fix QAndroidJniEnvironment test
The QAndroidJniEnvironment class does not detach when it goes out of scope. Detaching will only happen if explicitly done, or if the thread we attached on dies. Fixes: QTBUG-73570 Change-Id: Iac749c7f3bf8fcee99f70c06123eb3c88315e261 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
-rw-r--r--tests/auto/qandroidjnienvironment/tst_qandroidjnienvironment.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/tests/auto/qandroidjnienvironment/tst_qandroidjnienvironment.cpp b/tests/auto/qandroidjnienvironment/tst_qandroidjnienvironment.cpp
index f0f8fa6..3aa2033 100644
--- a/tests/auto/qandroidjnienvironment/tst_qandroidjnienvironment.cpp
+++ b/tests/auto/qandroidjnienvironment/tst_qandroidjnienvironment.cpp
@@ -66,9 +66,10 @@ void tst_QAndroidJniEnvironment::jniEnv()
env->ExceptionClear();
}
- // The environment should automatically be detached when QAndroidJniEnvironment goes out of scope
- JNIEnv *jni = 0;
- QCOMPARE(javaVM->GetEnv((void**)&jni, JNI_VERSION_1_6), JNI_EDETACHED);
+ // The env does not detach automatically, even if it goes out of scope. The only way it can
+ // be detached is if it's done explicitly, or if the thread we attached to gets killed (TLS clean-up).
+ JNIEnv *jni = nullptr;
+ QCOMPARE(javaVM->GetEnv((void**)&jni, JNI_VERSION_1_6), JNI_OK);
}
void tst_QAndroidJniEnvironment::javaVM()