summaryrefslogtreecommitdiffstats
path: root/tests/auto/other
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2022-02-16 18:07:54 +0100
committerIvan Solovev <ivan.solovev@qt.io>2022-02-25 13:52:33 +0100
commit3b82c2d16780c4474ebdf7064f406dc266eeba58 (patch)
treef996149cf562cf3a4f6b1c5c9dda7370e74ca493 /tests/auto/other
parent5a39173c34be6fb033b8988408d0d98546db9f13 (diff)
Fix tst_qaccessibility on Android
On Android we had 10 failing unit-tests in tst_qaccessibility One of them was failing because on Android QMdiSubWindow is created maximized by default, so we need to explicitly call showNormal() on it before doing all the checks. Other 9 were failing because we didn't get A11Y events when expected. This is a bit more tricky. On Android a11y state is not explicitly set by calling QPlatformAccessibility::setActive(), there is another flag that is controller from the Java side. It is set to 'true' only when some of the a11y services are enabled on the device. The state of this flag is queried during event processing, so a11y state can be reset to false while we do QTest::qWait(). This logic is absolutely correct for real applications, but it is a problem for the test case, because we can't easily enable a11y services in the CI. To overcome the issue in unit-tests, re-enable a11y before each test. A more precise fix will require re-enabling it after every qWait() or processEvents() call, but the current tests pass with such condition. Fixes: QTBUG-87674 Pick-to: 6.3 6.2 Change-Id: I6f765bc6d3aaeaa19aba3a64473ea25e9cbdb0f8 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Diffstat (limited to 'tests/auto/other')
-rw-r--r--tests/auto/other/CMakeLists.txt3
-rw-r--r--tests/auto/other/qaccessibility/tst_qaccessibility.cpp29
2 files changed, 27 insertions, 5 deletions
diff --git a/tests/auto/other/CMakeLists.txt b/tests/auto/other/CMakeLists.txt
index 8255406bb5..5f49dacdc0 100644
--- a/tests/auto/other/CMakeLists.txt
+++ b/tests/auto/other/CMakeLists.txt
@@ -21,8 +21,7 @@ endif()
if(TARGET Qt::Network)
add_subdirectory(networkselftest)
endif()
-# QTBUG-87674 # special case
-if(QT_FEATURE_accessibility AND TARGET Qt::Gui AND TARGET Qt::Widgets AND NOT ANDROID)
+if(QT_FEATURE_accessibility AND TARGET Qt::Gui AND TARGET Qt::Widgets)
add_subdirectory(qaccessibility)
endif()
if(TARGET Qt::Gui)
diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
index 49d0ce212d..a593a91525 100644
--- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
+++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
@@ -269,13 +269,21 @@ void tst_QAccessibility::onClicked()
click_count++;
}
+static bool initAccessibility()
+{
+ QPlatformIntegration *pfIntegration = QGuiApplicationPrivate::platformIntegration();
+ if (pfIntegration->accessibility()) {
+ pfIntegration->accessibility()->setActive(true);
+ return true;
+ }
+ return false;
+}
+
void tst_QAccessibility::initTestCase()
{
QTestAccessibility::initialize();
- QPlatformIntegration *pfIntegration = QGuiApplicationPrivate::platformIntegration();
- if (!pfIntegration->accessibility())
+ if (!initAccessibility())
QSKIP("This platform does not support accessibility");
- pfIntegration->accessibility()->setActive(true);
}
void tst_QAccessibility::cleanupTestCase()
@@ -286,6 +294,17 @@ void tst_QAccessibility::cleanupTestCase()
void tst_QAccessibility::init()
{
QTestAccessibility::clearEvents();
+#ifdef Q_OS_ANDROID
+ // On Android a11y state is not explicitly set by calling
+ // QPlatformAccessibility::setActive(), there is another flag that is
+ // controlled from the Java side. The state of this flag is queried
+ // during event processing, so a11y state can be reset to false while
+ // we do QTest::qWait().
+ // To overcome the issue in unit-tests, re-enable a11y before each test.
+ // A more precise fix will require re-enabling it after every qWait() or
+ // processEvents() call, but the current tests pass with such condition.
+ initAccessibility();
+#endif
}
void tst_QAccessibility::cleanup()
@@ -1978,6 +1997,10 @@ void tst_QAccessibility::mdiSubWindowTest()
mdiArea.setActiveSubWindow(testWindow);
+#ifdef Q_OS_ANDROID // on Android QMdiSubWindow is maximized by default
+ testWindow->showNormal();
+#endif
+
// state
QAccessible::State state;
state.focusable = true;