a11y: Report mixed state if QCheckBox is PartiallyChecked

Previously it only returned checked or unchecked for a tri-state
checkbox.

Fixes: QTBUG-84616
Change-Id: Ife72098e35f8295fd389bda232de5478ffa7e87f
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit f4887aca1e5ac7b90abf862d7c9828417a74a1b6)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Jan Arve Sæther 2021-02-03 11:49:47 +01:00 committed by Qt Cherry-pick Bot
parent 8652493529
commit fd15b28cf8
4 changed files with 9 additions and 3 deletions

View File

@ -389,6 +389,8 @@ id getValueAttribute(QAccessibleInterface *interface)
} }
if (interface->state().checkable) { if (interface->state().checkable) {
if (interface->state().checkStateMixed)
return @(2);
return interface->state().checked ? @(1) : @(0); return interface->state().checked ? @(1) : @(0);
} }

View File

@ -143,7 +143,7 @@ void tst_QAccessibilityMac::checkBoxTest()
QVERIFY(QTest::qWaitForWindowExposed(m_window)); QVERIFY(QTest::qWaitForWindowExposed(m_window));
QCoreApplication::processEvents(); QCoreApplication::processEvents();
QVERIFY(testCheckBox()); QVERIFY(testCheckBox(cb));
} }
QTEST_MAIN(tst_QAccessibilityMac) QTEST_MAIN(tst_QAccessibilityMac)

View File

@ -28,6 +28,7 @@
#include <QtCore/QString> #include <QtCore/QString>
#include <QtCore/QPair> #include <QtCore/QPair>
#include <QtWidgets/QWidget> #include <QtWidgets/QWidget>
#include <QtWidgets/QCheckBox>
#pragma once // Yeah, it's deprecated in general, but it's standard practice for Mac OS X. #pragma once // Yeah, it's deprecated in general, but it's standard practice for Mac OS X.
@ -37,4 +38,4 @@ bool testLineEdit();
bool testHierarchy(QWidget *w); bool testHierarchy(QWidget *w);
bool singleWidget(); bool singleWidget();
bool notifications(QWidget *w); bool notifications(QWidget *w);
bool testCheckBox(); bool testCheckBox(QCheckBox *ckBox);

View File

@ -565,7 +565,7 @@ bool notifications(QWidget *w)
return true; return true;
} }
bool testCheckBox() bool testCheckBox(QCheckBox *ckBox)
{ {
TestAXObject *appObject = [TestAXObject getApplicationAXObject]; TestAXObject *appObject = [TestAXObject getApplicationAXObject];
EXPECT(appObject); EXPECT(appObject);
@ -596,5 +596,8 @@ bool testCheckBox()
[cb performAction:kAXPressAction]; [cb performAction:kAXPressAction];
EXPECT([cb valueNumber] == 0); EXPECT([cb valueNumber] == 0);
ckBox->setCheckState(Qt::PartiallyChecked);
EXPECT([cb valueNumber] == 2);
return true; return true;
} }