diff options
author | Assam Boudjelthia <assam.boudjelthia@qt.io> | 2021-05-11 14:23:45 +0300 |
---|---|---|
committer | Assam Boudjelthia <assam.boudjelthia@qt.io> | 2021-05-13 01:41:36 +0300 |
commit | 23780891a50ba678714f7e0a4cf43a0f8164b440 (patch) | |
tree | 6dace90d624f15f1e456f4d8294cb67beab1e9d4 /tests/auto/other | |
parent | 320c282488f4ae4cae735b0be027170803d06cd7 (diff) |
Add tests for QAndroidApplication's sdkVersion and activity
While at it, move tst_android under corelib/platform/android.
Change-Id: Icf91cd75cb5e04d03fe6a81d52fba52a485ca41f
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
Diffstat (limited to 'tests/auto/other')
-rw-r--r-- | tests/auto/other/CMakeLists.txt | 3 | ||||
-rw-r--r-- | tests/auto/other/android/tst_android.cpp | 24 |
2 files changed, 21 insertions, 6 deletions
diff --git a/tests/auto/other/CMakeLists.txt b/tests/auto/other/CMakeLists.txt index 6142d086b4..f0cdeec0f2 100644 --- a/tests/auto/other/CMakeLists.txt +++ b/tests/auto/other/CMakeLists.txt @@ -44,9 +44,6 @@ endif() if(embedded) add_subdirectory(qdirectpainter) endif() -if(ANDROID) - add_subdirectory(android) -endif() if(QT_FEATURE_xkbcommon AND TARGET Qt::Gui) add_subdirectory(xkbkeyboard) endif() diff --git a/tests/auto/other/android/tst_android.cpp b/tests/auto/other/android/tst_android.cpp index 6a492e9315..3a00d9414b 100644 --- a/tests/auto/other/android/tst_android.cpp +++ b/tests/auto/other/android/tst_android.cpp @@ -26,7 +26,11 @@ ** ****************************************************************************/ +#include <jni.h> + #include <QTest> +#include <QtCore/qnativeinterface.h> +#include <QtCore/qjniobject.h> class tst_Android : public QObject { @@ -34,18 +38,20 @@ Q_OBJECT private slots: void assetsRead(); void assetsNotWritable(); + void testAndroidSdkVersion(); + void testAndroidActivity(); }; void tst_Android::assetsRead() { { - QFile file("assets:/test.txt"); + QFile file(QStringLiteral("assets:/test.txt")); QVERIFY(file.open(QIODevice::ReadOnly)); QCOMPARE(file.readAll(), QByteArray("FooBar")); } { - QFile file("assets:/test.txt"); + QFile file(QStringLiteral("assets:/test.txt")); QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text)); QCOMPARE(file.readAll(), QByteArray("FooBar")); } @@ -53,12 +59,24 @@ void tst_Android::assetsRead() void tst_Android::assetsNotWritable() { - QFile file("assets:/test.txt"); + QFile file(QStringLiteral("assets:/test.txt")); QVERIFY(!file.open(QIODevice::WriteOnly)); QVERIFY(!file.open(QIODevice::ReadWrite)); QVERIFY(!file.open(QIODevice::Append)); } +void tst_Android::testAndroidSdkVersion() +{ + QVERIFY(QNativeInterface::QAndroidApplication::sdkVersion() > 0); +} + +void tst_Android::testAndroidActivity() +{ + QJniObject activity = QNativeInterface::QAndroidApplication::context(); + QVERIFY(activity.isValid()); + QVERIFY(activity.callMethod<jboolean>("isTaskRoot")); +} + QTEST_MAIN(tst_Android) #include "tst_android.moc" |