JNI: harden QJniObject test case
Fail the test when an unexpected warning message about a field, class, or method not being found is generated from a JNI exception. Fix the failure when trying to look-up a boolean field that is no longer available, and ignore the one expected message from looking up an unavailable class explicitly. Change-Id: Ic5e4c003c64272f06a6d4da028e232abba75c4e4 Reviewed-by: Zoltan Gera <zoltan.gera@qt.io> Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
This commit is contained in:
parent
a948b12423
commit
218daa6f77
@ -35,6 +35,7 @@ public:
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
void init();
|
||||
|
||||
void ctor();
|
||||
void callMethodTest();
|
||||
@ -121,6 +122,14 @@ void tst_QJniObject::initTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
void tst_QJniObject::init()
|
||||
{
|
||||
// Unless explicitly ignored to test error handling, warning messages
|
||||
// in this test about a failure to look up a field, method, or class
|
||||
// make the test fail.
|
||||
QTest::failOnWarning(QRegularExpression("java.lang.NoSuch.*Error"));
|
||||
}
|
||||
|
||||
void tst_QJniObject::cleanupTestCase()
|
||||
{
|
||||
}
|
||||
@ -992,7 +1001,7 @@ void tst_QJniObject::getBooleanField()
|
||||
QJniObject obj("org/qtproject/qt/android/QtActivityDelegate");
|
||||
|
||||
QVERIFY(obj.isValid());
|
||||
QVERIFY(!obj.getField<jboolean>("m_fullScreen"));
|
||||
QVERIFY(!obj.getField<jboolean>("m_backKeyPressedSent"));
|
||||
}
|
||||
|
||||
void tst_QJniObject::getIntField()
|
||||
@ -1555,6 +1564,7 @@ void tst_QJniObject::templateApiCheck()
|
||||
void tst_QJniObject::isClassAvailable()
|
||||
{
|
||||
QVERIFY(QJniObject::isClassAvailable("java/lang/String"));
|
||||
QTest::ignoreMessage(QtWarningMsg, QRegularExpression("java.lang.ClassNotFoundException"));
|
||||
QVERIFY(!QJniObject::isClassAvailable("class/not/Available"));
|
||||
QVERIFY(QJniObject::isClassAvailable("org/qtproject/qt/android/QtActivityDelegate"));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user