1
/****************************************************************************
3
** Copyright (C) 2016 The Qt Company Ltd.
4
** Contact: https://www.qt.io/licensing/
6
** This file is part of the test suite of the Qt Toolkit.
8
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
9
** Commercial License Usage
10
** Licensees holding valid commercial Qt licenses may use this file in
11
** accordance with the commercial license agreement provided with the
12
** Software or, alternatively, in accordance with the terms contained in
13
** a written agreement between you and The Qt Company. For licensing terms
14
** and conditions see https://www.qt.io/terms-conditions. For further
15
** information use the contact form at https://www.qt.io/contact-us.
17
** GNU General Public License Usage
18
** Alternatively, this file may be used under the terms of the GNU
19
** General Public License version 3 as published by the Free Software
20
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21
** included in the packaging of this file. Please review the following
22
** information to ensure the GNU General Public License requirements will
23
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
27
****************************************************************************/
29
#include <QApplication>
31
#include <QtTest/QtTest>
32
#include <QtCore/qcoreapplication.h>
34
#include "tst_qaccessibilitymac_helpers.h"
39
class AccessibleTestWindow : public QWidget
43
AccessibleTestWindow()
45
new QHBoxLayout(this);
48
void addWidget(QWidget* widget)
50
layout()->addWidget(widget);
52
QTest::qWaitForWindowExposed(widget);
57
qDeleteAll(children());
58
new QHBoxLayout(this);
62
class tst_QAccessibilityMac : public QObject
69
void singleWidgetTest();
72
void notificationsTest();
76
AccessibleTestWindow *m_window;
80
void tst_QAccessibilityMac::init()
82
m_window = new AccessibleTestWindow();
83
m_window->setWindowTitle("Test window");
85
m_window->resize(400, 400);
87
QTest::qWaitForWindowExposed(m_window);
90
void tst_QAccessibilityMac::cleanup()
95
void tst_QAccessibilityMac::singleWidgetTest()
97
if (!macNativeAccessibilityEnabled())
103
QVERIFY(singleWidget());
106
void tst_QAccessibilityMac::lineEditTest()
108
if (!macNativeAccessibilityEnabled())
111
QLineEdit *lineEdit = new QLineEdit(m_window);
112
lineEdit->setText("a11y test QLineEdit");
113
m_window->addWidget(lineEdit);
114
QVERIFY(QTest::qWaitForWindowExposed(m_window));
115
QCoreApplication::processEvents();
117
QVERIFY(testLineEdit());
120
void tst_QAccessibilityMac::hierarchyTest()
122
if (!macNativeAccessibilityEnabled())
125
QWidget *w = new QWidget(m_window);
126
m_window->addWidget(w);
128
w->setLayout(new QVBoxLayout());
129
QPushButton *b = new QPushButton(w);
130
w->layout()->addWidget(b);
131
b->setText("I am a button");
133
QPushButton *b2 = new QPushButton(w);
134
w->layout()->addWidget(b2);
135
b2->setText("Button 2");
137
QVERIFY(QTest::qWaitForWindowExposed(m_window));
138
QCoreApplication::processEvents();
139
QVERIFY(testHierarchy(w));
142
void tst_QAccessibilityMac::notificationsTest()
144
if (!macNativeAccessibilityEnabled())
147
QVERIFY(notifications(m_window));
150
void tst_QAccessibilityMac::checkBoxTest()
152
if (!macNativeAccessibilityEnabled())
155
QCheckBox *cb = new QCheckBox(m_window);
156
cb->setText("Great option");
157
m_window->addWidget(cb);
158
QVERIFY(QTest::qWaitForWindowExposed(m_window));
159
QCoreApplication::processEvents();
161
QVERIFY(testCheckBox());
164
QTEST_MAIN(tst_QAccessibilityMac)
165
#include "tst_qaccessibilitymac.moc"